diff options
| author | Matt Hunter <m@lfurio.us> | 2026-05-09 09:02:01 -0400 |
|---|---|---|
| committer | Matt Hunter <m@lfurio.us> | 2026-05-10 04:47:01 -0400 |
| commit | ed7d2c87a983c5a7b555d7b8ef50919571195ef6 (patch) | |
| tree | aed8090a696c5f5a73ea4afb04db519ec904e3e9 /git-precheck | |
| parent | 3d00004d7f60e2c64f3ee17d0beede8afc1b2254 (diff) | |
| download | git-sonar-ed7d2c87a983c5a7b555d7b8ef50919571195ef6.tar.gz git-sonar-ed7d2c87a983c5a7b555d7b8ef50919571195ef6.zip | |
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 <m@lfurio.us>
Diffstat (limited to '')
| -rwxr-xr-x | git-precheck | 8 |
1 files 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 |
