git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sha1_name: accept output of git-describe
@ 2006-09-20 20:56 Johannes Schindelin
  2006-09-20 21:25 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Johannes Schindelin @ 2006-09-20 20:56 UTC (permalink / raw)
  To: git, junkio


Now, 'git log $(git describe)' does the same as 'git log'.

NOTE: it might be possible that the unique abbreviation generated by
git-describe is no longer unique at a later stage. Evidently, in this
case the sha1 resolution fails.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
 sha1_name.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/sha1_name.c b/sha1_name.c
index b497528..c1f6cca 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -159,6 +159,18 @@ static int get_short_sha1(const char *na
 
 	if (len < MINIMUM_ABBREV)
 		return -1;
+
+	/* check for output of git-describe */
+	if (len > MINIMUM_ABBREV + 2) {
+		int i;
+		for (i = len - MINIMUM_ABBREV - 2; i > 0 && name[i] != '-'; i--)
+			; /* do nothing */
+		if (i > 0 && name[i + 1] == 'g') {
+			name += i + 2;
+			len -= i + 2;
+		}
+	}
+
 	hashclr(res);
 	memset(canonical, 'x', 40);
 	for (i = 0; i < len ;i++) {
-- 
1.4.2.1.ga0df5-dirty

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

end of thread, other threads:[~2006-09-20 21:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-20 20:56 [PATCH] sha1_name: accept output of git-describe Johannes Schindelin
2006-09-20 21:25 ` Junio C Hamano
2006-09-20 21:31   ` Johannes Schindelin
2006-09-20 21:34   ` Shawn Pearce

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).