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

[PATCH v2 02/15] version-gen: trivial cleanup

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Apr 24, 2023, 16:50 UTC
Message-ID
<20230424165041.25180-3-felipe.contreras@gmail.com>
In-Reply-To
<20230424165041.25180-1-felipe.contreras@gmail.com>
We don't use `git-foo` since git 1.6.
HEAD is the default of `git describe`.
Also, deal with a bunch of shellcheck warnings.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 GIT-VERSION-GEN | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 29d634a30b..6dd7683ee7 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -7,7 +7,7 @@ LF='
 '
 
 describe () {
-	VN=$(git describe --match "v[0-9]*" HEAD 2>/dev/null) || return 1
+	VN=$(git describe --match "v[0-9]*" 2>/dev/null) || return 1
 	case "$VN" in
 	*$LF*)
 		return 1
@@ -22,26 +22,24 @@ describe () {
 }
 
 # First see if there is a version file (included in release tarballs),
-# then try git-describe, then default.
+# then try `git describe`, then default.
 if test -f version
 then
 	VN=$(cat version) || VN="$DEF_VER"
-elif test -d ${GIT_DIR:-.git} -o -f .git && describe
+elif test -d "${GIT_DIR:-.git}" -o -f .git && describe
 then
-	VN=$(echo "$VN" | sed -e 's/-/./g');
+	VN=$(echo "$VN" | sed -e 's/-/./g')
 else
 	VN="$DEF_VER"
 fi
 
-VN=$(expr "$VN" : v*'\(.*\)')
+VN=$(expr "$VN" : 'v*\(.*\)')
 
 if test -r $GVF
 then
 	VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
 else
-	VC=unset
+	VC='unset'
 fi
-test "$VN" = "$VC" || {
-	echo >&2 "GIT_VERSION = $VN"
-	echo "GIT_VERSION = $VN" >$GVF
-}
+test "$VN" = "$VC" && exit
+echo "GIT_VERSION = $VN" | tee $GVF >&2
-- 
2.40.0+fc1
Previous: Felipe ContrerasNext: Felipe Contreras
Message 5 of 16 in “version-gen: complete revamp/rewrite”
  1. 00/15 version-gen: complete revamp/rewriteFelipe Contreras, Apr 24, 2023
  2. 04/15 version-gen: simplify v prefix removalFelipe Contreras, Apr 24, 2023
  3. 01/15 version-gen: reorganizeFelipe Contreras, Apr 24, 2023
  4. 03/15 version-gen: refactor default versionFelipe Contreras, Apr 24, 2023
  5. 02/15 version-gen: trivial cleanupFelipe Contreras, Apr 24, 2023
  6. 05/15 version-gen: simplify update checkFelipe Contreras, Apr 24, 2023
  7. 06/15 version-gen: simplify `git describe` checksFelipe Contreras, Apr 24, 2023
  8. 07/15 version-gen: simplify dirty checkFelipe Contreras, Apr 24, 2023
  9. 08/15 version-gen: move describe fix into functionFelipe Contreras, Apr 24, 2023
  10. 09/15 version-gen: describe and sed in one goFelipe Contreras, Apr 24, 2023
  11. 10/15 version-gen: refactor describe functionFelipe Contreras, Apr 24, 2023
  12. 11/15 version-gen: do v fix only when necessaryFelipe Contreras, Apr 24, 2023
  13. 12/15 version-gen: move v fix into sedFelipe Contreras, Apr 24, 2023
  14. 13/15 version-gen: refactor main functionalityFelipe Contreras, Apr 24, 2023
  15. 14/15 version-gen: refactor GIT_VERSION stringFelipe Contreras, Apr 24, 2023
  16. 15/15 version-gen: get rid of GVF variableFelipe Contreras, Apr 24, 2023

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.