diff options
| author | Vicent Marti <tanoku@gmail.com> | 2011-02-09 12:43:19 +0200 |
|---|---|---|
| committer | Vicent Marti <tanoku@gmail.com> | 2011-02-09 12:43:19 +0200 |
| commit | 995f9c34a580bc17be577d807f9a3bcfd417a748 (patch) | |
| tree | d8039db19889dce3ce99eb525367083030335bbe /src/refs.c | |
| parent | 772c7e762363d6d5b5627941057775ba06886bb6 (diff) | |
| download | libgit2-995f9c34a580bc17be577d807f9a3bcfd417a748.tar.gz | |
Use the new git__joinpath to build paths in methods
The `git__joinpath` function has been changed to use a statically
allocated buffer; we assume the buffer to be 4096 bytes, because fuck
you.
The new method also supports an arbritrary number of paths to join,
which may come in handy in the future.
Some methods which were manually joining paths with `strcpy` now use the
new function, namely those in `index.c` and `refs.c`.
Based on Emeric Fermas' original patch, which was using the old
`git__joinpath` because I'm stupid. Thanks!
Signed-off-by: Vicent Marti <tanoku@gmail.com>
Diffstat (limited to 'src/refs.c')
| -rw-r--r-- | src/refs.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/refs.c b/src/refs.c index eca50ddaa..a3055650f 100644 --- a/src/refs.c +++ b/src/refs.c @@ -159,8 +159,7 @@ static int read_loose_ref(gitfo_buf *file_content, const char *name, const char char ref_path[GIT_PATH_MAX]; /* Determine the full path of the ref */ - strcpy(ref_path, repo_path); - strcat(ref_path, name); + git__joinpath(ref_path, repo_path, name); /* Does it even exist ? */ if (gitfo_exists(ref_path) < GIT_SUCCESS) @@ -228,8 +227,7 @@ static int read_packed_refs(gitfo_buf *packfile, const char *repo_path) char ref_path[GIT_PATH_MAX]; /* Determine the full path of the file */ - strcpy(ref_path, repo_path); - strcat(ref_path, GIT_PACKEDREFS_FILE); + git__joinpath(ref_path, repo_path, GIT_PACKEDREFS_FILE); /* Does it even exist ? */ if (gitfo_exists(ref_path) < GIT_SUCCESS) @@ -528,8 +526,7 @@ int git_reference_write(git_reference *ref) if ((error = check_refname(ref->name)) < GIT_SUCCESS) return error; - strcpy(ref_path, ref->owner->path_repository); - strcat(ref_path, ref->name); + git__joinpath(ref_path, ref->owner->path_repository, ref->name); if ((error = git_filelock_init(&lock, ref_path)) < GIT_SUCCESS) goto error_cleanup; |
