Skip to contentSkip to conversation

setlocalversion: fix error detectition of kernel git repository

PATCH In review xufeng 2 participants 3 messages Jan 20, 2017 – Jan 22, 2017 Kbuild

lore
Share & tools
lore

xufeng

author
#0 lore raw

PATCH 1/1 setlocalversion: fix error detectition of kernel git repository

This patch fixed the error using 'git rev-parse --show-cdup' to check that git is used as SCM to track the current directory. The return value of this command is not null string when the .git directory is not in kernel topdir.

---
 scripts/setlocalversion | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/setlocalversion +0 -0
index 966dd39..7966e39 100755
@@ -43,7 +43,7 @@ scm_version()

     fi

     # Check for git and a git repo.
-    if test -z "$(git rev-parse --show-cdup 2>/dev/null)" && +    if test -z "$(git rev-parse --show-cdup &>/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 --
2.9.3

#1 lore raw

Hello Xufeng,

why do you think redirecting *all* output to /dev/null is the right thing todo?

And which problem does it exactly fix?

Do you see that there is a difference between a "return value" (i.e. exit code) and the output (in this case stdout) of a program?

Best,

Nico

Quoted 22 lines · xufeng

This patch fixed the error using 'git rev-parse --show-cdup' to check that git is used as SCM to track the current directory. The return value of this command is not null string when the .git directory is not in kernel topdir.

---
scripts/setlocalversion | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
scripts/setlocalversion +0 -0
index 966dd39..7966e39 100755
@@ -43,7 +43,7 @@ scm_version()

fi

# Check for git and a git repo.

scripts/setlocalversion +1 -1
-if test -z "$(git rev-parse --show-cdup 2>/dev/null)" &&
+if test -z "$(git rev-parse --show-cdup &>/dev/null)" &&

head=git rev-parse --verify --short HEAD 2>/dev/null; then

Quoted 1 line

# If we are at a tagged commit (like "v2.6.30-rc6"), we ignore

--
Werde Teil des modernen Arbeitens im Glarnerland auf www.digitalglarus.ch!

Lese Neuigkeiten auf Twitter: www.twitter.com/DigitalGlarus
Diskutiere mit auf Facebook:  www.facebook.com/digitalglarus
author
#2 lore raw

I'm sorry. My patch is error.
But I just want to get the git version when we use git as SCM. No matter what .git directory where. Thanks.

Quoted 46 lines · Nico Schottelius

Hello Xufeng,

why do you think redirecting *all* output to /dev/null is the right thing todo?

And which problem does it exactly fix?

Do you see that there is a difference between a "return value" (i.e. exit code) and the output (in this case stdout) of a program?

Best,

Nico

Quoted 22 lines · xufeng

This patch fixed the error using 'git rev-parse --show-cdup' to check that git is used as SCM to track the current directory. The return value of this command is not null string when the .git directory is not in kernel topdir.

---
scripts/setlocalversion | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
scripts/setlocalversion +0 -0
index 966dd39..7966e39 100755
@@ -43,7 +43,7 @@ scm_version()

fi

# Check for git and a git repo.

scripts/setlocalversion +1 -1
-if test -z "$(git rev-parse --show-cdup 2>/dev/null)" &&
+if test -z "$(git rev-parse --show-cdup &>/dev/null)" &&

head=git rev-parse --verify --short HEAD 2>/dev/null; then

Quoted 1 line

# If we are at a tagged commit (like "v2.6.30-rc6"), we ignore

--
Werde Teil des modernen Arbeitens im Glarnerland auf www.digitalglarus.ch!

Lese Neuigkeiten auf Twitter: www.twitter.com/DigitalGlarus
Diskutiere mit auf Facebook:  www.facebook.com/digitalglarus