Skip to content

Commit 0409e0b

Browse files
pcloudsgitster
authored andcommitted
worktree: simplify prefixing paths
This also makes slash conversion always happen on Windows (a side effect of prefix_filename). Which is a good thing. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Reviewed-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ef23c34 commit 0409e0b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

builtin/worktree.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ static int add(int ac, const char **av, const char *prefix)
337337
if (ac < 1 || ac > 2)
338338
usage_with_options(worktree_usage, options);
339339

340-
path = prefix ? prefix_filename(prefix, strlen(prefix), av[0]) : av[0];
340+
path = prefix_filename(prefix, strlen(prefix), av[0]);
341341
branch = ac < 2 ? "HEAD" : av[1];
342342

343343
opts.force_new_branch = !!new_branch_force;
@@ -467,6 +467,8 @@ int cmd_worktree(int ac, const char **av, const char *prefix)
467467

468468
if (ac < 2)
469469
usage_with_options(worktree_usage, options);
470+
if (!prefix)
471+
prefix = "";
470472
if (!strcmp(av[1], "add"))
471473
return add(ac - 1, av + 1, prefix);
472474
if (!strcmp(av[1], "prune"))

0 commit comments

Comments
 (0)