Skip to content

Commit 35039ce

Browse files
jrngitster
authored andcommitted
archive: abbreviate substituted commit ids again
Given a file with: (define archive-id "$Format:%ct|%h|a$") and an export-subst attribute, the "%h" results in an full 40-digit object name instead of the expected 7-digit one. The export-subst feature requests unabbreviated object names because that is the low-level default. The effect was not observable until v1.7.1.1~17^2~3 (2010-05-03), which taught log --format=%h to respect the --abbrev option. Reported-by: Eli Barzilay <[email protected]> Tested-by: Eli Barzilay <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9a9fb5d commit 35039ce

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

archive.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ static void format_subst(const struct commit *commit,
3333
struct strbuf fmt = STRBUF_INIT;
3434
struct pretty_print_context ctx = {0};
3535
ctx.date_mode = DATE_NORMAL;
36+
ctx.abbrev = DEFAULT_ABBREV;
3637

3738
if (src == buf->buf)
3839
to_free = strbuf_detach(buf, NULL);

t/t5001-archive-attr.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ test_description='git archive attribute tests'
44

55
. ./test-lib.sh
66

7-
SUBSTFORMAT=%H%n
7+
SUBSTFORMAT='%H (%h)%n'
88

99
test_expect_exists() {
1010
test_expect_success " $1 exists" "test -e $1"

0 commit comments

Comments
 (0)