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

Re: RFC: Patch editing

From
PBPeter Baumann <siprbaum@stud.informatik.uni-erlangen.de>
Date
Feb 26, 2007, 13:18 UTC
Message-ID
<slrneu5ngm.s8g.siprbaum@xp.machine.xx>
In-Reply-To
<Pine.LNX.4.63.0702252156190.22628@wbgn013.biozentrum.uni-wuerzburg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> schrieb:
Show 54 quoted lines
> Hi list,
>
> while I was hacking on another issue, I realized just how often I would 
> like to stash away a fix which is unrelated (but often triggered) by the 
> theme of the current topic branch. Or I fix an earlier commit, which is 
> not the tip of the branch, so I cannot --amend it.
>
> My common practice is to commit it nevertheless, and sort the topic 
> branches out later, by cherry-picking my way through the commits.
>
> This is a tedious and error-prone procedure, and I often wished I knew how 
> to use StGIT. But then, StGIT is overkill for me: on some machines I work 
> on, there is no Python installed, I do not really need to have a history 
> on the order and version of patches, and I do not need to preserve author 
> and committer information *1*.
>
> Therefore, I wrote this extremely simple script to sort out the order of 
> commits, and possibly merging some. The script lets you edit the commit 
> list upon start (reordering it, or removing commits), and then works on 
> that list. It has three subcommands:
>
> 	start <base>
> 	continue
> 	reset [-f]
>
> The subcommand "start" takes a base commit (actually, it will take the 
> merge base of HEAD and that base commit) from which to start. It builds a 
> commit list and opens it in an editor. The rows of the list have the form 
> "<action> <sha1> <oneline>". The oneline description is purely for ease of 
> use.
>
> The three possible actions are "pick" (the default), "edit" and "merge". 
> "pick" will just cherry-pick that commit, "edit" will stop after 
> cherry-picking so that you can make a small fixup (in the code or in the 
> commit message), and "merge" will try to apply the corresponding patch, 
> amend the previous commit with the result, and let you edit the combined 
> commit message.
>
> If a patch fails, or "edit" was specified, the loop is interrupted for 
> fixups. Use the subcommand "continue" to restart the loop (the working 
> tree has to be clean, though).
>
> Once there are no more commits to be picked, the original branch is 
> updated to that new tip.
>
> If you decide at some point that you do not want to rewrite the patches 
> after all, you can use the subcommand "reset".
>
> To see which commits were already applied, you can inspect .series/done, 
> and likewise .series/todo for what is to be applied yet. You can even edit 
> .series/todo if you decide on another course of action.
>
> Anyway, it is a relatively short and stupid script.
>

Nice. I tried it on a simple testcase to just rearrange some commits and it worked as expected. That was exactly what I was looking for!

I tried for a while stgit, but it seemed like overkill to me and I messed up my test repo several times, propably because I have done something wrong so I gave up.

-Peter
Previous: Johannes SchindelinNext: Shawn O. Pearce
Message 2 of 15 in “RFC: Patch editing”
  1. Johannes SchindelinFeb 25, 2007
  2. Peter BaumannFeb 26, 2007
  3. Shawn O. PearceFeb 26, 2007
  4. Johannes SchindelinFeb 26, 2007
  5. Shawn O. PearceFeb 26, 2007
  6. Junio C HamanoFeb 26, 2007
  7. Daniel BarkalowFeb 27, 2007
  8. Johannes SchindelinFeb 27, 2007
  9. Daniel BarkalowFeb 27, 2007
  10. Johannes SchindelinFeb 27, 2007
  11. Daniel BarkalowFeb 27, 2007
  12. Johannes SchindelinFeb 27, 2007
  13. Karl HasselströmFeb 28, 2007
  14. Updated version, was Re: RFC: Patch editingJohannes Schindelin, Mar 1, 2007
  15. Junio C HamanoMar 1, 2007

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.