git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC PATCH 0/5] Add option to autostage changes when continuing a rebase

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 22, 2017, 15:54 UTC
Message-ID
<xmqqefs34mz4.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<d1eaed1c-5e62-0a93-f65d-06be43812617@talktalk.net>
Phillip Wood <phillip.wood@talktalk.net> writes:
Show 14 quoted lines
>> In other words, instead of
>> 
>> 	git add -u && git rebase --continue
>> 
>> you would want a quicker way to say
>> 
>> 	git rebase --continue $something_here 
>
> Exactly
> ...
> rebase --continue -a
>
> behaves like commit -a in that it commits all updated tracked files and
> does not take pathspecs.

Hmph, but what 'a' in "commit -a" wants to convey is "all", and in the context of "rebase" we want to avoid saying "all". A user can be confused into thinking "all" refers to "all subsequent commits" not "all paths conflicted".

Besides, with the $something_here option, the user is explicitly telling us that the user finisished the resolution of conflicts left in the working tree. There is nothing "auto" about it.

> Did you have any further thoughts on what checks if any this new option
> should make to avoid staging obviously unresolved files?

The more I think about this, the more I am convinced that it is a very bad idea to give such a $something_here option only to "rebase".

The standard flow for any operation that could stop in the middle because the command needs help from the user with conflicts that cannot be mechanically resolved is

 (1) write out conflicted state in the working tree, and mark these
     paths in the index by leaving them in higher stages
     (i.e. "ls-files -u" would list them);
 (2) the user edits them and marks the ones that are now resolved;
 (3) the user tells us to "continue".

and this is not limited to "rebase". "cherry-pick", "am", and "revert" all share the above, and even "merge" (which is a single commit operation to which "continue" in its original meaning---to tell us the user is done with this step and wants us to go on processing further commits or patches---does not quite apply) does.

And "rebase" is an oddball in that it is the only command that we could deduce which files in the working tree should be "add"ed, i.e. "all the files that are different from HEAD". All others allow users to begin in a dirty working tree (they only require the index to be clean), so your

	git [cherry-pick|am|revert] --continue $something_here

cannot be "git add -u && git [that command] --continue". Blindly taking any and all files that have modifications from HEAD will produce a wrong result.

You cannot even sanely solve that by first recording the paths that are conflicted before giving control back to the user and limit the "add" to them, i.e. doing "git add" only for paths that appear in "git ls-files -u" output would not catch additional changes the was needed in files that did not initially conflict (i.e. "evil merge" will have to modify a file that was not involved in the mechanical part of the conflict), because out of the files that are dirty in the working tree, some are evil merge resolutions and others are ones that were dirty from the beginning.

The only reason "git rebase" can get away without having to worry about all of the above is because it insists that the working tree is clean before it begins. In the ideal world, however, we would want to lift that and allow it to start in a working tree that has an unfinished local modification that does not interfere with the rebase, just like all other operations that could stop upon a conflict. And when that happens, your $something_here option to "git rebase --continue" will have to worry about it, too.

So...
Previous: Phillip WoodNext: Phillip Wood
Message 16 of 19 in “Add option to autostage changes when continuing a rebase”
  1. 0/5 Add option to autostage changes when continuing a rebasePhillip Wood, Jul 26, 2017
  2. 1/5 rebase --continue: add --autostage to stage unstaged changesPhillip Wood, Jul 26, 2017
  3. 3/5 Unify rebase amend message when HEAD has changedPhillip Wood, Jul 26, 2017
  4. 4/5 Add tests for rebase --continue --autostagePhillip Wood, Jul 26, 2017
  5. 5/5 Add rebase.continue.autostage config settingPhillip Wood, Jul 26, 2017
  6. 2/5 rebase -i: improve --continue --autostagePhillip Wood, Jul 26, 2017
  7. Junio C HamanoJul 26, 2017
  8. Junio C HamanoJul 26, 2017
  9. Junio C HamanoJul 26, 2017
  10. Phillip WoodJul 27, 2017
  11. Phillip WoodJul 27, 2017
  12. Junio C HamanoJul 27, 2017
  13. Phillip WoodAug 21, 2017
  14. Junio C HamanoAug 21, 2017
  15. Phillip WoodAug 22, 2017
  16. Junio C HamanoAug 22, 2017
  17. Phillip WoodAug 24, 2017
  18. Junio C HamanoAug 24, 2017
  19. Phillip WoodAug 25, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.