git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Apr 20, 2017, 10:10 UTC
Message-ID
<20170420101024.7593-1-pclouds@gmail.com>
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.
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 74fc8578fc..b5afba1646 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -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
diff --git a/worktree.c b/worktree.c
index 85bf481cec..c695dcf982 100644
--- a/worktree.c
+++ b/worktree.c
@@ -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(-)
-- 
2.11.0.157.gd943d85
Next: Nguyễn Thái Ngọc Duy
Message 1 of 15 in “nd/worktree-move update”
  1. 0/6 nd/worktree-move updateNguyễn Thái Ngọc Duy, Apr 20, 2017
  2. 1/6 worktree.c: add validate_worktree()Nguyễn Thái Ngọc Duy, Apr 20, 2017
  3. Junio C HamanoApr 21, 2017
  4. Duy NguyenApr 24, 2017
  5. 2/6 worktree.c: add update_worktree_location()Nguyễn Thái Ngọc Duy, Apr 20, 2017
  6. Junio C HamanoApr 21, 2017
  7. 3/6 worktree move: new commandNguyễn Thái Ngọc Duy, Apr 20, 2017
  8. Junio C HamanoApr 21, 2017
  9. 4/6 worktree move: accept destination as directoryNguyễn Thái Ngọc Duy, Apr 20, 2017
  10. Junio C HamanoApr 21, 2017
  11. 5/6 worktree move: refuse to move worktrees with submodulesNguyễn Thái Ngọc Duy, Apr 20, 2017
  12. Junio C HamanoApr 21, 2017
  13. 6/6 worktree remove: new commandNguyễn Thái Ngọc Duy, Apr 20, 2017
  14. Junio C HamanoApr 21, 2017
  15. Jeff KingApr 21, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.