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 <pclouds@gmail.com> Reviewed-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
May 22, 2016 at 16:33 UTC
0409e0b6dc169b07c05d02e8b62389b1cc975a45
1 file changed
+3
-1
builtin/worktree.c
+3
-1
@@ -337,7 +337,7 @@ static int add(int ac, const char **av, const char *prefix)
337
if (ac < 1 || ac > 2)
338
usage_with_options(worktree_usage, options);
339
340
- path = prefix ? prefix_filename(prefix, strlen(prefix), av[0]) : av[0];
340
+ path = prefix_filename(prefix, strlen(prefix), av[0]);
341
branch = ac < 2 ? "HEAD" : av[1];
342
343
opts.force_new_branch = !!new_branch_force;
@@ -467,6 +467,8 @@ int cmd_worktree(int ac, const char **av, const char *prefix)
467
468
if (ac < 2)
469
usage_with_options(worktree_usage, options);
470
+ if (!prefix)
471
+ prefix = "";
472
if (!strcmp(av[1], "add"))
473
return add(ac - 1, av + 1, prefix);
474
if (!strcmp(av[1], "prune"))