diff mbox series

[1/2] rebase: help user when dying with preserve-merges`

Message ID cd06aa68c2fc65551cd810a1c2c0941c51433163.1645526016.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series Update the die() preserve-merges messages to help some users | expand

Commit Message

Philip Oakley Feb. 22, 2022, 10:33 a.m. UTC
From: Philip Oakley <philipoakley@iee.email>

Git will die if a "rebase --preserve-merges" is in progress.
Users cannot --quit, --abort or --continue the rebase.

This sceario can occur if the user updates their Git, or switches
to another newer version, after starting a preserve-merges rebase,
commonly via the pull setting.

One trigger is an unexpectedly difficult to resolve conflict, as
reported on the `git-users` group.
(https://groups.google.com/g/git-for-windows/c/3jMWbBlXXHM)

Tell the user the cause, i.e. the existence of the directory.
The problem must be resolved manually, `git rebase --<option>`
commands will die, or the user must downgrade. Also, note that
the deleted options are no longer shown in the documentation.

Signed-off-by: Philip Oakley <philipoakley@iee.email>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 builtin/rebase.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Ævar Arnfjörð Bjarmason Feb. 22, 2022, 3:32 p.m. UTC | #1
On Tue, Feb 22 2022, Philip Oakley via GitGitGadget wrote:

> From: Philip Oakley <philipoakley@iee.email>
>
> Git will die if a "rebase --preserve-merges" is in progress.
> Users cannot --quit, --abort or --continue the rebase.
>
> This sceario can occur if the user updates their Git, or switches
> to another newer version, after starting a preserve-merges rebase,
> commonly via the pull setting.
>
> One trigger is an unexpectedly difficult to resolve conflict, as
> reported on the `git-users` group.
> (https://groups.google.com/g/git-for-windows/c/3jMWbBlXXHM)
>
> Tell the user the cause, i.e. the existence of the directory.
> The problem must be resolved manually, `git rebase --<option>`
> commands will die, or the user must downgrade. Also, note that
> the deleted options are no longer shown in the documentation.

I can go and read the linked thread for the answer, but:

>  		if (is_directory(buf.buf)) {
> -			die("`rebase -p` is no longer supported");
> +			die("`rebase --preserve-merges` (-p) is no longer supported.\n"
> +			"You still have a `.git/rebase-merge/rewritten` directory, \n"
> +			"indicating a `rebase preserve-merge` is still in progress.\n");
>  		} else {
>  			strbuf_reset(&buf);
>  			strbuf_addf(&buf, "%s/interactive", merge_dir());

As much of an improvement this is, I'd be no closer to knowing what I
should do at this point.

Should I "rm -rf" that directory, downgrade my version of git if I'd
like to recover my work (as the message alludes to).

In either case I'd think that this is getting a bit past the length
where we'd have just a die() v.s. splitting it into a die()/advise()
pair. I.e. to have the advise() carry some bullet-point list about X/Y/Z
solutions, with the die() being a brief ~"we did because xyz dir is
still here".
Philip Oakley Feb. 22, 2022, 4:06 p.m. UTC | #2
On 22/02/2022 15:32, Ævar Arnfjörð Bjarmason wrote:
> On Tue, Feb 22 2022, Philip Oakley via GitGitGadget wrote:
>
>> From: Philip Oakley <philipoakley@iee.email>
>>
>> Git will die if a "rebase --preserve-merges" is in progress.
>> Users cannot --quit, --abort or --continue the rebase.
>>
>> This sceario can occur if the user updates their Git, or switches
>> to another newer version, after starting a preserve-merges rebase,
>> commonly via the pull setting.
>>
>> One trigger is an unexpectedly difficult to resolve conflict, as
>> reported on the `git-users` group.
>> (https://groups.google.com/g/git-for-windows/c/3jMWbBlXXHM)
>>
>> Tell the user the cause, i.e. the existence of the directory.
>> The problem must be resolved manually, `git rebase --<option>`
>> commands will die, or the user must downgrade. Also, note that
>> the deleted options are no longer shown in the documentation.
> I can go and read the linked thread for the answer, but:
>
>>  		if (is_directory(buf.buf)) {
>> -			die("`rebase -p` is no longer supported");
>> +			die("`rebase --preserve-merges` (-p) is no longer supported.\n"
>> +			"You still have a `.git/rebase-merge/rewritten` directory, \n"
>> +			"indicating a `rebase preserve-merge` is still in progress.\n");
>>  		} else {
>>  			strbuf_reset(&buf);
>>  			strbuf_addf(&buf, "%s/interactive", merge_dir());
> As much of an improvement this is, I'd be no closer to knowing what I
> should do at this point.
>
> Should I "rm -rf" that directory, downgrade my version of git if I'd
> like to recover my work (as the message alludes to).
>
> In either case I'd think that this is getting a bit past the length
> where we'd have just a die() v.s. splitting it into a die()/advise()
> pair. I.e. to have the advise() carry some bullet-point list about X/Y/Z
> solutions, with the die() being a brief ~"we did because xyz dir is
> still here".
>
>
Hi Ævar,

Exactly. This is a slightly special, but real, case. The previous
message was essentially totally opaque to users. An "If I were you I
wouldn't start from here" response is somewhat true, so we simply tell
the user how they got to receive the fatal message. They can then take
any of the options they choose.

Ultimately the user downgraded and managed to use "rebase --continue",
as advised by Git, without the response "fatal:" to complete their old
preserve-merges rebase.

They'll hit a similar fault in short order because when they next `pull`
they'll be slipped into trying the preserve-merge rebase again - that's
the 2/2 patch, making sure they know why.

Philip
Ævar Arnfjörð Bjarmason Feb. 23, 2022, 10:20 a.m. UTC | #3
On Tue, Feb 22 2022, Philip Oakley wrote:

> On 22/02/2022 15:32, Ævar Arnfjörð Bjarmason wrote:
>> On Tue, Feb 22 2022, Philip Oakley via GitGitGadget wrote:
>>
>>> From: Philip Oakley <philipoakley@iee.email>
>>>
>>> Git will die if a "rebase --preserve-merges" is in progress.
>>> Users cannot --quit, --abort or --continue the rebase.
>>>
>>> This sceario can occur if the user updates their Git, or switches
>>> to another newer version, after starting a preserve-merges rebase,
>>> commonly via the pull setting.
>>>
>>> One trigger is an unexpectedly difficult to resolve conflict, as
>>> reported on the `git-users` group.
>>> (https://groups.google.com/g/git-for-windows/c/3jMWbBlXXHM)
>>>
>>> Tell the user the cause, i.e. the existence of the directory.
>>> The problem must be resolved manually, `git rebase --<option>`
>>> commands will die, or the user must downgrade. Also, note that
>>> the deleted options are no longer shown in the documentation.
>> I can go and read the linked thread for the answer, but:
>>
>>>  		if (is_directory(buf.buf)) {
>>> -			die("`rebase -p` is no longer supported");
>>> +			die("`rebase --preserve-merges` (-p) is no longer supported.\n"
>>> +			"You still have a `.git/rebase-merge/rewritten` directory, \n"
>>> +			"indicating a `rebase preserve-merge` is still in progress.\n");
>>>  		} else {
>>>  			strbuf_reset(&buf);
>>>  			strbuf_addf(&buf, "%s/interactive", merge_dir());
>> As much of an improvement this is, I'd be no closer to knowing what I
>> should do at this point.
>>
>> Should I "rm -rf" that directory, downgrade my version of git if I'd
>> like to recover my work (as the message alludes to).
>>
>> In either case I'd think that this is getting a bit past the length
>> where we'd have just a die() v.s. splitting it into a die()/advise()
>> pair. I.e. to have the advise() carry some bullet-point list about X/Y/Z
>> solutions, with the die() being a brief ~"we did because xyz dir is
>> still here".
>>
>>
> Hi Ævar,
>
> Exactly. This is a slightly special, but real, case. The previous
> message was essentially totally opaque to users. An "If I were you I
> wouldn't start from here" response is somewhat true, so we simply tell
> the user how they got to receive the fatal message. They can then take
> any of the options they choose.
>
> Ultimately the user downgraded and managed to use "rebase --continue",
> as advised by Git, without the response "fatal:" to complete their old
> preserve-merges rebase.

Right. I'm pointing out that in this proposed version of the die()
message we stop just short of actually telling the user how to proceed.

I.e. just that they have a X directory, not that they should either
remove X and lose their work, or downgrade git, proceed, and then
upgrade git.

> They'll hit a similar fault in short order because when they next `pull`
> they'll be slipped into trying the preserve-merge rebase again - that's
> the 2/2 patch, making sure they know why.

Well, this is "rebase". You can have been running rebases in a
repository without ever having any interactions with remotes.

And even if you had interactions with remotes you might be doing so via
"git fetch" followed by "git rebase", and might not ever invoke "git
pull".

And even if you did a "git pull" later shouldn't the error you got here
be sufficiently stand-alone as to tell you what to do, without needing a
later "pull"?
Philip Oakley Feb. 23, 2022, 5:44 p.m. UTC | #4
On 23/02/2022 10:20, Ævar Arnfjörð Bjarmason wrote:
> On Tue, Feb 22 2022, Philip Oakley wrote:
>
>> On 22/02/2022 15:32, Ævar Arnfjörð Bjarmason wrote:
>>> On Tue, Feb 22 2022, Philip Oakley via GitGitGadget wrote:
>>>
>>>> From: Philip Oakley <philipoakley@iee.email>
>>>>
>>>> Git will die if a "rebase --preserve-merges" is in progress.
>>>> Users cannot --quit, --abort or --continue the rebase.
>>>>
>>>> This sceario can occur if the user updates their Git, or switches
>>>> to another newer version, after starting a preserve-merges rebase,
>>>> commonly via the pull setting.
>>>>
>>>> One trigger is an unexpectedly difficult to resolve conflict, as
>>>> reported on the `git-users` group.
>>>> (https://groups.google.com/g/git-for-windows/c/3jMWbBlXXHM)
>>>>
>>>> Tell the user the cause, i.e. the existence of the directory.
>>>> The problem must be resolved manually, `git rebase --<option>`
>>>> commands will die, or the user must downgrade. Also, note that
>>>> the deleted options are no longer shown in the documentation.
>>> I can go and read the linked thread for the answer, but:
>>>
>>>>  		if (is_directory(buf.buf)) {
>>>> -			die("`rebase -p` is no longer supported");
>>>> +			die("`rebase --preserve-merges` (-p) is no longer supported.\n"
>>>> +			"You still have a `.git/rebase-merge/rewritten` directory, \n"
>>>> +			"indicating a `rebase preserve-merge` is still in progress.\n");
>>>>  		} else {
>>>>  			strbuf_reset(&buf);
>>>>  			strbuf_addf(&buf, "%s/interactive", merge_dir());
>>> As much of an improvement this is, I'd be no closer to knowing what I
>>> should do at this point.
>>>
>>> Should I "rm -rf" that directory, downgrade my version of git if I'd
>>> like to recover my work (as the message alludes to).
>>>
>>> In either case I'd think that this is getting a bit past the length
>>> where we'd have just a die() v.s. splitting it into a die()/advise()
>>> pair. I.e. to have the advise() carry some bullet-point list about X/Y/Z
>>> solutions, with the die() being a brief ~"we did because xyz dir is
>>> still here".
>>>
>>>
>> Hi Ævar,
>>
>> Exactly. This is a slightly special, but real, case. The previous
>> message was essentially totally opaque to users. An "If I were you I
>> wouldn't start from here" response is somewhat true, so we simply tell
>> the user how they got to receive the fatal message. They can then take
>> any of the options they choose.
>>
>> Ultimately the user downgraded and managed to use "rebase --continue",
>> as advised by Git, without the response "fatal:" to complete their old
>> preserve-merges rebase.
> Right. I'm pointing out that in this proposed version of the die()
> message we stop just short of actually telling the user how to proceed.
>
> I.e. just that they have a X directory, not that they should either
> remove X and lose their work, or downgrade git, proceed, and then
> upgrade git.
In a sense, that is it. They are in a difficult place, but with at least
a little information to seek further information and start making their
choices. Before, they (users in difficulty) were rather uninformed.
>> They'll hit a similar fault in short order because when they next `pull`
>> they'll be slipped into trying the preserve-merge rebase again - that's
>> the 2/2 patch, making sure they know why.
> Well, this is "rebase". You can have been running rebases in a
> repository without ever having any interactions with remotes.
True. That is a possibility. But we have also removed the preserve
option for interaction with remotes as well.
>
> And even if you had interactions with remotes you might be doing so via
> "git fetch" followed by "git rebase", and might not ever invoke "git
> pull".
>
> And even if you did a "git pull" later shouldn't the error you got here
> be sufficiently stand-alone as to tell you what to do, without needing a
> later "pull"?
Why are we delaying telling the user that they would have problems there
as well? It shouldn't be a game about how many ways we can trip up the user.

It's a pity the problem has split into the different ways into disaster.
Ævar Arnfjörð Bjarmason March 8, 2022, 1:45 p.m. UTC | #5
On Wed, Feb 23 2022, Philip Oakley wrote:

> On 23/02/2022 10:20, Ævar Arnfjörð Bjarmason wrote:
>> On Tue, Feb 22 2022, Philip Oakley wrote:
>>
>>> On 22/02/2022 15:32, Ævar Arnfjörð Bjarmason wrote:
>>>> On Tue, Feb 22 2022, Philip Oakley via GitGitGadget wrote:
>>>>
>>>>> From: Philip Oakley <philipoakley@iee.email>
>>>>>
>>>>> Git will die if a "rebase --preserve-merges" is in progress.
>>>>> Users cannot --quit, --abort or --continue the rebase.
>>>>>
>>>>> This sceario can occur if the user updates their Git, or switches
>>>>> to another newer version, after starting a preserve-merges rebase,
>>>>> commonly via the pull setting.
>>>>>
>>>>> One trigger is an unexpectedly difficult to resolve conflict, as
>>>>> reported on the `git-users` group.
>>>>> (https://groups.google.com/g/git-for-windows/c/3jMWbBlXXHM)
>>>>>
>>>>> Tell the user the cause, i.e. the existence of the directory.
>>>>> The problem must be resolved manually, `git rebase --<option>`
>>>>> commands will die, or the user must downgrade. Also, note that
>>>>> the deleted options are no longer shown in the documentation.
>>>> I can go and read the linked thread for the answer, but:
>>>>
>>>>>  		if (is_directory(buf.buf)) {
>>>>> -			die("`rebase -p` is no longer supported");
>>>>> +			die("`rebase --preserve-merges` (-p) is no longer supported.\n"
>>>>> +			"You still have a `.git/rebase-merge/rewritten` directory, \n"
>>>>> +			"indicating a `rebase preserve-merge` is still in progress.\n");
>>>>>  		} else {
>>>>>  			strbuf_reset(&buf);
>>>>>  			strbuf_addf(&buf, "%s/interactive", merge_dir());
>>>> As much of an improvement this is, I'd be no closer to knowing what I
>>>> should do at this point.
>>>>
>>>> Should I "rm -rf" that directory, downgrade my version of git if I'd
>>>> like to recover my work (as the message alludes to).
>>>>
>>>> In either case I'd think that this is getting a bit past the length
>>>> where we'd have just a die() v.s. splitting it into a die()/advise()
>>>> pair. I.e. to have the advise() carry some bullet-point list about X/Y/Z
>>>> solutions, with the die() being a brief ~"we did because xyz dir is
>>>> still here".
>>>>
>>>>
>>> Hi Ævar,
>>>
>>> Exactly. This is a slightly special, but real, case. The previous
>>> message was essentially totally opaque to users. An "If I were you I
>>> wouldn't start from here" response is somewhat true, so we simply tell
>>> the user how they got to receive the fatal message. They can then take
>>> any of the options they choose.
>>>
>>> Ultimately the user downgraded and managed to use "rebase --continue",
>>> as advised by Git, without the response "fatal:" to complete their old
>>> preserve-merges rebase.
>> Right. I'm pointing out that in this proposed version of the die()
>> message we stop just short of actually telling the user how to proceed.
>>
>> I.e. just that they have a X directory, not that they should either
>> remove X and lose their work, or downgrade git, proceed, and then
>> upgrade git.
> In a sense, that is it. They are in a difficult place, but with at least
> a little information to seek further information and start making their
> choices. Before, they (users in difficulty) were rather uninformed.

Yes, it's definitely an improvement. I'm just wondering if we can tell
them a bit more so that they're not needing to search "what do do about
.git/rebase-merge/rewritten" on Google/stackoverflow/whatever.

I.e. can we just specifically say that they either need to downgrade,
continue, upgrade, or alternatively rm -rf it, depending on wheher
they'd like to not lose their work, or if that's OK?

>>> They'll hit a similar fault in short order because when they next `pull`
>>> they'll be slipped into trying the preserve-merge rebase again - that's
>>> the 2/2 patch, making sure they know why.
>> Well, this is "rebase". You can have been running rebases in a
>> repository without ever having any interactions with remotes.
> True. That is a possibility. But we have also removed the preserve
> option for interaction with remotes as well.

*Nod*, presumably you mean its removal from "builtin/pull.c" etc.
>>
>> And even if you had interactions with remotes you might be doing so via
>> "git fetch" followed by "git rebase", and might not ever invoke "git
>> pull".
>>
>> And even if you did a "git pull" later shouldn't the error you got here
>> be sufficiently stand-alone as to tell you what to do, without needing a
>> later "pull"?
> Why are we delaying telling the user that they would have problems there
> as well? It shouldn't be a game about how many ways we can trip up the user.
>
> It's a pity the problem has split into the different ways into disaster.

I'm just saying that the reason the message is a bit confusing is
because we *are* delaying it. I.e. we could give a more specific error
message in builtin/pull.c, but the "preserve merges" scaffolding was
already removed from it.

Which is why we're doing it in builtin/rebase.c, and suggesting "tweak
your pull settings", to a user who may or may not have arrived there
after a "pull" (and may not be using remotes at all).

I think overall that's OK in this case, i.e. this fix shouldn't be held
up by putting that scaffolding in place in builtin/pull.c again to
slightly improve the error.

But perhaps in the 2/2 error just say instead: "if you arrived here via
'git pull' ....". I.e. no extra code, just a slight tweak to the
message, and any user seeing it by invoking "rebase" directly won't be
further confused about why the error is saying something about "pull"
(which they didn't run).
diff mbox series

Patch

diff --git a/builtin/rebase.c b/builtin/rebase.c
index d858add3fe8..07221d0ae41 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -1181,7 +1181,9 @@  int cmd_rebase(int argc, const char **argv, const char *prefix)
 		strbuf_reset(&buf);
 		strbuf_addf(&buf, "%s/rewritten", merge_dir());
 		if (is_directory(buf.buf)) {
-			die("`rebase -p` is no longer supported");
+			die("`rebase --preserve-merges` (-p) is no longer supported.\n"
+			"You still have a `.git/rebase-merge/rewritten` directory, \n"
+			"indicating a `rebase preserve-merge` is still in progress.\n");
 		} else {
 			strbuf_reset(&buf);
 			strbuf_addf(&buf, "%s/interactive", merge_dir());