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

Re: [PATCH] clone: Skip pack-*.keep files when cloning locally

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 28, 2013, 20:38 UTC
Message-ID
<7vvc4ym0mz.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7vvc4ynkrx.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
> I am perfectly fine with a change that allows a local clone to skip
> and not error out when such a "keep" marker cannot be copied, I do
> not know if it is a good idea to unconditionally skip and not even
> attempt to copy it.
That is, something like this, perhaps?

We could even create an empty file, as it is only the presense that matters for ".keep" files, but I found it a bit too much special casing to my taste.

 builtin/clone.c        |  9 ++++++++-
 t/t5701-clone-local.sh | 15 +++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index 66bff57..4b7cd9b 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -356,8 +356,15 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest,
 				die_errno(_("failed to create link '%s'"), dest->buf);
 			option_no_hardlinks = 1;
 		}
-		if (copy_file_with_time(dest->buf, src->buf, 0666))
+		if (copy_file_with_time(dest->buf, src->buf, 0666)) {
+			if (!strncmp(src->buf + src_baselen, "/pack/pack-", 11) &&
+			    !suffixcmp(src->buf, ".keep"))
+				goto skip;
+
 			die_errno(_("failed to copy file to '%s'"), dest->buf);
+		skip:
+			warning("skipping %s", src->buf);
+		}
 	}
 	closedir(dir);
 }
diff --git a/t/t5701-clone-local.sh b/t/t5701-clone-local.sh
index 7ff6e0e..bb5dddd 100755
--- a/t/t5701-clone-local.sh
+++ b/t/t5701-clone-local.sh
@@ -134,4 +134,19 @@ test_expect_success 'cloning a local path with --no-local does not hardlink' '
 	! repo_is_hardlinked force-nonlocal
 '
 
+test_expect_success SANITY 'clone --no-hardlinks with unreadable .keep' '
+	mkdir strictsrc &&
+	(
+		cd strictsrc &&
+		git init &&
+		git commit --allow-empty -m initial &&
+		git repack -a -d &&
+		packname=$(echo .git/objects/pack/pack-*.idx) &&
+		keepname=${packname%.idx}.keep &&
+		>"$keepname" &&
+		chmod a= "$keepname"
+	) &&
+	git clone --local --no-hardlinks strictsrc dst
+'
+
 test_done
Previous: Junio C HamanoNext: Jens Lindström
Message 3 of 8 in “clone: Skip pack-*.keep files when cloning locally”
  1. clone: Skip pack-*.keep files when cloning locallyJens Lindstrom, Jun 28, 2013
  2. Junio C HamanoJun 28, 2013
  3. Junio C HamanoJun 28, 2013
  4. Jens LindströmJul 1, 2013
  5. Junio C HamanoJul 1, 2013
  6. Jens LindströmJul 3, 2013
  7. Junio C HamanoJul 3, 2013
  8. Jens LindströmJul 3, 2013

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.