* [PATCH] Fix detectition of kernel git repository in setlocalversion script
@ 2013-12-02 13:21 Franck Bui-Huu
2013-12-02 14:57 ` Michal Marek
0 siblings, 1 reply; 7+ messages in thread
From: Franck Bui-Huu @ 2013-12-02 13:21 UTC (permalink / raw)
To: mmarek; +Cc: linux-kernel
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 <fbuihuu@gmail.com>
---
scripts/setlocalversion | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 0b5ccf3..c16e65d 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -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.
--
1.8.4.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix detectition of kernel git repository in setlocalversion script
2013-12-02 13:21 [PATCH] Fix detectition of kernel git repository in setlocalversion script Franck Bui-Huu
@ 2013-12-02 14:57 ` Michal Marek
2013-12-02 15:14 ` Franck Bui-Huu
0 siblings, 1 reply; 7+ messages in thread
From: Michal Marek @ 2013-12-02 14:57 UTC (permalink / raw)
To: Franck Bui-Huu; +Cc: linux-kernel
On 2.12.2013 14:21, Franck Bui-Huu wrote:
> diff --git a/scripts/setlocalversion b/scripts/setlocalversion
> index 0b5ccf3..c16e65d 100755
> --- a/scripts/setlocalversion
> +++ b/scripts/setlocalversion
> @@ -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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix detectition of kernel git repository in setlocalversion script
2013-12-02 14:57 ` Michal Marek
@ 2013-12-02 15:14 ` Franck Bui-Huu
2013-12-02 15:16 ` Michal Marek
0 siblings, 1 reply; 7+ messages in thread
From: Franck Bui-Huu @ 2013-12-02 15:14 UTC (permalink / raw)
To: Michal Marek; +Cc: linux-kernel
On 12/02/2013 03:57 PM, Michal Marek wrote:
> On 2.12.2013 14:21, Franck Bui-Huu wrote:
>> diff --git a/scripts/setlocalversion b/scripts/setlocalversion
>> index 0b5ccf3..c16e65d 100755
>> --- a/scripts/setlocalversion
>> +++ b/scripts/setlocalversion
>> @@ -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.
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.
--
Franck
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix detectition of kernel git repository in setlocalversion script
2013-12-02 15:14 ` Franck Bui-Huu
@ 2013-12-02 15:16 ` Michal Marek
2013-12-02 15:23 ` Franck Bui-Huu
0 siblings, 1 reply; 7+ messages in thread
From: Michal Marek @ 2013-12-02 15:16 UTC (permalink / raw)
To: Franck Bui-Huu; +Cc: linux-kernel
On 2.12.2013 16:14, Franck Bui-Huu wrote:
> On 12/02/2013 03:57 PM, Michal Marek wrote:
>> On 2.12.2013 14:21, Franck Bui-Huu wrote:
>>> diff --git a/scripts/setlocalversion b/scripts/setlocalversion
>>> index 0b5ccf3..c16e65d 100755
>>> --- a/scripts/setlocalversion
>>> +++ b/scripts/setlocalversion
>>> @@ -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.
>
> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix detectition of kernel git repository in setlocalversion script
2013-12-02 15:16 ` Michal Marek
@ 2013-12-02 15:23 ` Franck Bui-Huu
2013-12-02 15:34 ` [PATCH] Fix detectition of kernel git repository in setlocalversion script [take #2] Franck Bui-Huu
0 siblings, 1 reply; 7+ messages in thread
From: Franck Bui-Huu @ 2013-12-02 15:23 UTC (permalink / raw)
To: Michal Marek; +Cc: linux-kernel
On 12/02/2013 04:16 PM, Michal Marek wrote:
> On 2.12.2013 16:14, Franck Bui-Huu wrote:
>> On 12/02/2013 03:57 PM, Michal Marek wrote:
>>> On 2.12.2013 14:21, Franck Bui-Huu wrote:
>>>> diff --git a/scripts/setlocalversion b/scripts/setlocalversion
>>>> index 0b5ccf3..c16e65d 100755
>>>> --- a/scripts/setlocalversion
>>>> +++ b/scripts/setlocalversion
>>>> @@ -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.
>>
>> 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.
--
Franck
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] Fix detectition of kernel git repository in setlocalversion script [take #2]
2013-12-02 15:23 ` Franck Bui-Huu
@ 2013-12-02 15:34 ` Franck Bui-Huu
2014-01-03 13:49 ` Michal Marek
0 siblings, 1 reply; 7+ messages in thread
From: Franck Bui-Huu @ 2013-12-02 15:34 UTC (permalink / raw)
To: mmarek; +Cc: linux-kernel
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 <fbuihuu@gmail.com>
---
scripts/setlocalversion | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 0b5ccf3..3d8af0e 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -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.
--
1.8.4.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix detectition of kernel git repository in setlocalversion script [take #2]
2013-12-02 15:34 ` [PATCH] Fix detectition of kernel git repository in setlocalversion script [take #2] Franck Bui-Huu
@ 2014-01-03 13:49 ` Michal Marek
0 siblings, 0 replies; 7+ messages in thread
From: Michal Marek @ 2014-01-03 13:49 UTC (permalink / raw)
To: Franck Bui-Huu; +Cc: linux-kernel
On Mon, Dec 02, 2013 at 04:34:29PM +0100, Franck Bui-Huu wrote:
> 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 <fbuihuu@gmail.com>
> ---
> scripts/setlocalversion | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
Applied to kbuild.git#kbuild.
Michal
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-01-03 13:49 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-02 13:21 [PATCH] Fix detectition of kernel git repository in setlocalversion script Franck Bui-Huu
2013-12-02 14:57 ` Michal Marek
2013-12-02 15:14 ` Franck Bui-Huu
2013-12-02 15:16 ` Michal Marek
2013-12-02 15:23 ` Franck Bui-Huu
2013-12-02 15:34 ` [PATCH] Fix detectition of kernel git repository in setlocalversion script [take #2] Franck Bui-Huu
2014-01-03 13:49 ` Michal Marek
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.