{"thread":{"id":"14409","subject":"git cherry-pick before archive","startedAt":"2008-07-11T15:46:12Z","lastAt":"2008-07-11T22:18:54Z","messageCount":11,"participants":["Denis Bueno","Johannes Schindelin","Miklos Vajna","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"82968","messageId":"6dbd4d000807110846m2921ddb9r88eb3986762b8f81@mail.gmail.com","threadId":"14409","inReplyTo":null,"subject":"git cherry-pick before archive","fromName":"Denis Bueno","fromEmail":"dbueno@gmail.com","sentAt":"2008-07-11T15:46:12Z","receivedAt":"2008-07-11T15:46:12Z","isPatch":false,"sender":{"key":"dbueno@gmail.com","avatar":"https://gravatar.com/avatar/591be06714161d33b59a485e6b822cbd40ecc0b91fd188b9924ea22c405996f7?d=mp&s=160"},"body":"Hi all,\n\nI'm trying to use git archive to create a kind of \"release\" tarball of\nmy source.  I've got a patch (a commit) that I'd like to apply to the\ntree before I call git archive on HEAD.  Currently my command is:\n\n    git archive --format=tar --prefix=pfx/ HEAD | gzip > prj.tgz\n\nIf I were to actually modify my tree & history, I'd change the command to:\n\n    git cherry-pick 97a1235ce674f7cf4df3129cd0ab1ae0793db392\n    git archive --format=tar --prefix=pfx/ HEAD | gzip > prj.tgz\n    git reset --hard HEAD^\n\nBut I'd rather not modify my history, if it's possible.  (This will\ncreate a bunch of dangling commit objects over time, no?)\n\n-- \n Denis\n"},{"id":"82971","messageId":"alpine.DEB.1.00.0807111649290.8950@racer","threadId":"14409","inReplyTo":"6dbd4d000807110846m2921ddb9r88eb3986762b8f81@mail.gmail.com","subject":"Re: git cherry-pick before archive","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-11T15:51:03Z","receivedAt":"2008-07-11T15:51:03Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 11 Jul 2008, Denis Bueno wrote:\n\n> I'm trying to use git archive to create a kind of \"release\" tarball of\n> my source.  I've got a patch (a commit) that I'd like to apply to the\n> tree before I call git archive on HEAD.  Currently my command is:\n> \n>     git archive --format=tar --prefix=pfx/ HEAD | gzip > prj.tgz\n> \n> If I were to actually modify my tree & history, I'd change the command to:\n> \n>     git cherry-pick 97a1235ce674f7cf4df3129cd0ab1ae0793db392\n>     git archive --format=tar --prefix=pfx/ HEAD | gzip > prj.tgz\n>     git reset --hard HEAD^\n> \n> But I'd rather not modify my history, if it's possible.  (This will\n> create a bunch of dangling commit objects over time, no?)\n\n$ git cherry-pick -n <bla>\n$ git archive --format=tar --prefix=pfx/ $(git write-tree) | gzip > prj.tgz\n$ git reset\n\nHth,\nDscho\n"},{"id":"82974","messageId":"6dbd4d000807110909n1ced22eeraef45af441c20cca@mail.gmail.com","threadId":"14409","inReplyTo":"alpine.DEB.1.00.0807111649290.8950@racer","subject":"Re: git cherry-pick before archive","fromName":"Denis Bueno","fromEmail":"dbueno@gmail.com","sentAt":"2008-07-11T16:09:02Z","receivedAt":"2008-07-11T16:09:02Z","isPatch":false,"sender":{"key":"dbueno@gmail.com","avatar":"https://gravatar.com/avatar/591be06714161d33b59a485e6b822cbd40ecc0b91fd188b9924ea22c405996f7?d=mp&s=160"},"body":"On Fri, Jul 11, 2008 at 11:51, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n> $ git cherry-pick -n <bla>\n> $ git archive --format=tar --prefix=pfx/ $(git write-tree) | gzip > prj.tgz\n> $ git reset\n\nThank you!  This is much better.  The only thing that could improve it\nis by some way to \"un-cherry-pick\" the applied change (so that after\n\"git reset\" there are no local modifications to the file(s) changed by\ncherry-picking <bla>).\n\nIs there an easy way to invert a patch to undo the change the original\npatch introduced?\n\n\n-- \n Denis\n"},{"id":"82975","messageId":"20080711161158.GD10347@genesis.frugalware.org","threadId":"14409","inReplyTo":"6dbd4d000807110909n1ced22eeraef45af441c20cca@mail.gmail.com","subject":"Re: git cherry-pick before archive","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-07-11T16:11:58Z","receivedAt":"2008-07-11T16:11:58Z","isPatch":false,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Fri, Jul 11, 2008 at 12:09:02PM -0400, Denis Bueno <dbueno@gmail.com> wrote:\n> On Fri, Jul 11, 2008 at 11:51, Johannes Schindelin\n> <Johannes.Schindelin@gmx.de> wrote:\n> > $ git cherry-pick -n <bla>\n> > $ git archive --format=tar --prefix=pfx/ $(git write-tree) | gzip > prj.tgz\n> > $ git reset\n\nI guess he wanted to write 'git reset --hard' here ;-)\n\n> \n> Thank you!  This is much better.  The only thing that could improve it\n> is by some way to \"un-cherry-pick\" the applied change (so that after\n> \"git reset\" there are no local modifications to the file(s) changed by\n> cherry-picking <bla>).\n> \n> Is there an easy way to invert a patch to undo the change the original\n> patch introduced?\n\ngit show <commit> | git apply -R?\n"},{"id":"82977","messageId":"6dbd4d000807110918s1187abeaye6f249ff60b650fb@mail.gmail.com","threadId":"14409","inReplyTo":"20080711161158.GD10347@genesis.frugalware.org","subject":"Re: git cherry-pick before archive","fromName":"Denis Bueno","fromEmail":"dbueno@gmail.com","sentAt":"2008-07-11T16:18:23Z","receivedAt":"2008-07-11T16:18:23Z","isPatch":false,"sender":{"key":"dbueno@gmail.com","avatar":"https://gravatar.com/avatar/591be06714161d33b59a485e6b822cbd40ecc0b91fd188b9924ea22c405996f7?d=mp&s=160"},"body":"On Fri, Jul 11, 2008 at 12:11, Miklos Vajna <vmiklos@frugalware.org> wrote:\n> On Fri, Jul 11, 2008 at 12:09:02PM -0400, Denis Bueno <dbueno@gmail.com> wrote:\n>> On Fri, Jul 11, 2008 at 11:51, Johannes Schindelin\n>> <Johannes.Schindelin@gmx.de> wrote:\n>> > $ git cherry-pick -n <bla>\n>> > $ git archive --format=tar --prefix=pfx/ $(git write-tree) | gzip > prj.tgz\n>> > $ git reset\n>\n> I guess he wanted to write 'git reset --hard' here ;-)\n\nBut that will undo local modifications to any uncommitted files, not\njust those affected by the cherry-pick.  I don't want to do that.\n\n>> Thank you!  This is much better.  The only thing that could improve it\n>> is by some way to \"un-cherry-pick\" the applied change (so that after\n>> \"git reset\" there are no local modifications to the file(s) changed by\n>> cherry-picking <bla>).\n>>\n>> Is there an easy way to invert a patch to undo the change the original\n>> patch introduced?\n>\n> git show <commit> | git apply -R?\n\nBrilliant!  Thanks.  I didn't know about apply (or show for that matter ....).\n\n-- \n Denis\n"},{"id":"82987","messageId":"alpine.DEB.1.00.0807111924180.8950@racer","threadId":"14409","inReplyTo":"20080711161158.GD10347@genesis.frugalware.org","subject":"Re: git cherry-pick before archive","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-11T18:25:18Z","receivedAt":"2008-07-11T18:25:18Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 11 Jul 2008, Miklos Vajna wrote:\n\n> On Fri, Jul 11, 2008 at 12:09:02PM -0400, Denis Bueno <dbueno@gmail.com> wrote:\n> > On Fri, Jul 11, 2008 at 11:51, Johannes Schindelin\n> > <Johannes.Schindelin@gmx.de> wrote:\n> > > $ git cherry-pick -n <bla>\n> > > $ git archive --format=tar --prefix=pfx/ $(git write-tree) | gzip > prj.tgz\n> > > $ git reset\n> \n> I guess he wanted to write 'git reset --hard' here ;-)\n\nHe did not ;-)  \"git reset\" resets only the index, which is what I wanted.\n\nAnyway, back to Denis' question: I could imagine (haven't tested, \nthought), that \"git revert -n <the-same-commit>\" would undo the \"git \ncherry-pick -n\".\n\nPlease test and report back,\nDscho\n"},{"id":"82988","messageId":"6dbd4d000807111128l4721113dh3713bc7abd3d837e@mail.gmail.com","threadId":"14409","inReplyTo":"alpine.DEB.1.00.0807111924180.8950@racer","subject":"Re: git cherry-pick before archive","fromName":"Denis Bueno","fromEmail":"dbueno@gmail.com","sentAt":"2008-07-11T18:28:43Z","receivedAt":"2008-07-11T18:28:43Z","isPatch":false,"sender":{"key":"dbueno@gmail.com","avatar":"https://gravatar.com/avatar/591be06714161d33b59a485e6b822cbd40ecc0b91fd188b9924ea22c405996f7?d=mp&s=160"},"body":"On Fri, Jul 11, 2008 at 14:25, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n> Anyway, back to Denis' question: I could imagine (haven't tested,\n> thought), that \"git revert -n <the-same-commit>\" would undo the \"git\n> cherry-pick -n\".\n\nSo I need to be able to maintain the patch that is applied to the tree\nbefore archiving, so instead of a commit ID, I'm now using a patch\nfile, and the sequence of actions is like so:\n\n    $ <assume index is clean>\n    $ git apply --cached patchfile || exit 1\n    $ git archive --format=tar --prefix=pfx/ $(git write-tree) \\\n          | gzip > prj.tgz\n    $ git reset\n\nThis way I don't even need to reverse-apply the patch, because I never\ntouch the working copy.  Of course, this can't be done in this way in\nany other revision control system, because they don't have an index.\n\n-- \n Denis\n"},{"id":"82993","messageId":"alpine.DEB.1.00.0807111944000.8950@racer","threadId":"14409","inReplyTo":"6dbd4d000807111128l4721113dh3713bc7abd3d837e@mail.gmail.com","subject":"Re: git cherry-pick before archive","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-11T18:46:27Z","receivedAt":"2008-07-11T18:46:27Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 11 Jul 2008, Denis Bueno wrote:\n\n> On Fri, Jul 11, 2008 at 14:25, Johannes Schindelin\n> <Johannes.Schindelin@gmx.de> wrote:\n> > Anyway, back to Denis' question: I could imagine (haven't tested,\n> > thought), that \"git revert -n <the-same-commit>\" would undo the \"git\n> > cherry-pick -n\".\n> \n> So I need to be able to maintain the patch that is applied to the tree\n> before archiving, so instead of a commit ID, I'm now using a patch\n> file, and the sequence of actions is like so:\n> \n>     $ <assume index is clean>\n>     $ git apply --cached patchfile || exit 1\n>     $ git archive --format=tar --prefix=pfx/ $(git write-tree) \\\n>           | gzip > prj.tgz\n>     $ git reset\n> \n> This way I don't even need to reverse-apply the patch, because I never\n> touch the working copy.  Of course, this can't be done in this way in\n> any other revision control system, because they don't have an index.\n\nWell, they have.  They just do not expose it.\n\nBTW in your case, I would suggest this:\n\n\tINDEX_FILE=.git/bla git read-tree HEAD &&\n\tINDEX_FILE=.git/bla git apply --cached patchfile &&\n\tINDEX_FILE=.git/bla git archive [...] &&\n\trm .git/bla\n\nIOW: Just use a temporary index for your work.\n\nCiao,\nDscho\n"},{"id":"82994","messageId":"6dbd4d000807111149s4fb661cak9fac152864260901@mail.gmail.com","threadId":"14409","inReplyTo":"alpine.DEB.1.00.0807111944000.8950@racer","subject":"Re: git cherry-pick before archive","fromName":"Denis Bueno","fromEmail":"dbueno@gmail.com","sentAt":"2008-07-11T18:49:20Z","receivedAt":"2008-07-11T18:49:20Z","isPatch":false,"sender":{"key":"dbueno@gmail.com","avatar":"https://gravatar.com/avatar/591be06714161d33b59a485e6b822cbd40ecc0b91fd188b9924ea22c405996f7?d=mp&s=160"},"body":"On Fri, Jul 11, 2008 at 14:46, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n> BTW in your case, I would suggest this:\n>\n>        INDEX_FILE=.git/bla git read-tree HEAD &&\n>        INDEX_FILE=.git/bla git apply --cached patchfile &&\n>        INDEX_FILE=.git/bla git archive [...] &&\n>        rm .git/bla\n>\n> IOW: Just use a temporary index for your work.\n\nWhat is the rationale?  So I can relieve the assumption that the index is clean?\n\n-- \n Denis\n"},{"id":"82995","messageId":"alpine.DEB.1.00.0807111950540.8950@racer","threadId":"14409","inReplyTo":"6dbd4d000807111149s4fb661cak9fac152864260901@mail.gmail.com","subject":"Re: git cherry-pick before archive","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-11T18:53:17Z","receivedAt":"2008-07-11T18:53:17Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 11 Jul 2008, Denis Bueno wrote:\n\n> On Fri, Jul 11, 2008 at 14:46, Johannes Schindelin\n> <Johannes.Schindelin@gmx.de> wrote:\n> > BTW in your case, I would suggest this:\n> >\n> >        INDEX_FILE=.git/bla git read-tree HEAD &&\n> >        INDEX_FILE=.git/bla git apply --cached patchfile &&\n> >        INDEX_FILE=.git/bla git archive [...] &&\n> >        rm .git/bla\n> >\n> > IOW: Just use a temporary index for your work.\n> \n> What is the rationale?  So I can relieve the assumption that the index \n> is clean?\n\nNot completely.\n\nIt will just leave the current index alone, ignoring the changes within \nit.  It will also avoid having to update the index several times.\n\nIMO it is just the thing you should do here: you do not want to stage \nanything for commit, so keep .git/index as-is, and use a temporary staging \narea instead.\n\nIt also avoids the need to \"undo\" things that might not be easily undone: \nif your patch contains stuff that was partly in the index, but \nuncommitted, neither \"git reset\" nor \"git revert -n\" will do what you \nwant.\n\nCiao,\nDscho\n"},{"id":"83030","messageId":"7vzloohxo1.fsf@gitster.siamese.dyndns.org","threadId":"14409","inReplyTo":"alpine.DEB.1.00.0807111649290.8950@racer","subject":"Re: git cherry-pick before archive","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-11T22:18:54Z","receivedAt":"2008-07-11T22:18:54Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> Hi,\n>\n> On Fri, 11 Jul 2008, Denis Bueno wrote:\n>\n>> I'm trying to use git archive to create a kind of \"release\" tarball of\n>> my source.  I've got a patch (a commit) that I'd like to apply to the\n>> tree before I call git archive on HEAD.  Currently my command is:\n>> \n>>     git archive --format=tar --prefix=pfx/ HEAD | gzip > prj.tgz\n>> \n>> If I were to actually modify my tree & history, I'd change the command to:\n>> \n>>     git cherry-pick 97a1235ce674f7cf4df3129cd0ab1ae0793db392\n>>     git archive --format=tar --prefix=pfx/ HEAD | gzip > prj.tgz\n>>     git reset --hard HEAD^\n>> \n>> But I'd rather not modify my history, if it's possible.  (This will\n>> create a bunch of dangling commit objects over time, no?)\n>\n> $ git cherry-pick -n <bla>\n> $ git archive --format=tar --prefix=pfx/ $(git write-tree) | gzip > prj.tgz\n> $ git reset\n\nThat will create a bunch of dangling tree objects over time, yes.\n"}]}