diff options
| author | Junio C Hamano <gitster@pobox.com> | 2017-03-27 10:59:26 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2017-03-27 10:59:26 -0700 |
| commit | a026bde1ac84f90f0b82faa18890b2023c5198d5 (patch) | |
| tree | 8e976b861d4b23904c09bb1fbdd8004f37cb6e6f /worktree.c | |
| parent | Merge branch 'jc/lint-runaway-here-doc' (diff) | |
| parent | bundle: use prefix_filename with bundle path (diff) | |
| download | git-a026bde1ac84f90f0b82faa18890b2023c5198d5.tar.gz git-a026bde1ac84f90f0b82faa18890b2023c5198d5.zip | |
Merge branch 'jk/prefix-filename'
Code clean-up with minor bugfixes.
* jk/prefix-filename:
bundle: use prefix_filename with bundle path
prefix_filename: simplify windows #ifdef
prefix_filename: return newly allocated string
prefix_filename: drop length parameter
prefix_filename: move docstring to header file
hash-object: fix buffer reuse with --path in a subdirectory
Diffstat (limited to 'worktree.c')
| -rw-r--r-- | worktree.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/worktree.c b/worktree.c index fa7bc67a50..bae787cf8d 100644 --- a/worktree.c +++ b/worktree.c @@ -250,16 +250,19 @@ struct worktree *find_worktree(struct worktree **list, { struct worktree *wt; char *path; + char *to_free = NULL; if ((wt = find_worktree_by_suffix(list, arg))) return wt; - arg = prefix_filename(prefix, strlen(prefix), arg); + if (prefix) + arg = to_free = prefix_filename(prefix, arg); path = real_pathdup(arg, 1); for (; *list; list++) if (!fspathcmp(path, real_path((*list)->path))) break; free(path); + free(to_free); return *list; } |
