All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/18] version-gen: complete revamp/rewrite
@ 2023-04-14 12:18 Felipe Contreras
  2023-04-14 12:18 ` [PATCH 01/18] version-gen: reorganize Felipe Contreras
                   ` (17 more replies)
  0 siblings, 18 replies; 24+ messages in thread
From: Felipe Contreras @ 2023-04-14 12:18 UTC (permalink / raw)
  To: git; +Cc: Jeff King, Junio C Hamano, Felipe Contreras

The version generation script needs some love, as the last true change was done in 2008.

This series step by step revamps the whole script ending in only a few lines of code:

    get_version () {
        test -f version && cat version && return
        git describe --match "v[0-9]*" --dirty 2>/dev/null | sed -e 's/-/+/' -e 's/^v//'
    }

    NEW="GIT_VERSION = $(get_version)"

    test -r GIT-VERSION-FILE && test "$NEW" = "$(cat GIT-VERSION-FILE)" && exit
    echo "$NEW" | tee GIT-VERSION-FILE >&2

There should be no functional changes except for the last patch that changes
interim version from `2.40.0.$n.g${oid}` to `2.40.0+$n-g${oid}` as that causes
the proper sorting.

It's hard to see the actual changes to this script as 99% of the commits are
just to bump the default version (which I don't know why it even exists).

For reference, cleaning the history I came up with these actual changes in case
anyone is interested:

c48799e560 (Teach GIT-VERSION-GEN about the .git file, 2008-02-20)
1100ac81a9 (Change GIT-VERSION-GEN to call git commands with "git" not "git-"., 2006-05-22)
374dfaa2e3 (Make GIT-VERSION-GEN tolerate missing git describe command again, 2006-01-26)
5c7d3c9507 (Allow building of RPM from interim snapshot., 2006-01-16)
181129d24c (For release tarballs, include the proper version, 2006-01-09)
026351a035 (Make GIT-VERSION-GEN tolerate missing git describe command, 2005-12-30)
9b88fcef7d (Makefile: use git-describe to mark the git version., 2005-12-27)

Cheers.

diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 9a1111af9b..99584bf86d 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -1,40 +1,11 @@
 #!/bin/sh
 
-GVF=GIT-VERSION-FILE
-DEF_VER=v2.40.GIT
-
-LF='
-'
-
-# First see if there is a version file (included in release tarballs),
-# 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 &&
-	VN=$(git describe --match "v[0-9]*" HEAD 2>/dev/null) &&
-	case "$VN" in
-	*$LF*) (exit 1) ;;
-	v[0-9]*)
-		git update-index -q --refresh
-		test -z "$(git diff-index --name-only HEAD --)" ||
-		VN="$VN-dirty" ;;
-	esac
-then
-	VN=$(echo "$VN" | sed -e 's/-/./g');
-else
-	VN="$DEF_VER"
-fi
-
-VN=$(expr "$VN" : v*'\(.*\)')
-
-if test -r $GVF
-then
-	VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
-else
-	VC=unset
-fi
-test "$VN" = "$VC" || {
-	echo >&2 "GIT_VERSION = $VN"
-	echo "GIT_VERSION = $VN" >$GVF
+get_version () {
+	test -f version && cat version && return
+	git describe --match "v[0-9]*" --dirty 2>/dev/null | sed -e 's/-/+/' -e 's/^v//'
 }
+
+NEW="GIT_VERSION = $(get_version)"
+
+test -r GIT-VERSION-FILE && test "$NEW" = "$(cat GIT-VERSION-FILE)" && exit
+echo "$NEW" | tee GIT-VERSION-FILE >&2

Felipe Contreras (18):
  version-gen: reorganize
  version-gen: trivial cleanup
  version-gen: refactor default version
  version-gen: simplify v prefix removal
  version-gen: simplify update check
  version-gen: remove redundant check
  version-gen: simplify `git describe` checks
  version-gen: simplify dirty check
  version-gen: move describe fix into function
  version-gen: describe and sed in one go
  version-gen: refactor describe function
  version-gen: do v fix only when necessary
  version-gen: move v fix into sed
  version-gen: refactor main functionality
  version-gen: remove default version
  version-gen: refactor GIT_VERSION string
  version-gen: get rid of GVF variable
  version-gen: generate proper interim versions

 GIT-VERSION-GEN | 45 ++++++++-------------------------------------
 1 file changed, 8 insertions(+), 37 deletions(-)

-- 
2.40.0+fc1


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

end of thread, other threads:[~2023-04-14 19:42 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 02/18] version-gen: trivial cleanup Felipe Contreras
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.