From 35039ced9296786bc0971bf5385c0d6f6ea5ea1e Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Tue, 27 Jul 2010 13:32:36 -0500 Subject: 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 Tested-by: Eli Barzilay Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano diff --git a/archive.c b/archive.c index d700af3..edd6853 100644 --- a/archive.c +++ b/archive.c @@ -33,6 +33,7 @@ static void format_subst(const struct commit *commit, struct strbuf fmt = STRBUF_INIT; struct pretty_print_context ctx = {0}; ctx.date_mode = DATE_NORMAL; + ctx.abbrev = DEFAULT_ABBREV; if (src == buf->buf) to_free = strbuf_detach(buf, NULL); diff --git a/t/t5001-archive-attr.sh b/t/t5001-archive-attr.sh index 426b319..02d4d22 100755 --- a/t/t5001-archive-attr.sh +++ b/t/t5001-archive-attr.sh @@ -4,7 +4,7 @@ test_description='git archive attribute tests' . ./test-lib.sh -SUBSTFORMAT=%H%n +SUBSTFORMAT='%H (%h)%n' test_expect_exists() { test_expect_success " $1 exists" "test -e $1" -- cgit v0.10.2-6-g49f6 From dcbeac48a7e61154c53ae800ea224607c1f7d52a Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Tue, 27 Jul 2010 13:37:07 -0500 Subject: checkout, commit: remove confusing assignments to rev.abbrev Since they do not precede setup_revisions, these assignments of 0 to rev.abbrev have no effect. v1.7.1.1~17^2~3 (2010-05-03) taught the log --format=%h machinery to respect --abbrev instead of always abbreviating, so we have to pay attention to the abbrev setting now. Helped-by: Junio C Hamano Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano diff --git a/builtin/checkout.c b/builtin/checkout.c index 1994be9..eef2b48 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -279,7 +279,6 @@ static void show_local_changes(struct object *head) struct rev_info rev; /* I think we want full paths, even if we're in a subdirectory. */ init_revisions(&rev, NULL); - rev.abbrev = 0; rev.diffopt.output_format |= DIFF_FORMAT_NAME_STATUS; if (diff_setup_done(&rev.diffopt) < 0) die("diff_setup_done failed"); diff --git a/builtin/commit.c b/builtin/commit.c index a78dbd8..279cfc1 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1163,7 +1163,6 @@ static void print_summary(const char *prefix, const unsigned char *sha1) init_revisions(&rev, prefix); setup_revisions(0, NULL, &rev, NULL); - rev.abbrev = 0; rev.diff = 1; rev.diffopt.output_format = DIFF_FORMAT_SHORTSTAT | DIFF_FORMAT_SUMMARY; -- cgit v0.10.2-6-g49f6 From 7f1592db5d4cba2b3de3a1ce46eb8c05bd33e0a1 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Tue, 27 Jul 2010 13:44:51 -0500 Subject: examples/commit: use --abbrev for commit summary After v1.7.1.1~17^2~3 (pretty: Respect --abbrev option, 2010-05-03), plumbing users do not abbreviate %h hashes by default any more. Noticed while investigating the bug fixed by v1.7.1.1~17^2 (commit::print_summary(): don't use format_commit_message(), 2010-06-12). Cc: Will Palmer Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano diff --git a/contrib/examples/git-commit.sh b/contrib/examples/git-commit.sh index 5c72f65..23ffb02 100755 --- a/contrib/examples/git-commit.sh +++ b/contrib/examples/git-commit.sh @@ -631,7 +631,7 @@ then if test -z "$quiet" then commit=`git diff-tree --always --shortstat --pretty="format:%h: %s"\ - --summary --root HEAD --` + --abbrev --summary --root HEAD --` echo "Created${initial_commit:+ initial} commit $commit" fi fi -- cgit v0.10.2-6-g49f6