From 9e11023549df6672df4b7fe57a408ffb9e3243f1 Mon Sep 17 00:00:00 2001 From: Alessandro Cuttin Date: Wed, 2 Sep 2020 17:22:58 +0200 Subject: [PATCH] get the path of the .git directory I've added an additional `GINDIR` variable so that the script knows where the `.git` folder is if it is called not from the root folder of the project. This solves the problem I've encountered while using `gitinfo2` together with `git-subrepo`, as documented here: https://github.com/ingydotnet/git-subrepo/issues/499 --- post-xxx-sample.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/post-xxx-sample.txt b/post-xxx-sample.txt index d9e6ddb..9dc772f 100644 --- a/post-xxx-sample.txt +++ b/post-xxx-sample.txt @@ -10,6 +10,8 @@ FIRSTTAG=$(git describe --tags --always --dirty='-*' 2>/dev/null) # Get the first tag in history that looks like a Release RELTAG=$(git describe --tags --long --always --dirty='-*' --match '[0-9]*.*' 2>/dev/null) +# Get the path where gitHeadInfo.gin shall be put +GINDIR=$(git rev-parse --git-dir 2>/dev/null) # Hoover up the metadata git --no-pager log -1 --date=short --decorate=short \ --pretty=format:"\usepackage[% @@ -28,4 +30,4 @@ git --no-pager log -1 --date=short --decorate=short \ refnames={%d}, firsttagdescribe={$FIRSTTAG}, reltag={$RELTAG} - ]{gitexinfo}" HEAD > .git/gitHeadInfo.gin + ]{gitexinfo}" HEAD > $GINDIR/gitHeadInfo.gin