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

Re: [PATCH 3/3] rebase: new convenient option to edit a single commit

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Mar 4, 2014, 08:59 UTC
Message-ID
<53159601.8020702@alum.mit.edu>
In-Reply-To
<CACsJy8Ct41PRb=_Ez7FLXbdiZkTU-tFYqtAxow9mCw7wYAfOhg@mail.gmail.com>
On 03/04/2014 03:08 AM, Duy Nguyen wrote:
Show 24 quoted lines
> On Tue, Mar 4, 2014 at 3:28 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
>> On Sat, Mar 1, 2014 at 9:53 PM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
>>> "git rebase -e XYZ" is basically the same as
>>>
>>> EDITOR="sed -i '1s/pick XYZ/edit XYZ/' $@" \
>>> git rebase -i XYZ^
>>>
>>> In English, it prepares the todo list for you to edit only commit XYZ
>>> to save your time. The time saving is only significant when you edit a
>>> lot of commits separately.
>>
>> Is it correct to single out only "edit" for special treatment? If
>> allowing "edit" on the command-line, then shouldn't command-line
>> "reword" also be supported? I, for one, often need to reword a commit
>> message (or two or three); far more frequently than I need to edit a
>> commit.
>>
>> (This is a genuine question about perceived favoritism of "edit", as
>> opposed to a request to further bloat the interface.)
> 
> Heh I had the same thought yesterday. The same thing could be asked
> for "git commit --fixup" to send us back to the fixed up commit so we
> can do something about it. If we go along that line, then "git commit"
> may be a better interface to reword older commits..

I disagree. "git commit --fixup" doesn't rewrite history. It just adds a new commit with a special commit message that will make it easier to rewrite history later. I think it would be prudent to keep the history-rewriting functionality segregated in "git rebase", which users already know they have to use with care [1].

But the next question is whether "git rebase" should have shortcuts for *most* of its line commands. All of the following seem to make sense:

    git rebase --edit COMMIT
        A long-form for the -e option we have been talking about.
        It is unfortunately that this spelling sounds like the
        "--edit" option on "git commit --edit" and "git merge --edit",
        so people might use it when they really mean
        "git rebase --reword COMMIT".
    git rebase --reword COMMIT
    git rebase --fixup COMMIT
    git rebase --squash COMMIT
    git rebase --kill COMMIT
        Remove the commit from history, like running "git rebase
        --interactive" then deleting that line.
I'm quite confident that I would use all of these commands.

Moreover, it would logically be reasonable to allow multiple of these options, at least as long as they have distinct COMMIT arguments. Though, as Duy points out, it might in practice be easier to edit the todo list in an editor rather than trying to do multiple "edits" at a time via the command line.

Some thought would have to go into the question of if/how these commands should interact with "git rebase --autosquash" (which, don't forget, can also be requested via rebase.autosquash).

Michael

[1] OK, granted, there is "git commit --amend", which rewrites history too. But it rewrites only the last commit, which is less likely to be problematic.

-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
Previous: Duy NguyenNext: Duy Nguyen
Message 33 of 40 in “rebase: new convenient option to edit a single commit”
  1. rebase: new convenient option to edit a single commitNguyễn Thái Ngọc Duy, Feb 27, 2014
  2. Matthieu MoyFeb 27, 2014
  3. Jeff KingFeb 28, 2014
  4. Duy NguyenFeb 28, 2014
  5. Jeff KingFeb 28, 2014
  6. Philip OakleyFeb 28, 2014
  7. 0/3 rebase's convenient optionsNguyễn Thái Ngọc Duy, Mar 2, 2014
  8. 1/3 rev-parse: support OPT_NUMBER_CALLBACK in --parseoptNguyễn Thái Ngọc Duy, Mar 2, 2014
  9. Junio C HamanoMar 4, 2014
  10. 2/3 rebase: accept -<number> as another way of saying HEAD~<number>Nguyễn Thái Ngọc Duy, Mar 2, 2014
  11. Eric SunshineMar 2, 2014
  12. Duy NguyenMar 2, 2014
  13. Eric SunshineMar 2, 2014
  14. Eric SunshineMar 2, 2014
  15. Matthieu MoyMar 2, 2014
  16. Michael HaggertyMar 3, 2014
  17. Matthieu MoyMar 3, 2014
  18. Duy NguyenMar 3, 2014
  19. David KastrupMar 3, 2014
  20. Matthieu MoyMar 3, 2014
  21. Jeff KingMar 3, 2014
  22. Junio C HamanoMar 3, 2014
  23. Matthieu MoyMar 3, 2014
  24. Junio C HamanoMar 3, 2014
  25. 3/3 rebase: new convenient option to edit a single commitNguyễn Thái Ngọc Duy, Mar 2, 2014
  26. Eric SunshineMar 2, 2014
  27. Eric SunshineMar 2, 2014
  28. Michael HaggertyMar 3, 2014
  29. Duy NguyenMar 3, 2014
  30. David KastrupMar 3, 2014
  31. Eric SunshineMar 3, 2014
  32. Duy NguyenMar 4, 2014
  33. Michael HaggertyMar 4, 2014
  34. Duy NguyenMar 4, 2014
  35. Michael HaggertyMar 4, 2014
  36. Junio C HamanoMar 4, 2014
  37. rebase: new convenient option to edit/reword/delete a single commitNguyễn Thái Ngọc Duy, Mar 9, 2014
  38. Matthieu MoyMar 9, 2014
  39. Michael HaggertyMar 10, 2014
  40. Matthieu MoyMar 10, 2014

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.