{"thread":{"id":"18773","subject":"Any way to edit the file in index directly?","startedAt":"2009-04-08T01:03:03Z","lastAt":"2009-04-08T05:44:02Z","messageCount":7,"participants":["Ping Yin","Jeff King","Johannes Schindelin","Markus Heidelberg"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"110763","messageId":"46dff0320904071803k68fddff4j226760392e0c5bcc@mail.gmail.com","threadId":"18773","inReplyTo":null,"subject":"Any way to edit the file in index directly?","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2009-04-08T01:03:03Z","receivedAt":"2009-04-08T01:03:03Z","isPatch":false,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"There seems to be a patch for this ( add -e?), but i forget where to find it.\n\nFor a big change, instead of \"add -p\", it may be easier to edit the\nindex directly ( with the corresponding worktree file alongside)\n\nPing Yin\n"},{"id":"110766","messageId":"20090408021041.GB18244@coredump.intra.peff.net","threadId":"18773","inReplyTo":"46dff0320904071803k68fddff4j226760392e0c5bcc@mail.gmail.com","subject":"Re: Any way to edit the file in index directly?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-04-08T02:10:41Z","receivedAt":"2009-04-08T02:10:41Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Apr 08, 2009 at 09:03:03AM +0800, Ping Yin wrote:\n\n> There seems to be a patch for this ( add -e?), but i forget where to\n> find it.\n\n\"add -p\" has an \"e\"dit option for editing the patch. I don't recall any\nway of directly editing the content.\n\n> For a big change, instead of \"add -p\", it may be easier to edit the\n> index directly ( with the corresponding worktree file alongside)\n\nI'm not sure what you mean by \"alongside\". If you mean \"by editing a\ntemporary file that corresponds to the index file without munging your\nworktree file\", then you can do:\n\n  FILE=foo.c\n  git show :$FILE >$FILE.tmp\n  $EDITOR $FILE.tmp\n  object=`git hash-object -w $FILE.tmp`\n  git update-index --cacheinfo 100644 $object $FILE\n\nAnd obviously you could make a script for that if you wanted (but at the\nvery least, you would need quotes to handle files with spaces, and\nprobably some magic to handle smudge/clean filters and CRLF properly for\nthe tempfile).\n\n-Peff\n"},{"id":"110769","messageId":"20090408021620.GC18244@coredump.intra.peff.net","threadId":"18773","inReplyTo":"20090408021041.GB18244@coredump.intra.peff.net","subject":"Re: Any way to edit the file in index directly?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-04-08T02:16:20Z","receivedAt":"2009-04-08T02:16:20Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Apr 07, 2009 at 10:10:41PM -0400, Jeff King wrote:\n\n> On Wed, Apr 08, 2009 at 09:03:03AM +0800, Ping Yin wrote:\n> \n> > There seems to be a patch for this ( add -e?), but i forget where to\n> > find it.\n> \n> \"add -p\" has an \"e\"dit option for editing the patch. I don't recall any\n> way of directly editing the content.\n\nHmm, actually maybe you are thinking of:\n\n  http://article.gmane.org/gmane.comp.version-control.git/103389\n\nwhich I even reviewed, but it doesn't seem to have gone anywhere after\nthat.\n\n-Peff\n"},{"id":"110771","messageId":"46dff0320904071927l16d54c8bv9c219e681cc96bb2@mail.gmail.com","threadId":"18773","inReplyTo":"20090408021620.GC18244@coredump.intra.peff.net","subject":"Re: Any way to edit the file in index directly?","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2009-04-08T02:27:57Z","receivedAt":"2009-04-08T02:27:57Z","isPatch":false,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"Ping Yin\n\n\n\nOn Wed, Apr 8, 2009 at 10:16 AM, Jeff King <peff@peff.net> wrote:\n> On Tue, Apr 07, 2009 at 10:10:41PM -0400, Jeff King wrote:\n>\n>> On Wed, Apr 08, 2009 at 09:03:03AM +0800, Ping Yin wrote:\n>>\n>> > There seems to be a patch for this ( add -e?), but i forget where to\n>> > find it.\n>>\n>> \"add -p\" has an \"e\"dit option for editing the patch. I don't recall any\n>> way of directly editing the content.\n>\n\n> \"add -p\" has an \"e\"dit option for editing the patch. I don't recall any\n> way of directly editing the content.\n\nSometimes by 'add -p', i can't get what i want (the patch will fail to\napply when exiting editor). And with 'add -p', i can't get a global\nview of all changes together\n\n> I'm not sure what you mean by \"alongside\".\n\nBy \"aloneside\" i mean i can open the index and worktree file in diff\nmode side by side for easily editing.\n\n> Hmm, actually maybe you are thinking of:\n>\n>  http://article.gmane.org/gmane.comp.version-control.git/103389\n>\n> which I even reviewed, but it doesn't seem to have gone anywhere after\n> that.\n>\n\nThanks, That's what i want.\n"},{"id":"110774","messageId":"alpine.DEB.1.00.0904080434240.10279@pacific.mpi-cbg.de","threadId":"18773","inReplyTo":"20090408021041.GB18244@coredump.intra.peff.net","subject":"Re: Any way to edit the file in index directly?","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-04-08T02:39:17Z","receivedAt":"2009-04-08T02:39:17Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 7 Apr 2009, Jeff King wrote:\n\n> On Wed, Apr 08, 2009 at 09:03:03AM +0800, Ping Yin wrote:\n> \n> > There seems to be a patch for this ( add -e?), but i forget where to\n> > find it.\n> \n> \"add -p\" has an \"e\"dit option for editing the patch. I don't recall any\n> way of directly editing the content.\n\nI posted a patch for \"git add --edit\", which allows you to edit the _diff_ \nbetween the working directory and the index, and which applies the result \nusing apply --recount.\n\nBut that has nothing to do with \"editing the index directly\".\n\nBut you might want to use a combination of \"hash-object -w --stdin\" and \n\"update-index --cacheinfo\".  IOW something like\n\n\tsha1=$(echo Hello | git hash-object -w --stdin) &&\n\tgit update-index --cacheinfo 0644 $sha1 my-file\n\nHowever, Ping, I _strongly_ suspect an X-Y problem here.  IOW I think you \nare asking about specifics of a certain _solution_, while we probably have \na better solution for your particular _problem_.\n\nHth,\nDscho\n"},{"id":"110778","messageId":"46dff0320904072117x712f29dj6854ee7219aede9d@mail.gmail.com","threadId":"18773","inReplyTo":"alpine.DEB.1.00.0904080434240.10279@pacific.mpi-cbg.de","subject":"Re: Any way to edit the file in index directly?","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2009-04-08T04:17:59Z","receivedAt":"2009-04-08T04:17:59Z","isPatch":false,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"On Wed, Apr 8, 2009 at 10:39 AM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n> Hi,\n>\n> On Tue, 7 Apr 2009, Jeff King wrote:\n>\n>> On Wed, Apr 08, 2009 at 09:03:03AM +0800, Ping Yin wrote:\n>>\n>> > There seems to be a patch for this ( add -e?), but i forget where to\n>> > find it.\n>>\n>> \"add -p\" has an \"e\"dit option for editing the patch. I don't recall any\n>> way of directly editing the content.\n>\n> I posted a patch for \"git add --edit\", which allows you to edit the _diff_\n> between the working directory and the index, and which applies the result\n> using apply --recount.\n>\n> But that has nothing to do with \"editing the index directly\".\n>\n> But you might want to use a combination of \"hash-object -w --stdin\" and\n> \"update-index --cacheinfo\".  IOW something like\n>\n>        sha1=$(echo Hello | git hash-object -w --stdin) &&\n>        git update-index --cacheinfo 0644 $sha1 my-file\n>\n> However, Ping, I _strongly_ suspect an X-Y problem here.  IOW I think you\n> are asking about specifics of a certain _solution_, while we probably have\n> a better solution for your particular _problem_.\n>\n\nThanks. I think 'add --edit' is just what i meant by saying 'add -e'.\nI'll have it a try.\n"},{"id":"110787","messageId":"200904080744.02580.markus.heidelberg@web.de","threadId":"18773","inReplyTo":"46dff0320904071927l16d54c8bv9c219e681cc96bb2@mail.gmail.com","subject":"Re: Any way to edit the file in index directly?","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-04-08T05:44:02Z","receivedAt":"2009-04-08T05:44:02Z","isPatch":false,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"Ping Yin, 08.04.2009:\n> On Wed, Apr 8, 2009 at 10:16 AM, Jeff King <peff@peff.net> wrote:\n> > I'm not sure what you mean by \"alongside\".\n> \n> By \"aloneside\" i mean i can open the index and worktree file in diff\n> mode side by side for easily editing.\n\nThis is possible with git-difftool from the contrib/ area, but without\nediting the index file.\nBut I think \"worktree\" is called \"worktree\" for a good reason.\n\nMarkus\n"}]}