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

Re: FEATURE suggestion git commit --amend <ref>

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Feb 27, 2009, 14:49 UTC
Message-ID
<49A7FD81.9070808@drmicha.warpmail.net>
In-Reply-To
<alpine.DEB.1.00.0902271121590.6600@intel-tinevez-2-302>
Johannes Schindelin venit, vidit, dixit 27.02.2009 11:30:
Show 45 quoted lines
> Hi,
> 
> On Fri, 27 Feb 2009, Caleb Cushing wrote:
> 
>> git rebase -i seems a little more tedious/unfriendly than I'd like if 
>> all I want to do is edit HEAD~2 (assuming no merges) it's a bit of a 
>> pain to do a rebase -i and then pick which patches to edit. might be 
>> nice to be able to do stuff like git commit --amend <ref> and have that 
>> call rebase (as I think not rebasing is impossible?) with edit only on 
>> the ref I picked.
>>
>> hopefully I've explained well enough.
> 
> Yes, but IMHO you did not consider the undesired side effects well enough.
> 
> For example: What about merges?
> 
> To be clear: amending a merge is not just a matter of "rebase -i 
> <commit>^" with a custom script, and even worse, there could be merges 
> between the commit you want to amend and the current HEAD.  That is a 
> complete Pandora box right there.
> 
> Also, your amended changes could break reapplication of the later commits.  
> So "git commit --amend <ref-other-than-HEAD>" is _semantically_ different 
> from "git commit --amend".
> 
> Of course, there is also the problem that <ref> might not be an ancestor 
> of HEAD to begin with.
> 
> And that the specified commit could be part of more than one branch, 
> adding to user's confusion when it is only rewritten in the current 
> branch.
> 
> But more fundamental: is this operation something we want to make _that_ 
> easy?  After all, it is _not_ the common case, and it bears such a bunch 
> of problems that the user should be made well aware of what she is doing.
> 
> All in all, as with many feature requests, I have to say that I see what 
> you want, but the side effects are too horrible -- and you did not 
> consider them, obviously, otherwise you would have put forward arguments 
> as to why the side effects would not matter that much.
> 
> Ciao,
> Dscho
> 

FWIW I share all your caveats, especially the fact that - as you point out - we're really talking rebase here, not commit--amend.

In the end I think Caleb is asking for something like
git rebase --single $COMMIT
to mean

sha=$(git rev-parse --short $COMMIT) GIT_EDITOR='sed -i -e"/'$sha'/s/pick/edit/"' git rebase -i $COMMIT^

which, again, is easy in shell, and left as an exercise regarding the implementation as a git alias "rebase-one"...

Michael
Previous: Johannes Schindelin
Message 5 of 5 in “FEATURE suggestion git commit --amend <ref>”
  1. Caleb CushingFeb 27, 2009
  2. Sverre RabbelierFeb 27, 2009
  3. Wincent ColaiutaFeb 27, 2009
  4. Johannes SchindelinFeb 27, 2009
  5. Michael J GruberFeb 27, 2009

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.