git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: git@vger.kernel.org
Cc: Jeff King <peff@peff.net>, Junio C Hamano <gitster@pobox.com>,
	Felipe Contreras <felipe.contreras@gmail.com>
Subject: [PATCH 02/18] version-gen: trivial cleanup
Date: Fri, 14 Apr 2023 06:18:25 -0600	[thread overview]
Message-ID: <20230414121841.373980-3-felipe.contreras@gmail.com> (raw)
In-Reply-To: <20230414121841.373980-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


  parent reply	other threads:[~2023-04-14 12:19 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-14 12:18 [PATCH 00/18] version-gen: complete revamp/rewrite Felipe Contreras
2023-04-14 12:18 ` [PATCH 01/18] version-gen: reorganize Felipe Contreras
2023-04-14 12:18 ` Felipe Contreras [this message]
2023-04-14 12:18 ` [PATCH 03/18] version-gen: refactor default version Felipe Contreras
2023-04-14 12:18 ` [PATCH 04/18] version-gen: simplify v prefix removal Felipe Contreras
2023-04-14 12:18 ` [PATCH 05/18] version-gen: simplify update check Felipe Contreras
2023-04-14 12:18 ` [PATCH 06/18] version-gen: remove redundant check Felipe Contreras
2023-04-14 15:11   ` Todd Zullinger
2023-04-14 17:47     ` Felipe Contreras
2023-04-14 19:01       ` Todd Zullinger
2023-04-14 19:32         ` Felipe Contreras
2023-04-14 19:41           ` Todd Zullinger
2023-04-14 12:18 ` [PATCH 07/18] version-gen: simplify `git describe` checks Felipe Contreras
2023-04-14 12:18 ` [PATCH 08/18] version-gen: simplify dirty check Felipe Contreras
2023-04-14 12:18 ` [PATCH 09/18] version-gen: move describe fix into function Felipe Contreras
2023-04-14 12:18 ` [PATCH 10/18] version-gen: describe and sed in one go Felipe Contreras
2023-04-14 12:18 ` [PATCH 11/18] version-gen: refactor describe function Felipe Contreras
2023-04-14 12:18 ` [PATCH 12/18] version-gen: do v fix only when necessary Felipe Contreras
2023-04-14 12:18 ` [PATCH 13/18] version-gen: move v fix into sed Felipe Contreras
2023-04-14 12:18 ` [PATCH 14/18] version-gen: refactor main functionality Felipe Contreras
2023-04-14 12:18 ` [PATCH 15/18] version-gen: remove default version Felipe Contreras
2023-04-14 12:18 ` [PATCH 16/18] version-gen: refactor GIT_VERSION string Felipe Contreras
2023-04-14 12:18 ` [PATCH 17/18] version-gen: get rid of GVF variable Felipe Contreras
2023-04-14 12:18 ` [PATCH 18/18] version-gen: generate proper interim versions Felipe Contreras

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230414121841.373980-3-felipe.contreras@gmail.com \
    --to=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).