Skip to content

Commit

Permalink
fix(gittools): gittree wouldn't run in branchless repos
Browse files Browse the repository at this point in the history
gittree used to be `gittreeif @` on the theory that every git repo had @
or HEAD.  But a git repo with no branches at all, not even main, has no
HEAD.  Now that we have repos used exclusively for issues, we have to
deal with zero commits, zero branches.
  • Loading branch information
Ned Batchelder committed Aug 11, 2023
1 parent 3c0180b commit 2f505b0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions gittools.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Source this file to define some useful aliases for working with many git
# repos at once.
# Originally from:
# Originally from:
# https://github.com/nedbat/dot/blob/a517603c4969b017d5604418d05babc4a0f323f8/.rc.sh#L126


Expand Down Expand Up @@ -38,7 +38,9 @@ gittreeif() {
fi
find . -name .git -type d -prune | while read d; do
local d=$(dirname "$d")
git -C "$d" rev-parse --verify -q "$test_branch" >& /dev/null || continue
if [[ "$test_branch" != "" ]]; then
git -C "$d" rev-parse --verify -q "$test_branch" >& /dev/null || continue
fi
if [[ $show_dir == true ]]; then
echo "---- $d ----"
fi
Expand All @@ -54,6 +56,6 @@ gittreeif() {
}

gittree() {
# @ is in every repo, so this runs on all repos
gittreeif @ "$@"
# Run a command on all git repos.
gittreeif "" "$@"
}

0 comments on commit 2f505b0

Please sign in to comment.