Thread (13 messages) flat view 13 messages, 5 authors, 2016-06-15

Re: RFC: Patch editing

From: Daniel Barkalow <hidden>
Date: 2016-06-15 22:42:56

On Sun, 25 Feb 2007, Johannes Schindelin wrote:
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help