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

Re: [PATCH v2 00/11] git worktree (re)move

From
Duy Nguyen <pclouds@gmail.com>
Date
Nov 29, 2016, 13:56 UTC
Message-ID
<20161129135646.GA19797@ash>
In-Reply-To
<CACsJy8DQDPzZGJXLpTVHVFUeupPpp5e=b9z4m7xceJWrxPfF3Q@mail.gmail.com>
On Tue, Nov 29, 2016 at 07:08:16PM +0700, Duy Nguyen wrote:
Show 20 quoted lines
> On Tue, Nov 29, 2016 at 3:20 AM, Junio C Hamano <gitster@pobox.com> wrote:
> > Junio C Hamano <gitster@pobox.com> writes:
> >
> >> Does this round address the issue raised in
> >>
> >>   http://public-inbox.org/git/alpine.DEB.2.20.1611161041040.3746@virtualbox
> >>
> >> by Dscho?
> 
> It does not (and is sort of expected), quoting from the commit message
> 
>     copy.c: convert copy_file() to copy_dir_recursively()
> 
>     This finally enables busybox's copy_file() code under a new name
>     (because "copy_file" is already taken in Git code base). Because this
>     comes from busybox, POSIXy (or even Linuxy) behavior is expected. More
>     changes may be needed for Windows support.
> 
> I could "#ifdef WINDOWS return -ENOSYS" for now, which would make it
> build. "git worktree move" won't work on Windows of course...

Another way, as pointed out by j6t, is go with "move within filesystem only", at least at the first step. Which is probably a good idea anyway so we can concentrate on git-specific stuff before going to minor and complicated copy/move details.

If you drop all the "copy.c: " patches and squash this to "worktree move: new command", and if Windows rename() can move directories, then git should build and new tests pass.

-- 8< --
diff --git a/builtin/worktree.c b/builtin/worktree.c
index f114965..d8d0127 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -569,9 +569,9 @@ static int move_worktree(int ac, const char **av, const char *prefix)
 				  wt->path, dst.buf);
 
 		/* second try.. */
-		if (copy_dir_recursively(wt->path, dst.buf))
-			die(_("failed to copy '%s' to '%s'"),
-			    wt->path, dst.buf);
+		if (copy_dir_recursively(dst.buf, wt->path))
+			die_errno(_("failed to copy '%s' to '%s'"),
+				  wt->path, dst.buf);
 		else {
 			struct strbuf sb = STRBUF_INIT;
 
diff --git a/cache.h b/cache.h
index a50a61a..2d4edf6 100644
--- a/cache.h
+++ b/cache.h
@@ -1857,6 +1857,7 @@ extern void fprintf_or_die(FILE *, const char *fmt, ...);
 extern int copy_fd(int ifd, int ofd);
 extern int copy_file(const char *dst, const char *src, int mode);
 extern int copy_file_with_time(const char *dst, const char *src, int mode);
+extern int copy_dir_recursively(const char *dst, const char *src);
 
 extern void write_or_die(int fd, const void *buf, size_t count);
 extern void fsync_or_die(int fd, const char *);
diff --git a/copy.c b/copy.c
index 4de6a11..b232aec 100644
--- a/copy.c
+++ b/copy.c
@@ -65,3 +65,9 @@ int copy_file_with_time(const char *dst, const char *src, int mode)
 		return copy_times(dst, src);
 	return status;
 }
+
+int copy_dir_recursively(const char *dst, const char *src)
+{
+	errno = ENOSYS;
+	return -1;
+}
-- 8< --
Previous: Duy NguyenNext: Junio C Hamano
Message 31 of 39 in “git worktree (re)move”
  1. 00/11 git worktree (re)moveNguyễn Thái Ngọc Duy, Nov 12, 2016
  2. 06/11 worktree.c: add validate_worktree()Nguyễn Thái Ngọc Duy, Nov 12, 2016
  3. 02/11 copy.c: delete unused code in copy_file()Nguyễn Thái Ngọc Duy, Nov 12, 2016
  4. 03/11 copy.c: convert bb_(p)error_msg to error(_errno)Nguyễn Thái Ngọc Duy, Nov 12, 2016
  5. 07/11 worktree.c: add update_worktree_location()Nguyễn Thái Ngọc Duy, Nov 12, 2016
  6. 01/11 copy.c: import copy_file() from busyboxNguyễn Thái Ngọc Duy, Nov 12, 2016
  7. 05/11 copy.c: convert copy_file() to copy_dir_recursively()Nguyễn Thái Ngọc Duy, Nov 12, 2016
  8. 04/11 copy.c: style fixNguyễn Thái Ngọc Duy, Nov 12, 2016
  9. 10/11 worktree move: refuse to move worktrees with submodulesNguyễn Thái Ngọc Duy, Nov 12, 2016
  10. 09/11 worktree move: accept destination as directoryNguyễn Thái Ngọc Duy, Nov 12, 2016
  11. 08/11 worktree move: new commandNguyễn Thái Ngọc Duy, Nov 12, 2016
  12. 11/11 worktree remove: new commandNguyễn Thái Ngọc Duy, Nov 12, 2016
  13. 00/11 git worktree (re)moveNguyễn Thái Ngọc Duy, Nov 28, 2016
  14. 01/11 copy.c: import copy_file() from busyboxNguyễn Thái Ngọc Duy, Nov 28, 2016
  15. 02/11 copy.c: delete unused code in copy_file()Nguyễn Thái Ngọc Duy, Nov 28, 2016
  16. 03/11 copy.c: convert bb_(p)error_msg to error(_errno)Nguyễn Thái Ngọc Duy, Nov 28, 2016
  17. 04/11 copy.c: style fixNguyễn Thái Ngọc Duy, Nov 28, 2016
  18. 05/11 copy.c: convert copy_file() to copy_dir_recursively()Nguyễn Thái Ngọc Duy, Nov 28, 2016
  19. 06/11 worktree.c: add validate_worktree()Nguyễn Thái Ngọc Duy, Nov 28, 2016
  20. 07/11 worktree.c: add update_worktree_location()Nguyễn Thái Ngọc Duy, Nov 28, 2016
  21. 08/11 worktree move: new commandNguyễn Thái Ngọc Duy, Nov 28, 2016
  22. 09/11 worktree move: accept destination as directoryNguyễn Thái Ngọc Duy, Nov 28, 2016
  23. 10/11 worktree move: refuse to move worktrees with submodulesNguyễn Thái Ngọc Duy, Nov 28, 2016
  24. Stefan BellerDec 19, 2016
  25. 11/11 worktree remove: new commandNguyễn Thái Ngọc Duy, Nov 28, 2016
  26. Junio C HamanoNov 28, 2016
  27. Junio C HamanoNov 28, 2016
  28. Johannes SixtNov 28, 2016
  29. Duy NguyenNov 29, 2016
  30. Duy NguyenNov 29, 2016
  31. Duy NguyenNov 29, 2016
  32. Junio C HamanoNov 29, 2016
  33. Stefan BellerNov 30, 2016
  34. Johannes SixtNov 29, 2016
  35. Duy NguyenNov 30, 2016
  36. Duy NguyenNov 16, 2016
  37. Duy NguyenNov 16, 2016
  38. Junio C HamanoNov 16, 2016
  39. Junio C HamanoNov 16, 2016

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.