git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] index-pack: correct --keep[=<msg>]
@ 2016-03-03 19:14 Junio C Hamano
  2016-03-03 19:47 ` Jeff King
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Junio C Hamano @ 2016-03-03 19:14 UTC (permalink / raw)
  To: git

When 592ce208 (index-pack: use strip_suffix to avoid magic numbers,
2014-06-30) refactored the code to derive names of .idx and .keep
files from the name of .pack file, a copy-and-paste typo crept in,
mistakingly attempting to create and store the keep message file in
the .idx file we just created, instead of .keep file.

As we create the .keep file with O_CREAT|O_EXCL, and we do so after
we write the .idx file, we luckily do not clobber the .idx file, but
because we deliberately ignored EEXIST when creating .keep file
(which is justifiable because only the existence of .keep file
matters), nobody noticed this mistake so far.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

 * In a later patch, I'll be adding another file to the family of
   .pack/.idx/.keep files, and the body of these if() statements
   would be made into a helper function when it happens.  This is to
   fix it directly on top of the problematic commit without such a
   helper, the result of which could be merged to 2.1.x and later
   maintenance series.

 builtin/index-pack.c   | 2 +-
 t/t5300-pack-object.sh | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index d4b77fd..3814731 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -1617,7 +1617,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
 			die(_("packfile name '%s' does not end with '.pack'"),
 			    pack_name);
 		strbuf_add(&keep_name_buf, pack_name, len);
-		strbuf_addstr(&keep_name_buf, ".idx");
+		strbuf_addstr(&keep_name_buf, ".keep");
 		keep_name = keep_name_buf.buf;
 	}
 	if (verify) {
diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh
index 20c1961..0e3cadf 100755
--- a/t/t5300-pack-object.sh
+++ b/t/t5300-pack-object.sh
@@ -284,6 +284,12 @@ test_expect_success \
      git index-pack test-3.pack &&
      cmp test-3.idx test-3-${packname_3}.idx &&
 
+     cat test-1-${packname_1}.pack >test-4.pack &&
+     rm -f test-4.keep &&
+     git index-pack --keep=why test-4.pack &&
+     cmp test-1-${packname_1}.idx test-4.idx &&
+     test -f test-4.keep &&
+
      :'
 
 test_expect_success 'unpacking with --strict' '
-- 
v2.0.1-6-g592ce20

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-03-04 15:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-03 19:14 [PATCH] index-pack: correct --keep[=<msg>] Junio C Hamano
2016-03-03 19:47 ` Jeff King
2016-03-03 21:37 ` [PATCH] index-pack: add a helper function to derive .idx/.keep filename Junio C Hamano
2016-03-03 22:29   ` Jeff King
2016-03-03 22:57     ` [PATCH] index-pack: --clone-bundle option Junio C Hamano
2016-03-03 23:20       ` Junio C Hamano
2016-03-04 15:51         ` Jeff King
2016-03-04 15:34       ` Jeff King
2016-03-03 21:44 ` [PATCH] index-pack: correct --keep[=<msg>] Eric Sunshine

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 NNTP newsgroup(s).