|
From: Philippe W. <phi...@so...> - 2018-03-11 14:15:02
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=f72dce36da804163c4826442073fbb36d40a1e60 commit f72dce36da804163c4826442073fbb36d40a1e60 Author: Philippe Waroquiers <phi...@sk...> Date: Sun Mar 11 15:12:54 2018 +0100 auxprogs/make_or_upd_vgversion_h : accept a git worktree as a git dir A directory can be a git directory in 2 cases: * it is a git repository, checked with -d .git + it is a git worktree directory (see git help worktree) Modify auxprogs/make_or_upd_vgversion_h so that it detects worktree directory and produces a correct git version for --version -v Diff: --- auxprogs/make_or_upd_vgversion_h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/auxprogs/make_or_upd_vgversion_h b/auxprogs/make_or_upd_vgversion_h index 7787b4c..ea6f068 100755 --- a/auxprogs/make_or_upd_vgversion_h +++ b/auxprogs/make_or_upd_vgversion_h @@ -2,7 +2,9 @@ extract_git_version() { - if [ -d "$1"/.git ] + PREVPWD="$PWD" + cd "$1" + if [ -d ./.git ] || git rev-parse --is-inside-work-tree > /dev/null 2> /dev/null then REV=$(git show --format=%H#%ci -s $(git rev-parse HEAD) | sed -e 's/ .*//' -e 's/[0-9a-f]\{30\}#/#/' -e 's/-//g' \ @@ -11,7 +13,8 @@ extract_git_version() echo $REV$X else echo "unknown" - fi + fi + cd "$PREVPWD" } srcdir="${1:-.}" @@ -24,7 +27,7 @@ else /* Do not edit: file generated by auxprogs/make_or_upd_vgversion_h. This file defines VGGIT, used to report GIT revision when using command line options: -v --version - The produced VGGIT format is + The produced VGGIT format is hhhhhhhhhh-YYYYMMDDX where hhhhhhhhhh is the first 10 characters of the HEAD commit YYYYMMDD is the commit date |
|
From: Matthias S. <zz...@ge...> - 2018-03-13 11:22:12
|
Am 11.03.2018 um 15:14 schrieb Philippe Waroquiers: > https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=f72dce36da804163c4826442073fbb36d40a1e60 > > commit f72dce36da804163c4826442073fbb36d40a1e60 > Author: Philippe Waroquiers <phi...@sk...> > Date: Sun Mar 11 15:12:54 2018 +0100 > > auxprogs/make_or_upd_vgversion_h : accept a git worktree as a git dir > > A directory can be a git directory in 2 cases: > * it is a git repository, checked with -d .git > + it is a git worktree directory (see git help worktree) > > Modify auxprogs/make_or_upd_vgversion_h so that it detects worktree directory > and produces a correct git version for --version -v > > Diff: > --- > auxprogs/make_or_upd_vgversion_h | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/auxprogs/make_or_upd_vgversion_h b/auxprogs/make_or_upd_vgversion_h > index 7787b4c..ea6f068 100755 > --- a/auxprogs/make_or_upd_vgversion_h > +++ b/auxprogs/make_or_upd_vgversion_h > @@ -2,7 +2,9 @@ > > extract_git_version() > { > - if [ -d "$1"/.git ] > + PREVPWD="$PWD" > + cd "$1" > + if [ -d ./.git ] || git rev-parse --is-inside-work-tree > /dev/null 2> /dev/null Hi Philippe, this check could be optimized. If there is no directory .git it always calls git rev-parse. This could be improved by first testing if .git is a file before running git rev-parse. But I am not sure if it is worth optimizing that case. If you want to change it, maybe make it: if [ -e ./.git ] && git rev-parse --is-inside-work-tree > /dev/null 2> /dev/null That way it always checks --is-inside-work-tree, but only if .git exists (as file or directory). Regards Matthias |