index-pack: correct --keep[=<msg>]

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>

Junio C Hamano committed Mar 3, 2016 at 10:52 UTC 0e94242df1ba11830c5443a55decaa041fa97710
2 files changed +7 -1
builtin/index-pack.c
+1 -1
@@ -1617,7 +1617,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
1617 die(_("packfile name '%s' does not end with '.pack'"),
1618 pack_name);
1619 strbuf_add(&keep_name_buf, pack_name, len);
1620 - strbuf_addstr(&keep_name_buf, ".idx");
1620 + strbuf_addstr(&keep_name_buf, ".keep");
1621 keep_name = keep_name_buf.buf;
1622 }
1623 if (verify) {
t/t5300-pack-object.sh
+6
@@ -284,6 +284,12 @@ test_expect_success \
284 git index-pack test-3.pack &&
285 cmp test-3.idx test-3-${packname_3}.idx &&
286
287 + cat test-1-${packname_1}.pack >test-4.pack &&
288 + rm -f test-4.keep &&
289 + git index-pack --keep=why test-4.pack &&
290 + cmp test-1-${packname_1}.idx test-4.idx &&
291 + test -f test-4.keep &&
292 +
293 :'
294
295 test_expect_success 'unpacking with --strict' '