Add git-graft-ripple, a tool for permanently grafting history into a tree.
Subsystems (2)
PATCH 1/1 Add git-graft-ripple, a tool for permanently grafting history into a tree.
Enhancements over the original example:
o Each newly created commit A' references A, and (A^1)' (The first try referenced A^1 and (A^1)' but not A)
o Support for incrementally rewriting history is present.
---
Documentation/git-graft-ripple | 57 +++++++++++++++++ Makefile | 3 + git-graft-ripple.perl | 137 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 196 insertions(+), 1 deletions(-) create mode 100644 Documentation/git-graft-ripple create mode 100755 git-graft-ripple.perl
applies-to: 92551f12af8cd77f821d066a53c4dd301d1b41f5 9bfbdd948e6c0c9a8f0383b355e5cbbb42e0a772
Documentation/git-graft-ripple new file +57 -0
@@ -0,0 +1,57 @@ +git-graft-ripple(1) +=============== + +NAME +---- +git-graft-ripple - Rewrite history with an additional commitish as a parent. + + +SYNOPSIS +-------- +'git-log <git repository> <branch committish> <graft SHA1> [start commitish]' + +DESCRIPTION +----------- + +git-graft-ripple rewrites a series of commit objects by adding a new parent to +the most ancestral commit, and passing the changed history back up through the +revision history. + +Proceeding in reverse merge order a new commit is created using the following +algorithim: + + If this is the first commit reached, append the graft object name to + the parents. + + Replace each parent object name with the object name generated by this + algorithm earlier. + + Add the original object name to the parents. + +If a start commitish is given, the output of git-rev-list is restricted using +it. This allows for incremental grafting to occur. + +Note: No branches are modified by this operation. + +Files +----- + +GIT_DIR/info/ripple-status contains a mapping between the original object name +and the object name generated by this algorithm. When doing incremental +grafting, this file is necessary to continue to rename objects. If this is not +present, git-graft-ripple will leave the old object name in the list of +parents, which should still allow most merges to occur cleanly. + + +Author +------ +Written by Ryan Anderson <[email protected]> + +Documentation +-------------- +Documentation by Ryan Anderson. + +GIT +--- +Part of the gitlink:git[7] suite +
Makefile +2 -1
@@ -97,7 +97,8 @@ SCRIPT_SH = \ SCRIPT_PERL = \ git-archimport.perl git-cvsimport.perl git-relink.perl \ git-shortlog.perl git-fmt-merge-msg.perl \ - git-svnimport.perl git-mv.perl git-cvsexportcommit.perl + git-svnimport.perl git-mv.perl git-cvsexportcommit.perl \ + git-graft-ripple.perl SCRIPT_PYTHON = \ git-merge-recursive.py
git-graft-ripple.perl new file +137 -0
137 lines not on this page · raw message
---
0.99.9.GIT
Quoted 7 lines · Ryan Anderson
Enhancements over the original example:
o Each newly created commit A' references A, and (A^1)' (The first try referenced A^1 and (A^1)' but not A)
o Support for incrementally rewriting history is present.
How about the case of having commits that have pointers to other commits in the comments?
For example, on the kernel do
gitk 19842d67340e4a8f616552d344e97fc7452aa37a
and see how gitk highlights the SHA1's in the commit message and makes hyperlinks to the commits they point to..
Linus
Quoted 12 lines · Linus Torvalds
Quoted 7 lines · Ryan Anderson
Enhancements over the original example:
o Each newly created commit A' references A, and (A^1)' (The first try referenced A^1 and (A^1)' but not A)
o Support for incrementally rewriting history is present.
How about the case of having commits that have pointers to other commits in the comments?
Quoted 6 lines
For example, on the kernel do
gitk 19842d67340e4a8f616552d344e97fc7452aa37aand see how gitk highlights the SHA1's in the commit message and makes hyperlinks to the commits they point to..
For some reason, my gut says that this goes too far. I'm having a hard time pinning down a way to explain that.
I guess something (untested) like this could do it, right before I call git_commit_tree():
my $found;
do {
$found = 0;
if ($csets{$old}{comments} =~ /\s([a-f0-9]{40})\s/ &&
exists $newcsets{$1}) {
my $tcommit = $1;
$found = 1;
$csets{$old}{comments} =~ s/$tcommit/$newcsets{$tcommit}/g;
}
} while ($found);I'm not entirely convinced this is a good idea, but there it is.
I'll write up a patch later for this (probably switching to GetOpt in the process.)
Signature · 2 lines
Ryan Anderson sometimes Pug Majere
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Ryan" == Ryan Anderson <[email protected]> writes:
Ryan> git_commit_tree():
Ryan> my $found;
Ryan> do {
Ryan> $found = 0;
Ryan> if ($csets{$old}{comments} =~ /\s([a-f0-9]{40})\s/ &&
Ryan> exists $newcsets{$1}) {
Ryan> my $tcommit = $1;
Ryan> $found = 1;
Ryan> $csets{$old}{comments} =~ s/$tcommit/$newcsets{$tcommit}/g;
Ryan> }
Ryan> } while ($found);
I hate artificial booleans. This is better written as:
{
last unless my ($tcommit) = $csets{$old}{comments} =~ /\s([a-f0-9]{40})\s/;
last unless exists $newcsets{$tcommit};
$csets{$old}{comments} =~ s/$tcommit/$newcsets{$tcommit}/g;
redo;
}Signature · 4 lines
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <[email protected]> <URL:http://www.stonehenge.com/merlyn/> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Hi,
Quoted 2 lines · Ryan Anderson
For some reason, my gut says that this goes too far. I'm having a hard time pinning down a way to explain that.
I can pin down what my gut says:
- the old commits still exist, so the links are not invalid
- the commit message is signed off as is
- the process to find the correct new SHA1 is not straight-forward, i.e. one would need to introduce a recursion where now suffices a simple linear loop.
Ciao,
Dscho
Quoted 2 lines · Ryan Anderson
I'm not entirely convinced this is a good idea, but there it is.
Well, quite frankly, I think the whole graft-rippling is just wrong (why do it? The grafts are fine, and after you've rippled, you'll never be able to merge with somebody who didn't) but if you do it, I think you should fix it up properly and have a resulting tree that is at least as good as the original.
Linus
Quoted 11 lines · Linus Torvalds
Quoted 6 lines · Ryan Anderson
Enhancements over the original example:
o Each newly created commit A' references A, and (A^1)' (The first try referenced A^1 and (A^1)' but not A)
o Support for incrementally rewriting history is present.
Quoted 8 lines
How about the case of having commits that have pointers to other commits in the comments?
For example, on the kernel do
gitk 19842d67340e4a8f616552d344e97fc7452aa37aand see how gitk highlights the SHA1's in the commit message and makes hyperlinks to the commits they point to..
For reference, gitweb does the same.
Signature · 3 lines
Andreas Ericsson [email protected] OP5 AB www.op5.se Tel: +46 8-230225 Fax: +46 8-230231