git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Dmitry Potapov" <dpotapov@gmail.com>
To: "Stephen R. van den Berg" <srb@cuci.nl>
Cc: git@vger.kernel.org
Subject: Re: RFC: grafts generalised
Date: Wed, 2 Jul 2008 22:33:29 +0400	[thread overview]
Message-ID: <37fcd2780807021133y3a02ca80g9647b1f0854fec2b@mail.gmail.com> (raw)
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:
> 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

  reply	other threads:[~2008-07-02 18:34 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-02 14:35 RFC: grafts generalised Stephen R. van den Berg
2008-07-02 16:35 ` Jakub Narebski
2008-07-02 16:43   ` Michael J Gruber
2008-07-02 17:42     ` Stephen R. van den Berg
2008-07-02 18:25       ` Mike Hommey
2008-07-02 18:34         ` Michael J Gruber
2008-07-02 19:31           ` Stephan Beyer
2008-07-02 19:36             ` Stephan Beyer
2008-07-02 20:42             ` Dmitry Potapov
2008-07-02 23:46               ` Stephan Beyer
2008-07-03  6:05                 ` Stephen R. van den Berg
2008-07-02 18:37         ` Stephen R. van den Berg
2008-07-07  6:28       ` Andreas Ericsson
2008-07-07  6:59         ` Stephen R. van den Berg
2008-07-02 17:32   ` Stephen R. van den Berg
2008-07-03  0:21     ` Petr Baudis
2008-07-03  7:11       ` Stephen R. van den Berg
2008-07-04  0:43     ` Jakub Narebski
2008-07-02 17:19 ` Dmitry Potapov
2008-07-02 17:58   ` Dmitry Potapov
2008-07-02 18:10     ` Stephen R. van den Berg
2008-07-02 18:33       ` Dmitry Potapov [this message]
2008-07-02 20:39       ` Dmitry Potapov
2008-07-02 21:18         ` Stephen R. van den Berg
2008-07-02 21:28           ` Avery Pennarun
2008-07-02 21:27         ` Junio C Hamano
2008-07-02 21:49           ` Junio C Hamano
2008-07-03  0:03             ` Junio C Hamano
2008-07-03  6:02       ` Johannes Sixt
2008-07-03  7:30         ` Stephen R. van den Berg
2008-07-03  7:42           ` Johannes Sixt
2008-07-03  9:37             ` Stephen R. van den Berg
2008-07-02 17:59   ` Stephen R. van den Berg
2008-07-03  0:13 ` Petr Baudis
2008-07-03  0:16   ` Petr Baudis
2008-07-03  0:28     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=37fcd2780807021133y3a02ca80g9647b1f0854fec2b@mail.gmail.com \
    --to=dpotapov@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=srb@cuci.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).