Skip to contentSkip to conversation

GIT-VERSION-GEN: restrict tags used

RFC PATCH In review Tay Ray Chuan 3 participants 6 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 GIT-VERSION-GEN: restrict tags used

Restrict the tags used to generate the version string to those that begin with "v", since git's tags for git-core (ie. excluding git-gui) are all of the form "vX.Y...".

This is to avoid using private tags by the user in a clone of the git code repository, which may break certain machinery (eg. Makefile).

---

Ran into this after tagging a topic branch and running make.

Although a "v.*" match does not guarantee the non-usage of private tags, I feel it's an acceptable level of accuracy.

After this patch, perhaps we could advertise somewhere to git hackers that tags beginning with "v" should be avoided.

 GIT-VERSION-GEN |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
GIT-VERSION-GEN +1 -1
index 59219bd..28b4d56 100755
@@ -12,7 +12,7 @@ if test -f version
 then
 	VN=$(cat version) || VN="$DEF_VER"
 elif test -d .git -o -f .git &&
-	VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
+	VN=$(git describe --match "v*" --abbrev=4 HEAD 2>/dev/null) &&
 	case "$VN" in
 	*$LF*) (exit 1) ;;
 	v[0-9]*)

--
1.7.1.189.g07419

#1 lore raw
Quoted 2 lines · Tay Ray Chuan

Restrict the tags used to generate the version string to those that begin with "v"

I like it. Thanks!

Quoted 2 lines

since git's tags for git-core (ie. excluding git-gui) are all of the form "vX.Y...".

git gui’s too, now.

Quoted 2 lines

This is to avoid using private tags by the user in a clone of the git code repository, which may break certain machinery (eg. Makefile).

Not to mention gitk:

  set git_version [join [lrange [split [lindex [exec git version] end] .] 0 2] .]
  if {[package vcompare $git_version "1.6.1"] >= 0} {

This requires ‘git version’ output to have the form

introducing 1.2.3.otherstuff

or there will be errors at startup time.

Quoted 2 lines

After this patch, perhaps we could advertise somewhere to git hackers that tags beginning with "v" should be avoided.

Maybe v[0-9]* would make this problem harder to trip.

Jonathan

#2 lore raw
Quoted 6 lines · Jonathan Nieder
Quoted 2 lines · Tay Ray Chuan

since git's tags for git-core (ie. excluding git-gui) are all of the form "vX.Y...".

git gui’s too, now.

Aggh --- sent early, there. Here is what I meant to say.

Shawn, this helps avoid any stray (annotated) tags the user may have made, following Tay’s example.

---

GIT-VERSION-GEN +1 -1
index b3f937e..d6a6601 100755
@@ -13,7 +13,7 @@ tree_search ()
 	for p in $(git rev-list --parents --max-count=1 $head 2>/dev/null)
 	do
 		test $tree = $(git rev-parse $p^{tree} 2>/dev/null) &&
-		vn=$(git describe --abbrev=4 $p 2>/dev/null) &&
+		vn=$(git describe --match=gitgui-[0-9]* --abbrev=4 $p 2>/dev/null) &&
 		case "$vn" in
 		gitgui-[0-9]*) echo $vn; break;;
 		esac
#3 lore raw
In reply to Jonathan Nieder
Quoted 6 lines · Jonathan Nieder
Quoted 2 lines · Tay Ray Chuan

This is to avoid using private tags by the user in a clone of the git code repository, which may break certain machinery (eg. Makefile).

Not to mention gitk:

Quoted 8 lines

 set git_version [join [lrange [split [lindex [exec git version] end] .] 0 2] .] if {[package vcompare $git_version "1.6.1"] >= 0} {

This requires ‘git version’ output to have the form

 introducing 1.2.3.otherstuff

or there will be errors at startup time.

Thanks for the heads-up, I'll put that in the patch message.

Quoted 4 lines
Quoted 2 lines

  After this patch, perhaps we could advertise somewhere to git hackers that tags beginning with "v" should be avoided.

Maybe v[0-9]* would make this problem harder to trip.

Oh, I didn't know character classes were allows. Sounds good.

Signature · 2 lines
Cheers,
Ray Chuan
#4 lore raw

PATCH 1/1 GIT-VERSION-GEN: restrict tags used

Restrict the tags used to generate the version string to those that begin with "v", since git's tags for git-core (ie. excluding git-gui) are all of the form "vX.Y...".

This is to avoid using private tags by the user in a clone of the git code repository, which may break certain machinery (eg. Makefile, gitk).

---

Changes from RFC:

- used "v[0-9]*" instead of just "v*"
- mentioned gitk as another piece that may break

 GIT-VERSION-GEN |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
GIT-VERSION-GEN +1 -1
index 59219bd..e45513d 100755
@@ -12,7 +12,7 @@ if test -f version
 then
 	VN=$(cat version) || VN="$DEF_VER"
 elif test -d .git -o -f .git &&
-	VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
+	VN=$(git describe --match "v[0-9]*" --abbrev=4 HEAD 2>/dev/null) &&
 	case "$VN" in
 	*$LF*) (exit 1) ;;
 	v[0-9]*)

--
1.7.1.189.g07419