All of lore.kernel.org
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: "D. Ben Knoble" <ben.knoble@gmail.com>,
	Ludo Pulles <ludo.pulles@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Bug: being stuck in rebase mode when accidently typing `git am`
Date: Fri, 11 Apr 2025 20:13:30 +0100	[thread overview]
Message-ID: <c0075b62-34fb-41f6-bc69-e33a403d528c@gmail.com> (raw)
In-Reply-To: <CALnO6CCbzqez9-BvbuV3NRRMvFLHSv57Tfwj3ibadUAMKznWrw@mail.gmail.com>

On 11/04/2025 19:23, D. Ben Knoble wrote:
> On Thu, Apr 10, 2025 at 10:35 AM Ludo Pulles <ludo.pulles@gmail.com> wrote:
>>
>> Thank you for filling out a Git bug report!
>> Please answer the following questions to help us understand your issue.
>>
>> What did you do before the bug happened? (Steps to reproduce your issue)
>>
>> 1. Run `git init` in an empty directory, and commit once.
>> 2. Run `git am` and press Ctrl-C.
> 
> Doesn't `git am` print a warning about how it's reading from stdin?
> Pressing C-d at this point to send EOF just exits "normally."

Indeed

>> 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?

I think the issue is that "git am" does not write the 
".git/rebase-apply/applying" which "git status" uses to distinguish 
between "git am" and "git rebase" until it has read the patch files. We 
could instead check for ".git/rebase-apply/rebased-patches" which is 
written by "git rebase" but that file gets deleted when "git am" exits 
for the user to fix merge conflicts. I think the best solution is to 
move where "git am" writes ".git/rebase-apply/applying" so it gets 
created before the patch files are read - see the diff below.

Best Wishes

Phillip

[Apologies for the line wrapping the thunderbird plugin I was using to 
disable that has stopped working in recent versions]
---- >8 ----

diff --git a/builtin/am.c b/builtin/am.c
index 3b61bd4c333..e884ac39b23 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1006,6 +1006,11 @@
          refs_delete_ref(get_main_ref_store(the_repository), NULL,
                          "REBASE_HEAD", NULL, REF_NO_DEREF);

+        if (state->rebasing)
+                write_state_text(state, "rebasing", "");
+        else
+                write_state_text(state, "applying", "");
+
          if (split_mail(state, patch_format, paths, keep_cr) < 0) {
                  am_destroy(state);
                  die(_("Failed to split patches."));
@@ -1076,11 +1081,6 @@
          sq_quote_argv(&sb, state->git_apply_opts.v);
          write_state_text(state, "apply-opt", sb.buf);

-        if (state->rebasing)
-                write_state_text(state, "rebasing", "");
-        else
-                write_state_text(state, "applying", "");
-
          if (!repo_get_oid(the_repository, "HEAD", &curr_head)) {
                  write_state_text(state, "abort-safety", 
oid_to_hex(&curr_head));
                  if (!state->rebasing)


      parent reply	other threads:[~2025-04-11 19:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-10 14:35 Bug: being stuck in rebase mode when accidently typing `git am` Ludo Pulles
2025-04-11 18:23 ` D. Ben Knoble
2025-04-11 18:32   ` D. Ben Knoble
2025-04-11 19:13   ` Phillip Wood [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c0075b62-34fb-41f6-bc69-e33a403d528c@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=ben.knoble@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=ludo.pulles@gmail.com \
    --cc=phillip.wood@dunelm.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.