diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-07-06 13:38:11 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-07-06 13:38:11 -0700 |
commit | 7a738b40f67fc44c2a2c1abcffe474241af3d30e (patch) | |
tree | 38045c933a3d7247599a9d2f5ba0d981ea7a8832 /builtin | |
parent | Merge branch 'jk/bisect-show-tree' (diff) | |
parent | worktree: simplify prefixing paths (diff) | |
download | tgif-7a738b40f67fc44c2a2c1abcffe474241af3d30e.tar.xz |
Merge branch 'nd/worktree-cleanup-post-head-protection'
Further preparatory clean-up for "worktree" feature continues.
* nd/worktree-cleanup-post-head-protection:
worktree: simplify prefixing paths
worktree: avoid 0{40}, too many zeroes, hard to read
worktree.c: use is_dot_or_dotdot()
git-worktree.txt: keep subcommand listing in alphabetical order
worktree.c: rewrite mark_current_worktree() to avoid strbuf
completion: support git-worktree
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/worktree.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/builtin/worktree.c b/builtin/worktree.c index e3199a22e5..e866844685 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -13,8 +13,8 @@ static const char * const worktree_usage[] = { N_("git worktree add [<options>] <path> [<branch>]"), - N_("git worktree prune [<options>]"), N_("git worktree list [<options>]"), + N_("git worktree prune [<options>]"), NULL }; @@ -95,7 +95,7 @@ static void prune_worktrees(void) if (!dir) return; while ((d = readdir(dir)) != NULL) { - if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")) + if (is_dot_or_dotdot(d->d_name)) continue; strbuf_reset(&reason); if (!prune_worktree(d->d_name, &reason)) @@ -262,7 +262,7 @@ static int add_worktree(const char *path, const char *refname, */ strbuf_reset(&sb); strbuf_addf(&sb, "%s/HEAD", sb_repo.buf); - write_file(sb.buf, "0000000000000000000000000000000000000000"); + write_file(sb.buf, sha1_to_hex(null_sha1)); strbuf_reset(&sb); strbuf_addf(&sb, "%s/commondir", sb_repo.buf); write_file(sb.buf, "../.."); @@ -337,7 +337,7 @@ static int add(int ac, const char **av, const char *prefix) if (ac < 1 || ac > 2) usage_with_options(worktree_usage, options); - path = prefix ? prefix_filename(prefix, strlen(prefix), av[0]) : av[0]; + path = prefix_filename(prefix, strlen(prefix), av[0]); branch = ac < 2 ? "HEAD" : av[1]; if (!strcmp(branch, "-")) @@ -470,6 +470,8 @@ int cmd_worktree(int ac, const char **av, const char *prefix) if (ac < 2) usage_with_options(worktree_usage, options); + if (!prefix) + prefix = ""; if (!strcmp(av[1], "add")) return add(ac - 1, av + 1, prefix); if (!strcmp(av[1], "prune")) |