From cb3ccaa3381a0ef7bf16aef1156a50e55eb337b6 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Tue, 17 Feb 2026 17:19:46 +0100 Subject: [PATCH] pgit.sh: Auto-detect current project in toplevel dir This commit allows pgit.sh to target not only multiple projects below a projects-directory, but also one single project. If invoked from the toplevel directory of a project, it uses that as the only project it should deal with. This is meant to facilitate running the same VCS abstraction logic for one project as for many projects. The project or projects to deal with should probably be specified on the command line, but changing the auto-detection mechanism buys us what we want for now with low hassle. Signed-off-by: Jan Lindemann --- scripts/pgit.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/pgit.sh b/scripts/pgit.sh index dcd44add..f42378be 100644 --- a/scripts/pgit.sh +++ b/scripts/pgit.sh @@ -39,10 +39,14 @@ set_global_variables() { [ "$projects_dir" ] || { projects_dir=`pwd` - while [ ! -r Makefile ] || ! grep -q some-random-string-to-id-this-makefile Makefile; do - [ "$projects_dir" = / ] && fatal "Failed to find projects directory" - projects_dir=`dirname $projects_dir` - done + # If we're in a toplevel directory, suppose projects_dir == project_dirs, + # i.e. we only want to target this Git repo + if [ ! -d .git ]; then + while [ ! -r Makefile ] || ! grep -q some-random-string-to-id-this-makefile Makefile; do + [ "$projects_dir" = / ] && fatal "Failed to find projects directory" + projects_dir=`dirname $projects_dir` + done + fi } [ "$project_dirs" ] || {