Skip to contentSkip to conversation

GIT-VERSION-GEN: support non-standard $GIT_DIR path

PATCH In review Dennis Kaarsemaker 2 participants 5 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 GIT-VERSION-GEN: support non-standard $GIT_DIR path

make and make test both work when $GIT_DIR isn't .git, but make dist included a bogus GIT-VERSION-FILE.

---
I'm doing daily builds of git, using many workers and a shared git.git, with per-worker checkouts, it would be really useful if GIT-VERSION-GEN actually supports this and doesn't generate a fairly bogus GIT-VERSION-FILE.

 GIT-VERSION-GEN | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
GIT-VERSION-GEN +1 -1
index 390782f..7dcca28 100755
@@ -11,7 +11,7 @@ LF='
 if test -f version
 then
 	VN=$(cat version) || VN="$DEF_VER"
-elif test -d .git -o -f .git &&
+elif test -d .git -o -f .git -o test -d $GIT_DIR &&
 	VN=$(git describe --match "v[0-9]*" --abbrev=7 HEAD 2>/dev/null) &&
 	case "$VN" in
 	*$LF*) (exit 1) ;;
Signature · 1 line
1.8.2.4.g940421e
#1 lore raw
Quoted 2 lines · Dennis Kaarsemaker

I'm doing daily builds of git, using many workers and a shared git.git, with per-worker checkouts

OK, so GIT_DIR is explicitly specified in these "workers".

Makes sense.

#2 lore raw
Quoted 8 lines · Junio C Hamano
Quoted 2 lines · Dennis Kaarsemaker

I'm doing daily builds of git, using many workers and a shared git.git, with per-worker checkouts

OK, so GIT_DIR is explicitly specified in these "workers".

Makes sense.

Actually it does not. What if GIT_DIR is an empty string or not set at all? The patch breaks the build for everybody else, doesn't it?

Perhaps like this instead?

 GIT-VERSION-GEN | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
GIT-VERSION-GEN +1 -1
index 2908204..91ec831 100755
@@ -11,7 +11,7 @@ LF='
 if test -f version
 then
 	VN=$(cat version) || VN="$DEF_VER"
-elif test -d .git -o -f .git &&
+elif test -d ${GIT_DIR:-.git} -o -f .git &&
 	VN=$(git describe --match "v[0-9]*" --abbrev=7 HEAD 2>/dev/null) &&
 	case "$VN" in
 	*$LF*) (exit 1) ;;
#3 lore raw
Quoted 8 lines · Junio C Hamano
Quoted 6 lines · Junio C Hamano
Quoted 2 lines · Dennis Kaarsemaker

I'm doing daily builds of git, using many workers and a shared git.git, with per-worker checkouts

OK, so GIT_DIR is explicitly specified in these "workers".

Yes, both GIT_DIR and GIT_WORK_TREE are set and the use of .git/HEAD and anything relying on it is shunned, so workers can run checkout as they please.

Quoted 4 lines
Quoted 1 line

Makes sense.

Actually it does not. What if GIT_DIR is an empty string or not set at all? The patch breaks the build for everybody else, doesn't it?

It does indeed, I only tested in my setup and not with a normal make test. Apologies.

Quoted 10 lines

Perhaps like this instead?

 GIT-VERSION-GEN | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
GIT-VERSION-GEN +0 -0
index 2908204..91ec831 100755

GIT-VERSION-GEN LF=' · line 17

Quoted 8 lines
GIT-VERSION-GEN +1 -1
@@ -11,7 +11,7 @@ LF='
 if test -f version
 then
 	VN=$(cat version) || VN="$DEF_VER"
-elif test -d .git -o -f .git &&
+elif test -d ${GIT_DIR:-.git} -o -f .git &&
 	VN=$(git describe --match "v[0-9]*" --abbrev=7 HEAD 2>/dev/null) &&
 	case "$VN" in
 	*$LF*) (exit 1) ;;

Yes, that makes a lot more sense and actually works in normal make test and with a detached .git. Do you want me to send an updated patch?

Signature · 2 lines
Dennis Kaarsemaker
www.kaarsemaker.net
#4 lore raw
Quoted 27 lines · Dennis Kaarsemaker
Quoted 8 lines · Junio C Hamano
Quoted 6 lines · Junio C Hamano
Quoted 2 lines · Dennis Kaarsemaker

I'm doing daily builds of git, using many workers and a shared git.git, with per-worker checkouts

OK, so GIT_DIR is explicitly specified in these "workers".

Yes, both GIT_DIR and GIT_WORK_TREE are set and the use of .git/HEAD and anything relying on it is shunned, so workers can run checkout as they please.

Quoted 4 lines
Quoted 1 line

Makes sense.

Actually it does not. What if GIT_DIR is an empty string or not set at all? The patch breaks the build for everybody else, doesn't it?

It does indeed, I only tested in my setup and not with a normal make test. Apologies.

Quoted 5 lines

Perhaps like this instead?

 GIT-VERSION-GEN | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines

GIT-VERSION-GEN LF=' · line 17

Quoted 13 lines
GIT-VERSION-GEN +1 -1
index 2908204..91ec831 100755
@@ -11,7 +11,7 @@ LF='
 if test -f version
 then
 	VN=$(cat version) || VN="$DEF_VER"
-elif test -d .git -o -f .git &&
+elif test -d ${GIT_DIR:-.git} -o -f .git &&
 	VN=$(git describe --match "v[0-9]*" --abbrev=7 HEAD 2>/dev/null) &&
 	case "$VN" in
 	*$LF*) (exit 1) ;;

Yes, that makes a lot more sense and actually works in normal make test and with a detached .git. Do you want me to send an updated patch?

I think I've locally amended it already before queueing it to 'pu', so no need to resend.

Thanks.