Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save anonymous/162689 to your computer and use it in GitHub Desktop.
From 2776a399ff5d7e16bd421c4bd06feed3b67b7fdf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= <B.Steinbrink@gmx.de>
Date: Wed, 5 Aug 2009 15:51:01 +0200
Subject: [PATCH] git-describe: Die early if there are no possible descriptions
If we found no refs that may be used for git-describe with the current
options, then die early instead of pointlessly walking the whole history.
---
builtin-describe.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/builtin-describe.c b/builtin-describe.c
index 7a66298..cf802d1 100644
--- a/builtin-describe.c
+++ b/builtin-describe.c
@@ -20,6 +20,7 @@ static int tags; /* Allow lightweight tags */
static int longformat;
static int abbrev = DEFAULT_ABBREV;
static int max_candidates = 10;
+static int found_names = 0;
static const char *pattern;
static int always;
@@ -39,6 +40,8 @@ static void add_to_known_names(const char *path,
const unsigned char *sha1)
{
struct commit_name *e = commit->util;
+ if (!e)
+ found_names++;
if (!e || e->prio < prio) {
size_t len = strlen(path)+1;
free(e);
@@ -195,6 +198,9 @@ static void describe(const char *arg, int last_one)
for_each_ref(get_name, NULL);
}
+ if (!found_names)
+ die("cannot describe '%s'", sha1_to_hex(sha1));
+
n = cmit->util;
if (n) {
/*
--
1.6.4.19.g42af.dirty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment