Re: Any way to edit the file in index directly?
- From
Jeff King <peff@peff.net>
- Date
- Apr 8, 2009, 02:10 UTC
- Message-ID
- <20090408021041.GB18244@coredump.intra.peff.net>
- In-Reply-To
- <46dff0320904071803k68fddff4j226760392e0c5bcc@mail.gmail.com>
On Wed, Apr 08, 2009 at 09:03:03AM +0800, Ping Yin wrote:
> There seems to be a patch for this ( add -e?), but i forget where to > find it.
"add -p" has an "e"dit option for editing the patch. I don't recall any way of directly editing the content.
> For a big change, instead of "add -p", it may be easier to edit the > index directly ( with the corresponding worktree file alongside)
I'm not sure what you mean by "alongside". If you mean "by editing a temporary file that corresponds to the index file without munging your worktree file", then you can do:
FILE=foo.c git show :$FILE >$FILE.tmp $EDITOR $FILE.tmp object=`git hash-object -w $FILE.tmp` git update-index --cacheinfo 100644 $object $FILE
And obviously you could make a script for that if you wanted (but at the very least, you would need quotes to handle files with spaces, and probably some magic to handle smudge/clean filters and CRLF properly for the tempfile).
-Peff