summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLibravatar Ann T Ropea <bedhanger@gmx.de>2017-12-06 01:20:42 +0100
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-12-06 07:32:40 -0800
commitca69d4d5b14245c9ba4535212c4f4a0621e78ffa (patch)
tree66a56fe0f738068bcfd6c63c8ce6d89cde27b225 /builtin
parentprint_sha1_ellipsis: introduce helper (diff)
downloadtgif-ca69d4d5b14245c9ba4535212c4f4a0621e78ffa.tar.xz
checkout: describe_detached_head: remove ellipsis after committish
We do not want an ellipsis displayed following an (abbreviated) SHA-1 value. The days when this was necessary to indicate the truncation to lower-level Git commands and/or the user are bygone. However, to ease the transition, the ellipsis will still be printed if the user sets the environment variable GIT_PRINT_SHA1_ELLIPSIS to "yes". Correct documentation with respect to what describe_detached_head prints when GIT_PRINT_SHA1_ELLIPSIS is not set as indicated above. Add tests for the old and new behaviour. Signed-off-by: Ann T Ropea <bedhanger@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/checkout.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 6c2b4cd419..6a6f5bcb2a 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -400,10 +400,16 @@ static void show_local_changes(struct object *head,
static void describe_detached_head(const char *msg, struct commit *commit)
{
struct strbuf sb = STRBUF_INIT;
+
if (!parse_commit(commit))
pp_commit_easy(CMIT_FMT_ONELINE, commit, &sb);
- fprintf(stderr, "%s %s... %s\n", msg,
- find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV), sb.buf);
+ if (print_sha1_ellipsis()) {
+ fprintf(stderr, "%s %s... %s\n", msg,
+ find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV), sb.buf);
+ } else {
+ fprintf(stderr, "%s %s %s\n", msg,
+ find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV), sb.buf);
+ }
strbuf_release(&sb);
}