Re: Bug: being stuck in rebase mode when accidently typing `git am`

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Apr 11, 2025 at 2:23 PM D. Ben Knoble <ben.knoble@xxxxxxxxx> wrote:
>
> On Thu, Apr 10, 2025 at 10:35 AM Ludo Pulles <ludo.pulles@xxxxxxxxx> wrote:
> > 3. Run `git status`. It will say: 'You are currently rebasing. (all
> > conflicts fixed: run "git rebase --continue")'.
>
> Yes, this is odd: my shell prompt (using the contrib script) says
> "AM/REBASE", so I know better: git am --abort does the trick.
>
> This seems like a failure of git-status more than anything; I wonder
> if there's some difference in how the prompt script checks for
> in-progress am vs. how git-status does it?

Ok, looks like the prompt script checks for rebase, apply, and then
gives up (its ambiguous):

if [ -d "$g/rebase-apply" ]; then
__git_eread "$g/rebase-apply/next" step
__git_eread "$g/rebase-apply/last" total
if [ -f "$g/rebase-apply/rebasing" ]; then
__git_eread "$g/rebase-apply/head-name" b
r="|REBASE"
elif [ -f "$g/rebase-apply/applying" ]; then
r="|AM"
else
r="|AM/REBASE"
fi

(with apologies for GMail stripping leading tabs :eyeroll:—source code link [1])

Meantime, wt-status just assumes it must be a rebase if it isn't an apply:

if (!stat(worktree_git_path(the_repository, wt, "rebase-apply"), &st)) {
if (!stat(worktree_git_path(the_repository, wt,
"rebase-apply/applying"), &st)) {
state->am_in_progress = 1;
if (!stat(worktree_git_path(the_repository, wt, "rebase-apply/patch"),
&st) && !st.st_size)
state->am_empty_patch = 1;
} else {
state->rebase_in_progress = 1;
state->branch = get_branch(wt, "rebase-apply/head-name");
state->onto = get_branch(wt, "rebase-apply/onto");
}

(source: [2])

The shell distinction was contributed in e75201963f (Improve bash
prompt to detect various states like an unfinished merge, 2007-09-30),
author CC'd.
I think the logic in wt-status.c is largely unchanged from 83c750acde
(wt-status.*: better advices for git status added, 2012-06-05), author
CC'd as well.

Maybe we can omit a "You might be rebasing or applying; we're not sure
which?" type of message?

[1]: https://github.com/git/git/blob/08bdfd453584e489d5a551aecbdcb77584e1b958/contrib/completion/git-prompt.sh#L517-L527
[2]: https://github.com/git/git/blob/08bdfd453584e489d5a551aecbdcb77584e1b958/wt-status.c#L1725-L1734

-- 
D. Ben Knoble





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux