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

Re: RFC: Patch editing

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Feb 27, 2007, 07:14 UTC
Message-ID
<Pine.LNX.4.64.0702270205540.6485@iabervon.org>
In-Reply-To
<Pine.LNX.4.63.0702252156190.22628@wbgn013.biozentrum.uni-wuerzburg.de>
On Sun, 25 Feb 2007, Johannes Schindelin wrote:
Show 20 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.

For much the same reason, I wrote a script that entirely ignores the intermediate commits in a throw-away head, and lets you trim down the diff between the mainline and your head, and arrange it into a new patch series. Never got around to making it particularly nice, but it might be a good starting point for someone who wants to make something useable. (In its current state, you need some external tool that you're comfortable editing diffs with, and it doesn't do anything with any commit messages you may have written)

	-Daniel
*This .sig left intentionally blank*
#!/bin/sh
if [ "$1" != "" ]
then
  git-symbolic-ref REFINE_HEAD refs/heads/$1
fi
if [ -f .git/refine-patch ]
then
  if ! git-apply --index .git/refine-patch
  then
    exit 1
  fi
  rm .git/refine-patch
  echo "Applied selected changes; verify and commit"
  exit 0
fi
if git-status > /dev/null
then
  echo "Uncommitted changes; verify and commit"
  exit 0
fi
git-diff -M HEAD REFINE_HEAD > .git/refine-patch
if [ -s .git/refine-patch ]
then
  $EDITOR .git/refine-patch
else
  echo "All done"
  rm .git/refine-patch
fi
Previous: Junio C HamanoNext: Johannes Schindelin
Message 7 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.