From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "Stefan Beller" <stefanbeller@googlemail.com>,
"Torsten Bögershausen" <tboegi@web.de>,
git@vger.kernel.org
Subject: Re: [PATCH] repack.c: rename and unlink pack file if it exists
Date: Wed, 05 Feb 2014 12:06:41 -0800 [thread overview]
Message-ID: <xmqq1tzh494e.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <20140205011632.GA3923@sigill.intra.peff.net> (Jeff King's message of "Tue, 4 Feb 2014 20:16:32 -0500")
Jeff King <peff@peff.net> writes:
> On Tue, Feb 04, 2014 at 03:40:15PM -0800, Junio C Hamano wrote:
>
>> * Somehow this came to my private mailbox without Cc to list, so I
>> am forwarding it.
>>
>> I think with 1190a1ac (pack-objects: name pack files after
>> trailer hash, 2013-12-05), repacking the same set of objects may
>> have less chance of producing colliding names, especially if you
>> are on a box with more than one core, but it still would be a
>> good idea to get this part right in the upcoming release.
>
> Actually, since 1190a1ac, if you have repacked and gotten the same pack
> name, then you do not have to do any rename dance at all; you can throw
> away what you just generated because you know that it is byte-for-byte
> identical.
>
> You could collide with a pack created by an older version of git that
> used the original scheme, but that is quite unlikely (on the order of
> 2^-160).
Yes, so in that sense this is not so urgent, but I'm tempted to
split the original patch into two and merge only the first one to
'master' before -rc3 (see below). The renaming of the variables
added enough noise to cause me fail to spot a change mixed within.
-- >8 --
From: Torsten Bögershausen <tboegi@web.de>
Date: Sun, 2 Feb 2014 16:09:56 +0100
When a repo was fully repacked, and is repacked again, we may run
into the situation that "new" packfiles have the same name as
already existing ones (traditionally packfiles have been named after
the list of names of objects in them, so repacking all the objects
in a single pack would have produced a packfile with the same name).
The logic is to rename the existing ones into filename like
"old-XXX", create the new ones and then remove the "old-" ones.
When something went wrong in the middle, this sequence is rolled
back by renaming the "old-" files back.
The renaming into "old-" did not work as intended, because
file_exists() was done on "XXX", not "pack-XXX". Also when rolling
back the change, the code tried to rename "old-pack-XXX" but the
saved ones are named "old-XXX", so this couldn't have worked.
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin/repack.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin/repack.c b/builtin/repack.c
index bca7710..fe31577 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -260,7 +260,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
for_each_string_list_item(item, &names) {
for (ext = 0; ext < 2; ext++) {
char *fname, *fname_old;
- fname = mkpathdup("%s/%s%s", packdir,
+ fname = mkpathdup("%s/pack-%s%s", packdir,
item->string, exts[ext]);
if (!file_exists(fname)) {
free(fname);
@@ -337,7 +337,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
for_each_string_list_item(item, &names) {
for (ext = 0; ext < 2; ext++) {
char *fname;
- fname = mkpath("%s/old-pack-%s%s",
+ fname = mkpath("%s/old-%s%s",
packdir,
item->string,
exts[ext]);
--
1.9-rc2-217-g24a8b2e
next prev parent reply other threads:[~2014-02-05 20:37 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-04 23:40 [PATCH] repack.c: rename and unlink pack file if it exists Junio C Hamano
2014-02-04 23:43 ` Junio C Hamano
2014-02-05 1:16 ` Jeff King
2014-02-05 17:54 ` Torsten Bögershausen
2014-02-05 20:06 ` Junio C Hamano [this message]
2014-02-05 20:12 ` Jeff King
2014-02-05 20:31 ` Junio C Hamano
2014-02-05 20:37 ` Jeff King
2014-02-05 20:54 ` Jeff King
2014-02-05 20:57 ` Junio C Hamano
2014-02-05 21:01 ` Jeff King
2014-02-05 21:08 ` Junio C Hamano
2014-02-05 21:09 ` Jeff King
2014-02-05 21:01 ` Torsten Bögershausen
2014-02-05 20:10 ` Junio C Hamano
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq1tzh494e.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=stefanbeller@googlemail.com \
--cc=tboegi@web.de \
/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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.