From ed7d2c87a983c5a7b555d7b8ef50919571195ef6 Mon Sep 17 00:00:00 2001 From: Matt Hunter Date: Sat, 9 May 2026 09:02:01 -0400 Subject: precheck: Improve rebase detection REBASE_HEAD will sometimes be left behind in .git after an interactive rebase concludes (if the last step completed was a squash or edit, for instance). Likewise, it may be missing _during_ a rebase, such as when paused on a break command. Instead, use the presence of the rebase-merge or rebase-apply directories as the "rebase in progress" signal. Note still that rebase-apply will exist during git-am as well. These two directories are utilized by the two rebase implementation backends, so we shouldn't normally expect to see them both at the same time. Signed-off-by: Matt Hunter --- git-precheck | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/git-precheck b/git-precheck index ddea769..2547563 100755 --- a/git-precheck +++ b/git-precheck @@ -65,13 +65,17 @@ if ! [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then fi check MERGE_HEAD merge -check REBASE_HEAD rebase check REVERT_HEAD revert check CHERRY_PICK_HEAD cherry-pick check BISECT_EXPECTED_REV bisect +if [ -e "$(git rev-parse --git-path rebase-merge 2>/dev/null)" ]; then + [ -z "$quiet" ] && printf '\e[0;31mrebase in progress\e[0m\n' + exit 3 +fi + if [ -e "$(git rev-parse --git-path rebase-apply 2>/dev/null)" ]; then - [ -z "$quiet" ] && printf '\e[0;31mrebase-apply (am) found\e[0m\n' + [ -z "$quiet" ] && printf '\e[0;31mrebase/am in progress\e[0m\n' exit 3 fi -- cgit v1.2.3