From 7b722d906bd5b32f3c7a63fb77835b38c1e04e4a Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Sun, 22 May 2016 16:33:53 +0700 Subject: git-worktree.txt: keep subcommand listing in alphabetical order MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is probably not the best order. But it makes it no-brainer to know where to insert new commands. At some point we might want to reorder at least the synopsis part again, grouping commonly use subcommands together. Signed-off-by: Nguyễn Thái Ngọc Duy Reviewed-by: Eric Sunshine Signed-off-by: Junio C Hamano --- builtin/worktree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/worktree.c b/builtin/worktree.c index 12c0af723e..bf80111fd8 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -13,8 +13,8 @@ static const char * const worktree_usage[] = { N_("git worktree add [] []"), - N_("git worktree prune []"), N_("git worktree list []"), + N_("git worktree prune []"), NULL }; -- cgit v1.3-5-g9baa From afb9e30b2cadfa010975b29e0ff7459d4b7ae953 Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Sun, 22 May 2016 16:33:54 +0700 Subject: worktree.c: use is_dot_or_dotdot() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy Reviewed-by: Eric Sunshine Signed-off-by: Junio C Hamano --- builtin/worktree.c | 2 +- worktree.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'builtin') diff --git a/builtin/worktree.c b/builtin/worktree.c index bf80111fd8..aaee0e2fe8 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -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)) diff --git a/worktree.c b/worktree.c index 6a11611e60..f4a4f38092 100644 --- a/worktree.c +++ b/worktree.c @@ -187,7 +187,7 @@ struct worktree **get_worktrees(void) if (dir) { while ((d = readdir(dir)) != NULL) { struct worktree *linked = NULL; - if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")) + if (is_dot_or_dotdot(d->d_name)) continue; if ((linked = get_linked_worktree(d->d_name))) { -- cgit v1.3-5-g9baa From ef23c347cf363118e236ae72fe6372443fae1ecf Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Sun, 22 May 2016 16:33:55 +0700 Subject: worktree: avoid 0{40}, too many zeroes, hard to read MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy Reviewed-by: Eric Sunshine Signed-off-by: Junio C Hamano --- builtin/worktree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/worktree.c b/builtin/worktree.c index aaee0e2fe8..b53f8024fc 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -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, "../.."); -- cgit v1.3-5-g9baa From 0409e0b6dc169b07c05d02e8b62389b1cc975a45 Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Sun, 22 May 2016 16:33:56 +0700 Subject: worktree: simplify prefixing paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Eric Sunshine Signed-off-by: Junio C Hamano --- builtin/worktree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/worktree.c b/builtin/worktree.c index b53f8024fc..f9dac376f7 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -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]; opts.force_new_branch = !!new_branch_force; @@ -467,6 +467,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")) -- cgit v1.3-5-g9baa