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

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
Previous: Stephen R. van den BergNext: Dmitry Potapov
Message 22 of 36 in “RFC: grafts generalised”
  1. Stephen R. van den BergJul 2, 2008
  2. Jakub NarebskiJul 2, 2008
  3. Michael J GruberJul 2, 2008
  4. Stephen R. van den BergJul 2, 2008
  5. Mike HommeyJul 2, 2008
  6. Michael J GruberJul 2, 2008
  7. Stephen R. van den BergJul 2, 2008
  8. Stephan BeyerJul 2, 2008
  9. Stephan BeyerJul 2, 2008
  10. Dmitry PotapovJul 2, 2008
  11. Stephan BeyerJul 2, 2008
  12. Stephen R. van den BergJul 3, 2008
  13. Andreas EricssonJul 7, 2008
  14. Stephen R. van den BergJul 7, 2008
  15. Stephen R. van den BergJul 2, 2008
  16. Petr BaudisJul 3, 2008
  17. Stephen R. van den BergJul 3, 2008
  18. Jakub NarebskiJul 4, 2008
  19. Dmitry PotapovJul 2, 2008
  20. Dmitry PotapovJul 2, 2008
  21. Stephen R. van den BergJul 2, 2008
  22. Dmitry PotapovJul 2, 2008
  23. Dmitry PotapovJul 2, 2008
  24. Stephen R. van den BergJul 2, 2008
  25. Avery PennarunJul 2, 2008
  26. Junio C HamanoJul 2, 2008
  27. Junio C HamanoJul 2, 2008
  28. Junio C HamanoJul 3, 2008
  29. Johannes SixtJul 3, 2008
  30. Stephen R. van den BergJul 3, 2008
  31. Johannes SixtJul 3, 2008
  32. Stephen R. van den BergJul 3, 2008
  33. Stephen R. van den BergJul 2, 2008
  34. Petr BaudisJul 3, 2008
  35. Petr BaudisJul 3, 2008
  36. Junio C HamanoJul 3, 2008

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.