Skip to content

nd/worktree-move update

Nguyễn Thái Ngọc Duy git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest6 patches 8 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6worktree.c: add validate_worktree()worktree.c worktree.h+71 -02 replies
2/6worktree.c: add update_worktree_location()worktree.c worktree.h+27 -01 reply
3/6worktree move: new commandDocumentation/git-worktree.txt builtin/worktree.c contrib/completion/git-completion.bash +1 more+79 -21 reply
4/6worktree move: accept destination as directorybuiltin/worktree.c+18 -11 reply
5/6worktree move: refuse to move worktrees with submodulesbuiltin/worktree.c+23 -01 reply
6/6worktree remove: new commandDocumentation/git-worktree.txt builtin/worktree.c contrib/completion/git-completion.bash +1 more+121 -101 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/6] nd/worktree-move update

This

- squashes in Johannes' fix (that's already on jch/nd/worktree-move)
- fixes the compile problem on latest master (because prefix_filename takes one argument less)
- fixes the test failure because real_path() is called twice (the first one hidden in read_gitfile_gently) but the output is not duplicated.

builtin/worktree.c +1 -3
index 74fc8578fc..b5afba1646 100644
@@ -561,9 +561,7 @@ static int move_worktree(int ac, const char **av, const char *prefix)
 	if (ac != 2)
 		usage_with_options(worktree_usage, options);
 
-	strbuf_addstr(&dst, prefix_filename(prefix,
-					    strlen(prefix),
-					    av[1]));
+	strbuf_addstr(&dst, prefix_filename(prefix, av[1]));
 	if (is_directory(dst.buf))
 		/*
 		 * keep going, dst will be appended after we get the
worktree.c +8 -5
index 85bf481cec..c695dcf982 100644
@@ -311,8 +311,8 @@ static int report(int quiet, const char *fmt, ...)
 int validate_worktree(const struct worktree *wt, int quiet)
 {
 	struct strbuf sb = STRBUF_INIT;
-	const char *path;
-	int err;
+	char *path;
+	int err, ret;
 
 	if (is_main_worktree(wt)) {
 		/*
@@ -344,14 +344,17 @@ int validate_worktree(const struct worktree *wt, int quiet)
 		return report(quiet, _("'%s/.git' does not exist"), wt->path);
 	}
 
-	path = read_gitfile_gently(sb.buf, &err);
+	path = xstrdup_or_null(read_gitfile_gently(sb.buf, &err));
 	strbuf_release(&sb);
 	if (!path)
 		return report(quiet, _("'%s/.git' is not a .git file, error code %d"),
 			      wt->path, err);
 
-	if (fspathcmp(path, real_path(git_common_path("worktrees/%s", wt->id))))
-		return report(quiet, _("'%s' does not point back to"),
+	ret = fspathcmp(path, real_path(git_common_path("worktrees/%s", wt->id)));
+	free(path);
+
+	if (ret)
+		return report(quiet, _("'%s' does not point back to '%s'"),
 			      wt->path, git_common_path("worktrees/%s", wt->id));
 
 	return 0;

Nguyễn Thái Ngọc Duy (6):
worktree.c: add validate_worktree() worktree.c: add update_worktree_location() worktree move: new command
worktree move: accept destination as directory worktree move: refuse to move worktrees with submodules worktree remove: new command

 Documentation/git-worktree.txt         |  28 +++---
 builtin/worktree.c                     | 160 +++++++++++++++++++++++++++++++++
 contrib/completion/git-completion.bash |   5 +-
 t/t2028-worktree-move.sh               |  57 ++++++++++++
 worktree.c                             |  87 ++++++++++++++++++
 worktree.h                             |  11 +++
 6 files changed, 337 insertions(+), 11 deletions(-)
Signature · 1 line
2.11.0.157.gd943d85