Fix detectition of kernel git repository in setlocalversion script
PATCH 1/1 Fix detectition of kernel git repository in setlocalversion script
setlocalversion script was testing the presence of .git directory in order to find out if git is used as SCM to track the current kernel project. However in some cases, .git is not a directory but can be a file: when the kernel is a git submodule part of a git super project for example.
This patch just fixes this by using 'git rev-parse --show-cdup' to check that the current directory is the kernel git topdir. This has the advantage to not test and rely on git internal infrastructure directly.
--- scripts/setlocalversion | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/setlocalversion +2 -1
@@ -43,7 +43,8 @@ scm_version() fi # Check for git and a git repo. - if test -d .git && head=`git rev-parse --verify --short HEAD 2>/dev/null`; then + if topdir=$(git rev-parse --show-cdup 2>/dev/null) && test -z "$topdir" && + head=`git rev-parse --verify --short HEAD 2>/dev/null`; then # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore # it, because this version is defined in the top level Makefile.
Signature · 1 line
1.8.4.2
scripts/setlocalversion scm_version() · line 47
Quoted 11 lines · Franck Bui-Huu
scripts/setlocalversion +2
-1@@ -43,7 +43,8 @@ scm_version() fi # Check for git and a git repo. - if test -d .git && head=`git rev-parse --verify --short HEAD 2>/dev/null`; then + if topdir=$(git rev-parse --show-cdup 2>/dev/null) && test -z "$topdir" && + head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
You can do test -z "$(git rev-parse --show-cdup 2>/dev/null)" without the $topdir variable.
Michal
Quoted 8 lines · Michal Marek
Quoted 7 lines · Franck Bui-Huu
scripts/setlocalversion +0
-0@@ -43,7 +43,8 @@ scm_version() fi
Quoted 7 lines
scripts/setlocalversion scm_version() · line 47
Quoted 4 lines
scripts/setlocalversion +2
-1# Check for git and a git repo. - if test -d .git && head=`git rev-parse --verify --short HEAD 2>/dev/null`; then + if topdir=$(git rev-parse --show-cdup 2>/dev/null) && test -z "$topdir" && + head=`git rev-parse --verify --short HEAD 2>/dev/null`; thenYou can do test -z "$(git rev-parse --show-cdup 2>/dev/null)" without the $topdir variable.
No, "$(git rev-parse --show-cdup 2>/dev/null)" would also give the empty string if the git command fails (ie not inside a git repository at all).
Thanks.
Signature · 1 line
Franck
Quoted 17 lines · Franck Bui-Huu
Quoted 8 lines · Michal Marek
Quoted 7 lines · Franck Bui-Huu
scripts/setlocalversion +0
-0@@ -43,7 +43,8 @@ scm_version() fiQuoted 7 lines
scripts/setlocalversion scm_version() · line 47
Quoted 4 lines
scripts/setlocalversion +2
-1# Check for git and a git repo. - if test -d .git && head=`git rev-parse --verify --short HEAD 2>/dev/null`; then + if topdir=$(git rev-parse --show-cdup 2>/dev/null) && test -z "$topdir" && + head=`git rev-parse --verify --short HEAD 2>/dev/null`; thenYou can do test -z "$(git rev-parse --show-cdup 2>/dev/null)" without the $topdir variable.
Quoted 2 lines
No, "$(git rev-parse --show-cdup 2>/dev/null)" would also give the empty string if the git command fails (ie not inside a git repository at all).
Then git rev-parse will also fail.
Michal
Quoted 18 lines · Michal Marek
Quoted 17 lines · Franck Bui-Huu
Quoted 15 lines · Michal Marek
scripts/setlocalversion scm_version() · line 47
Quoted 11 lines · Franck Bui-Huu
scripts/setlocalversion +2
-1@@ -43,7 +43,8 @@ scm_version() fi # Check for git and a git repo. - if test -d .git && head=`git rev-parse --verify --short HEAD 2>/dev/null`; then + if topdir=$(git rev-parse --show-cdup 2>/dev/null) && test -z "$topdir" && + head=`git rev-parse --verify --short HEAD 2>/dev/null`; thenYou can do test -z "$(git rev-parse --show-cdup 2>/dev/null)" without the $topdir variable.
Quoted 4 lines
Quoted 2 lines
No, "$(git rev-parse --show-cdup 2>/dev/null)" would also give the empty string if the git command fails (ie not inside a git repository at all).
Then git rev-parse will also fail.
Fair enough ;)
I'm resending a new patch.
Thanks.
Signature · 1 line
Franck
PATCH 1/1 Fix detectition of kernel git repository in setlocalversion script [take #2]
setlocalversion script was testing the presence of .git directory in order to find out if git is used as SCM to track the current kernel project. However in some cases, .git is not a directory but can be a file: when the kernel is a git submodule part of a git super project for example.
This patch just fixes this by using 'git rev-parse --show-cdup' to check that the current directory is the kernel git topdir. This has the advantage to not test and rely on git internal infrastructure directly.
--- scripts/setlocalversion | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/setlocalversion +2 -1
@@ -43,7 +43,8 @@ scm_version() fi # Check for git and a git repo. - if test -d .git && head=`git rev-parse --verify --short HEAD 2>/dev/null`; then + if test -z "$(git rev-parse --show-cdup 2>/dev/null)" && + head=`git rev-parse --verify --short HEAD 2>/dev/null`; then # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore # it, because this version is defined in the top level Makefile.
Signature · 1 line
1.8.4.2
Re: [PATCH] Fix detectition of kernel git repository in setlocalversion script [take #2]
Quoted 5 lines · Franck Bui-Huu
setlocalversion script was testing the presence of .git directory in order to find out if git is used as SCM to track the current kernel project. However in some cases, .git is not a directory but can be a file: when the kernel is a git submodule part of a git super project for example.
Quoted 8 lines
This patch just fixes this by using 'git rev-parse --show-cdup' to check that the current directory is the kernel git topdir. This has the advantage to not test and rely on git internal infrastructure directly.
Signed-off-by Franck Bui-Huu <[email protected]>--- scripts/setlocalversion | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Applied to kbuild.git#kbuild.
Michal