Matthieu Moy [off-list ref] writes:
"Paolo Ciarrocchi" [off-list ref] writes:
quoted
Yes it helps but I still wonder whether thereis a "simpler" way to achive that.
Is it possible to split a patch selecting the hunk in git gui or any
other graphical
tool?
You can apply the patch without commiting it, and them make several
partial commits, by right-click "stage hunk for commit" in git-gui.
Yes, and you can do the same with "git add -i". These tools are
not quite nice, as they encourage a wrong workflow of committing
what you haven't had as a whole in the work tree. By
definition, you are making untested commits between your base
commit (that presumably was tested well) and your final commit
(that would also be tested well).
Ideally, once you have a perfect state (i.e. the shape of the
tree recorded by the last commit in your "split" series), you
should be able to make a commit, and walk backwards, removing
the fanciest "finishing touches" changes from the work tree
files, test it, and record it as a new commit between where you
are and one commit before it. A possible workflow could be:
$ work work work, now it is perfect.
$ git commit -a -m 'Now it is perfect'
$ edit away the fanciest bits
$ test test, the basics still work.
$ git commit --splice -a -m 'Almost there'
And the last "git commit --splice" would record the tree object
as a commit, whose parent is the parent of the current HEAD, and
record the tree of the current HEAD as a (rewritten) commit that
is a child of that commit.
Graphically, you would start from (X is "the perfect commit"):
---o-------X
then "--splice" would create a new commit "W" and record the
same tree as X as a new commit X' that is a child of W:
.--W---X'
/
---o-------X
There is no such tool yet, though.
The splitting you can do with "rebase -i" instead walks
forwards. That also lets you test before you make commits in
each step.
El 28/1/2008, a las 11:27, Junio C Hamano escribió:
Matthieu Moy [off-list ref] writes:
quoted
"Paolo Ciarrocchi" [off-list ref] writes:
quoted
Yes it helps but I still wonder whether thereis a "simpler" way to
achive that.
Is it possible to split a patch selecting the hunk in git gui or any
other graphical
tool?
You can apply the patch without commiting it, and them make several
partial commits, by right-click "stage hunk for commit" in git-gui.
Yes, and you can do the same with "git add -i". These tools are
not quite nice, as they encourage a wrong workflow of committing
what you haven't had as a whole in the work tree. By
definition, you are making untested commits between your base
commit (that presumably was tested well) and your final commit
(that would also be tested well).
And as another alternative, seeing as Git is so easy to script, it is
trivial to make a script that checks out all the commits in a series
and runs the test suite against them. This of course assumes that you
have a test suite!
For example, this is the script that I use on a topic branch before
submitting the corresponding patch series. It's one of the first
scripts for Git that I wrote, so it is probably a bit naïve, but it
works in the basic case. Basically bails if "make clean && make test"
doesn't work for any commit in the series.
I've used this on the series that I've sent to the Git mailing list,
but you can use it internally on your local projects too before
merging topic branches.
Cheers,
Wincent
#!/bin/sh -e
#
# check-series.sh
# Check all commits in a topic branch before submission
#
# Created by Wincent Colaiuta on 23 November 2007.
# Copyright 2007 Wincent Colaiuta.
#
# Functions
#
die () {
echo "$1"
exit 1
}
#
# Main
#
git diff --quiet || die "Unstaged changes; won't start"
git diff --cached --quiet || die "Staged changes; won't start"
# parse HEAD (something like "ref: refs/heads/my_local_branch") to get
remote and merge
GIT_DIR=$(git rev-parse --git-dir)
TOPIC="$GIT_DIR/HEAD"
test -f "$TOPIC" || die "No HEAD found at '$TOPIC'"
BRANCH_REF=$(< "$TOPIC")
if [ "${BRANCH_REF%%: */*}" != "ref" ]; then
die "expected HEAD '$BRANCH_REF' to be of the form 'ref: .../...'"
fi
BRANCH=${BRANCH_REF##*/}
REMOTE=$(git config branch.$BRANCH.remote) || die "failed to get
branch.$BRANCH.remote"
MERGE=$(git config branch.$BRANCH.merge) || die "failed to get branch.
$BRANCH.merge"
MERGE=${MERGE##*/}
# remember which branch we were on prior to starting
trap 'git checkout $BRANCH' exit
# will check all commits in topic branch not present in origin
echo "On branch $BRANCH"
echo "Commits to be checked:"
git rev-list --pretty=oneline HEAD ^$REMOTE/$MERGE
for COMMIT in $(git rev-list HEAD ^$REMOTE/$MERGE); do
echo "Checking $COMMIT"
git checkout $COMMIT
make clean
make test || die "Commit $COMMIT is bad"
done
echo "All revisions passed!"
Hi,
On Mon, 28 Jan 2008, Junio C Hamano wrote:
Matthieu Moy [off-list ref] writes:
quoted
"Paolo Ciarrocchi" [off-list ref] writes:
quoted
Yes it helps but I still wonder whether thereis a "simpler" way to
achive that. Is it possible to split a patch selecting the hunk in
git gui or any other graphical tool?
You can apply the patch without commiting it, and them make several
partial commits, by right-click "stage hunk for commit" in git-gui.
Yes, and you can do the same with "git add -i". These tools are
not quite nice, as they encourage a wrong workflow of committing
what you haven't had as a whole in the work tree.
FWIW I have a preliminary patch for "git stash apply -i" in my personal
next branch. It does not quite work yet, and it is stalled, of course,
since I am working on master until 1.5.4 is released.
Ciao,
Dscho