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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <gitster@xxxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]