Re: RFC: grafts generalised
- From
Dmitry Potapov <dpotapov@gmail.com>
- Date
- Jul 2, 2008, 18:33 UTC
- Message-ID
- <37fcd2780807021133y3a02ca80g9647b1f0854fec2b@mail.gmail.com>
- In-Reply-To
- <20080702181021.GD16235@cuci.nl>
On Wed, Jul 2, 2008 at 10:10 PM, Stephen R. van den Berg <srb@cuci.nl> wrote:
Show 7 quoted lines
> Dmitry Potapov wrote: >>On second thought, it may be not necessary. You can extract an old commit >>object, edit it, put it into Git with a new SHA1, and then use the graft file to >>replace all references from an old to a new one. And you will be able to see >>changes immediately in gitk. > > Hmmmm, interesting thought. That just might solve my problem.
This script is just a prove of the concept. It seems to work for me, but I don't really tested it.
=========================================== #!/bin/bash
set -e
# creating some silly repo git init # creating some history for ((i=0; $i<10; i++)) do echo foo$i > foo$i git add foo$i git commit -m "add foo$i" done
# run gitk to see it gitk --all &
# dump all graft info to text file git rev-list --parents --all > .git/info/grafts.tmp mv .git/info/grafts.tmp .git/info/grafts
# please choose what commit you want to edit echo while read -p 'Edit commit: ' C do C=$(git rev-parse "$C") || continue # edit commit C git cat-file commit $C > .git/COMMIT_OBJ vim .git/COMMIT_OBJ
C2=$(git hash-object -w -t commit .git/COMMIT_OBJ)
# replace all references from C to C2 sed -e 's/\<'$C'\>/'$C2'/g' < .git/info/grafts > .git/info/grafts.tmp mv .git/info/grafts.tmp .git/info/grafts done ===========================================
Dmitry