From f55a32024b6adf082635a835332b9e000eb07904 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Wed, 4 Mar 2026 16:59:44 +0000 Subject: [PATCH] pgit.sh get: Fix default revision for fresh clones Fix detection of a project's revision if a project directory is freshly cloned, and hence doesn't exist, yet. The fix is to default to master for now. --- scripts/pgit.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/pgit.sh b/scripts/pgit.sh index d29aba16..d26e544f 100644 --- a/scripts/pgit.sh +++ b/scripts/pgit.sh @@ -145,6 +145,15 @@ cmd_get() fi } + project_current_revision() { + local dir="$1" + if [ -d $dir ]; then + git -C $dir rev-parse --abbrev-ref HEAD + else + echo master + fi + } + local remote_base="$global_remote_base" local remote_subpath="$global_remote_subpath" local whoami="$(id -un)" @@ -202,7 +211,7 @@ cmd_get() cur=`expr $cur + 1` local pull_url=$remote_base/$from_user$remote_subpath/$project_name local push_url=$remote_base/$remote_user$remote_subpath/$project_name - local cur_ref=$(git -C $project_dir rev-parse --abbrev-ref HEAD) + local cur_ref=$(project_current_revision $project_dir) local remote_name="jw-$from_user" local from_ref="${refspec[1]}" local to_ref="${refspec[2]}"