Re: RFC: Patch editing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Johannes Schindelin <Johannes.Schindelin@xxxxxx> schrieb:
> 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

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]