From: Junio C Hamano <gitster@pobox.com>
To: Jens Lindstrom <jl@opera.com>
Cc: git@vger.kernel.org, johan@herland.net
Subject: Re: [PATCH] clone: Skip pack-*.keep files when cloning locally
Date: Fri, 28 Jun 2013 13:38:28 -0700 [thread overview]
Message-ID: <7vvc4ym0mz.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <7vvc4ynkrx.fsf@alter.siamese.dyndns.org> (Junio C. Hamano's message of "Fri, 28 Jun 2013 11:38:10 -0700")
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
next prev parent reply other threads:[~2013-06-28 20:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-28 14:42 [PATCH] clone: Skip pack-*.keep files when cloning locally Jens Lindstrom
2013-06-28 18:38 ` Junio C Hamano
2013-06-28 20:38 ` Junio C Hamano [this message]
2013-07-01 10:24 ` Jens Lindström
2013-07-01 16:20 ` Junio C Hamano
2013-07-03 10:02 ` Jens Lindström
2013-07-03 17:26 ` Junio C Hamano
2013-07-03 18:31 ` Jens Lindström
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vvc4ym0mz.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=jl@opera.com \
--cc=johan@herland.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).