Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version.sh dont get version from git #25

Closed
sl1pkn07 opened this issue Feb 6, 2013 · 6 comments
Closed

version.sh dont get version from git #25

sl1pkn07 opened this issue Feb 6, 2013 · 6 comments

Comments

@sl1pkn07
Copy link

sl1pkn07 commented Feb 6, 2013

need remove "!" in line 10

┌─┤[sl1pkn07]|[sL1pKn07]|[~/aplicaciones/mpv-build-git/src/mpv-build/mpv]|
└───╼  git_revision= ; test $git_revision || test ! -d .git || git_revision=`git rev-parse --short HEAD` ; echo $git_revision

┌─┤[sl1pkn07]|[sL1pKn07]|[~/aplicaciones/mpv-build-git/src/mpv-build/mpv]|
└───╼  git_revision=esee ; test $git_revision || test ! -d .git || git_revision=`git rev-parse --short HEAD` ; echo $git_revision
esee
┌─┤[sl1pkn07]|[sL1pKn07]|[~/aplicaciones/mpv-build-git/src/mpv-build/mpv]|
└───╼  git_revision= ; test $git_revision || test -d .git || git_revision=`git rev-parse --short HEAD` ; echo $git_revision
4a2e4b6
┌─┤[sl1pkn07]|[sL1pKn07]|[~/aplicaciones/mpv-build-git/src/mpv-build/mpv]|
└───╼  git_revision=esee ; test $git_revision || test -d .git || git_revision=`git rev-parse --short HEAD` ; echo $git_revision
esee

PD: yes, my bash is flaman XD

greetings

@ghost
Copy link

ghost commented Feb 6, 2013

Sorry, I can't reproduce your output, nor can I tell what your problem is.

The current version.sh seems to work fine for me with bash and dash on Linux. When I remove the "!" it stops working (prints an empty revision).

@sl1pkn07
Copy link
Author

sl1pkn07 commented Feb 6, 2013

bash --help
GNU bash, versión 4.2.42(2)-release-(x86_64-unknown-linux-gnu)

┌─┤[sl1pkn07]|[sL1pKn07]|[~/aplicaciones/mpv-build-git/src/mpv-build/mpv]|
└───╼  sh version.sh 
┌─┤[sl1pkn07]|[sL1pKn07]|[~/aplicaciones/mpv-build-git/src/mpv-build/mpv]|
└───╼  cat version.h
#define VERSION "git-UNKNOWN"
#define BUILDDATE "Wed Feb  6 15:29:53 CET 2013"
┌─┤[sl1pkn07]|[sL1pKn07]|[~/aplicaciones/mpv-build-git/src/mpv-build/mpv]|
└───╼  sed 's|! ||g' -i version.sh
┌─┤[sl1pkn07]|[sL1pKn07]|[~/aplicaciones/mpv-build-git/src/mpv-build/mpv]|
└───╼  sh version.sh 
┌─┤[sl1pkn07]|[sL1pKn07]|[~/aplicaciones/mpv-build-git/src/mpv-build/mpv]|
└───╼  cat version.h
#define VERSION "git-4a2e4b6"
#define BUILDDATE "Wed Feb  6 15:30:24 CET 2013"
┌─┤[sl1pkn07]|[sL1pKn07]|[~/aplicaciones/mpv-build-git/src/mpv-build/mpv]|
└───╼ 

bash trace http://paste.ubuntu.com/1616791

archlinux 64bits

@ghost
Copy link

ghost commented Feb 6, 2013

I think I get it now. "test ! -d .git" checks whether there's a directory named .git - however, when making a new checkout of mpv-build.git, the mpv sub directory has a regular file named .git, not a directory. This seems to be a recent change in how git manages sub modules.

Anyway, changing it to "test ! -e .git" should fix it. Removing "!" is not the correct solution. Please test whether this works:

diff --git a/version.sh b/version.sh
index a907dd2..90a08ac 100755
--- a/version.sh
+++ b/version.sh
@@ -7,7 +7,7 @@ test "$1" && extra="-$1"
 # Extract revision number from file used by daily tarball snapshots
 # or from "git describe" output
 git_revision=$(cat snapshot_version 2> /dev/null)
-test $git_revision || test ! -d .git || git_revision=`git rev-parse --short HEAD`
+test $git_revision || test ! -e .git || git_revision=`git rev-parse --short HEAD`
 git_revision=$(expr "$git_revision" : v*'\(.*\)')
 test $git_revision || git_revision=UNKNOWN

@divVerent
Copy link
Member

Yes, that explains it all. Apply.

Am 06.02.2013 um 16:45 schrieb wm4 notifications@github.com:

I think I get it now. "test ! -d .git" checks whether there's a directory named .git - however, when making a new checkout of mpv-build.git, the mpv sub directory has a regular file named .git, not a directory. This seems to be a recent change in how git manages sub modules.

Anyway, changing it to "test ! -e .git" should fix it. Removing "!" is not the correct solution. Please test whether this works:

diff --git a/version.sh b/version.sh
index a907dd2..90a08ac 100755
--- a/version.sh
+++ b/version.sh
@@ -7,7 +7,7 @@ test "$1" && extra="-$1"

Extract revision number from file used by daily tarball snapshots

or from "git describe" output

git_revision=$(cat snapshot_version 2> /dev/null)
-test $git_revision || test ! -d .git || git_revision=git rev-parse --short HEAD
+test $git_revision || test ! -e .git || git_revision=git rev-parse --short HEAD
git_revision=$(expr "$git_revision" : v_'(._)')
test $git_revision || git_revision=UNKNOWN


Reply to this email directly or view it on GitHub.

@sl1pkn07
Copy link
Author

sl1pkn07 commented Feb 6, 2013

yes confirm change "-d" to "-e", the script version.sh get version properly

greetings

@ghost
Copy link

ghost commented Feb 6, 2013

Pushed as 314a07e.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants