git/list[1] front-page[2] threads[3] people[4] search[5] about
 

RE: [PATCH] git-submodule: Instead of using only annotated tags, use any tag found in .git/refs/tags

From
MEMedve Emilian-EMMEDVE1 <emilian.medve@freescale.com>
Date
Jun 27, 2007, 12:20 UTC
Message-ID
<598D5675D34BE349929AF5EDE9B03E27011CFD8F@az33exm24.fsl.freescale.net>
In-Reply-To
<7vabulrki3.fsf@assigned-by-dhcp.pobox.com>
Hello Junio,

You're right and there might be no tag at all, thus --contains might return an undefined. In the spirit of best effort maybe we should try --all (which I don't think that can fail and it will return something more relevant then undefined, i.e. the branch of the commit) if --contains returns undefined. I'll submit a patch to reflect this. Opinions?

While playing with git-describe I noticed that the --all option is maybe not trying first to find a tag as the man page suggests but it goes directly for .git/refs. Here is some output from my git repo clone with yesterday's head on the master branch:

$ git-describe aeb59328453cd4f438345ea79ff04c96bccbbbb8 v1.5.2.2-549-gaeb5932

$ git-describe --all aeb59328453cd4f438345ea79ff04c96bccbbbb8 heads/master

Do you think we want to fix that? If yes, I could look into it and submit a patch.

Cheers, Emil.

This e-mail, and any associated attachments have been classified as: -------------------------------------------------------------------- [x] Public [ ] Freescale Semiconductor Internal Use Only [ ] Freescale Semiconductor Confidential Proprietary

-----Original Message-----
From: Junio C Hamano [mailto:gitster@pobox.com] 
Sent: Wednesday, June 27, 2007 1:15 AM
To: Medve Emilian-EMMEDVE1
Cc: git@vger.kernel.org
Subject: Re: [PATCH] git-submodule: Instead of using only annotated
tags, use any tag found in .git/refs/tags
Emil Medve <Emilian.Medve@Freescale.com> writes:
Show 6 quoted lines
> Some repositories might not use/have annotated tags (for
> example repositories created with git-cvsimport) and
> git-submodule status might fail because git-describe might
> fail to find a tag.  This change allows the status of a
> submodule to be described/displayed relative to lightweight
> tags as well.

Certainly that is an improvement, as $revname is purely for commenting and not being able to describe it is not an excuse to fail the command.

But there may not be any tag at all. How about something like this on top?

diff --git a/git-submodule.sh b/git-submodule.sh
index 56ea935..7b6195b 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -133,6 +133,18 @@ modules_update()
 	done
 }
 
+set_name_rev () {
+	revname=$( (
+		unset GIT_DIR &&
+		cd "$1" && {
+			git-describe "$2" 2>/dev/null ||
+			git-describe --tags "$2" 2>/dev/null ||
+			git-describe --contains --tags "$2"
+		}
+	) )
+	test -z "$revname" || revname=" ($revname)"
+}
+
 #
 # List all submodules, prefixed with:
 #  - submodule not initialized
@@ -156,16 +168,17 @@ modules_list()
 			continue;
 		fi
 		revname=$(unset GIT_DIR && cd "$path" && git-describe
--tags $sha1)
+		set_name_rev "$path" $"sha1"
 		if git diff-files --quiet -- "$path"
 		then
-			say " $sha1 $path ($revname)"
+			say " $sha1 $path$revname"
 		else
 			if test -z "$cached"
 			then
 				sha1=$(unset GIT_DIR && cd "$path" &&
git-rev-parse --verify HEAD)
-				revname=$(unset GIT_DIR && cd "$path" &&
git-describe --tags $sha1)
+				set_name_rev "$path" $"sha1"
 			fi
-			say "+$sha1 $path ($revname)"
+			say "+$sha1 $path$revname"
 		fi
 	done
 }
Previous: Junio C HamanoNext: Shawn O. Pearce
Message 3 of 4 in “git-submodule: Instead of using only annotated tags, use any tag found in .git/refs/tags”
  1. git-submodule: Instead of using only annotated tags, use any tag found in .git/refs/tagsEmil Medve, Jun 26, 2007
  2. Junio C HamanoJun 27, 2007
  3. Medve Emilian-EMMEDVE1Jun 27, 2007
  4. Shawn O. PearceJun 28, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.