git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] describe: make '--always' fallback work after '--exact-match' failed
@ 2015-08-20 12:13 SZEDER Gábor
  2015-08-20 18:39 ` Junio C Hamano
  2015-08-21 14:50 ` [PATCH] describe --contains: default to HEAD when no commit-ish is given SZEDER Gábor
  0 siblings, 2 replies; 9+ messages in thread
From: SZEDER Gábor @ 2015-08-20 12:13 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, SZEDER Gábor

'git describe [...] --always' should always show the unique abbreviated
object name as a fallback when the given commit cannot be described with
the given set of options, see da2478dbb0 (describe --always: fall back
to showing an abbreviated object name, 2008-03-02).

However, this is not the case when the combination '--exact-match
--always' is given and the commit cannot be described, because in such
cases 'git describe' errors out, as if '--always' were not given at all.

Respect '--always' and print the unique abbreviated object name instead
of erroring out when the commit cannot be described with '--exact-match
--always'.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
---
 builtin/describe.c  | 2 +-
 t/t6120-describe.sh | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/builtin/describe.c b/builtin/describe.c
index a36c829e57..ce36032b1f 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -266,7 +266,7 @@ static void describe(const char *arg, int last_one)
 		return;
 	}
 
-	if (!max_candidates)
+	if (!always && !max_candidates)
 		die(_("no tag exactly matches '%s'"), sha1_to_hex(cmit->object.sha1));
 	if (debug)
 		fprintf(stderr, _("searching to describe %s\n"), arg);
diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh
index c0e5b2a627..57d50156bb 100755
--- a/t/t6120-describe.sh
+++ b/t/t6120-describe.sh
@@ -113,6 +113,8 @@ check_describe A-3-* --long HEAD^^2
 check_describe c-7-* --tags
 check_describe e-3-* --first-parent --tags
 
+check_describe $(git rev-parse --short HEAD) --exact-match --always HEAD
+
 : >err.expect
 check_describe A --all A^0
 test_expect_success 'no warning was displayed for A' '
-- 
2.5.0.343.g6f38143

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-08-24 18:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-20 12:13 [PATCH] describe: make '--always' fallback work after '--exact-match' failed SZEDER Gábor
2015-08-20 18:39 ` Junio C Hamano
2015-08-21 11:40   ` SZEDER Gábor
2015-08-21 15:55     ` Junio C Hamano
2015-08-21 14:50 ` [PATCH] describe --contains: default to HEAD when no commit-ish is given SZEDER Gábor
2015-08-21 16:30   ` Junio C Hamano
2015-08-24 16:14     ` SZEDER Gábor
2015-08-24 16:15       ` [PATCH v2] " SZEDER Gábor
2015-08-24 18:47       ` [PATCH] " Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).