Skip to content

Commit 0e94242

Browse files
committed
index-pack: correct --keep[=<msg>]
When 592ce20 (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>
1 parent 592ce20 commit 0e94242

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

builtin/index-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
16171617
die(_("packfile name '%s' does not end with '.pack'"),
16181618
pack_name);
16191619
strbuf_add(&keep_name_buf, pack_name, len);
1620-
strbuf_addstr(&keep_name_buf, ".idx");
1620+
strbuf_addstr(&keep_name_buf, ".keep");
16211621
keep_name = keep_name_buf.buf;
16221622
}
16231623
if (verify) {

t/t5300-pack-object.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,12 @@ test_expect_success \
284284
git index-pack test-3.pack &&
285285
cmp test-3.idx test-3-${packname_3}.idx &&
286286
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+
287293
:'
288294

289295
test_expect_success 'unpacking with --strict' '

0 commit comments

Comments
 (0)