Re: [PATCH v3 1/5] checkout: describe_detached_head: remove ellipsis after committish
- From
Ann T Ropea <bedhanger@gmx.de>
- Date
- Nov 19, 2017, 18:41 UTC
- Message-ID
- <20171119184113.16630-1-bedhanger@gmx.de>
- In-Reply-To
- <xmqq1sl17e1u.fsf@gitster.mtv.corp.google.com>
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 (actively!) sets the environment variable PRINT_SHA1_ELLIPSIS to "yes" (case does not matter).
The transient nature of this fallback suggests that we should not prefix the variable by "GIT_".
Signed-off-by: Ann T Ropea <bedhanger@gmx.de> --- v2: rename patch series & focus on removal of ellipses v3: env var instead of config option, use one-line comments where appropriate, preserve indent level builtin/checkout.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/builtin/checkout.c b/builtin/checkout.c index 7d8bcc383351..e6d3a28fe26e 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -400,10 +400,17 @@ static void show_local_changes(struct object *head, static void describe_detached_head(const char *msg, struct commit *commit) { struct strbuf sb = STRBUF_INIT; + const char *env_printsha1ellipsis = getenv("PRINT_SHA1_ELLIPSIS"); + 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 (env_printsha1ellipsis && !strcasecmp(env_printsha1ellipsis, "yes")) { + 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); }
-- 2.13.6