[Devel] [PATCH RHEL7 COMMIT] ms/Fix detectition of kernel git repository in setlocalversion script [take #2]

Konstantin Khorenko khorenko at virtuozzo.com
Fri Jul 1 18:23:22 MSK 2022


The commit is pushed to "branch-rh7-3.10.0-1160.66.1.vz7.188.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.66.1.vz7.188.1
------>
commit 139c63d457cd765295d00a219a15f2134fd7a80a
Author: Franck Bui-Huu <fbuihuu at gmail.com>
Date:   Mon Dec 2 16:34:29 2013 +0100

    ms/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 <fbuihuu at gmail.com>
    Signed-off-by: Michal Marek <mmarek at suse.cz>
    
    (cherry picked from ms commit 7593e0902bc41392315316f1b5f4ba15feead842)
    Upon request from Pasha Tikhomirov.
    
    Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 scripts/setlocalversion | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 84b88f109b80f..7fd97dcee3f41 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.


More information about the Devel mailing list