Given 2 git repositories (Product A and Product B), with submodules (CommonSubmodule, SomeOtherSubmodule)
D:\Repositories\ProductA\
D:\Repositories\ProductA\CommonSubmodule
D:\Repositories\ProductA\SomeOtherSubmodule
D:\Repositories\ProductA\SomeOtherSubmodule\
D:\Repositories\ProductB\SomeOtherSubmodule\
D:\Repositories\ProductB\CommonSubmodule\
I've found a script online that allows for branches to be logged via a post_checkout hook
#!/bin/sh
previous_head_ref=$1
new_head_ref=$2
is_branch_checkout=$3
if [[ "$previous_head_ref" != "$new_head_ref" ]] && [[ "$is_branch_checkout" == 1 ]]; then
branch=$(git rev-parse --abbrev-ref HEAD)
#if [[ "develop" != "$branch" ]]; then
path="$(dirname "$0")/.."
logfile="$path/x_branch_log"
ts=$(date +%s)
echo "$branch|1|$ts" >> $logfile
echo "Logging $branch|1|$ts to $logfile"
echo PWD is $PWD
#fi
fi
In a post_checkout context, how can I get the root directory (D:\Repositories) no matter how deep in the submodule the hook is installed, without encoding absolute paths?
D:\Repositories\
Additionally, how can I get the root product directory, e.g.
D:\Repositories\ProductA\
D:\Repositories\ProductB\