Skip to content

Commit 7593e09

Browse files
fbuihuumichal42
authored andcommitted
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. Signed-off-by: Franck Bui-Huu <[email protected]> Signed-off-by: Michal Marek <[email protected]>
1 parent 6ce4eac commit 7593e09

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

scripts/setlocalversion

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ scm_version()
4343
fi
4444

4545
# Check for git and a git repo.
46-
if test -d .git && head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
46+
if test -z "$(git rev-parse --show-cdup 2>/dev/null)" &&
47+
head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
4748

4849
# If we are at a tagged commit (like "v2.6.30-rc6"), we ignore
4950
# it, because this version is defined in the top level Makefile.

0 commit comments

Comments
 (0)