{"thread":{"id":"12071","subject":"git-archive for files changed in revision range","startedAt":"2008-02-13T13:03:04Z","lastAt":"2008-02-13T13:43:23Z","messageCount":4,"participants":["Graham Cox","Johannes Schindelin","Jeff King","Johannes Sixt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"68646","messageId":"20080213130304.GA19957@grahamcox.co.uk","threadId":"12071","inReplyTo":null,"subject":"git-archive for files changed in revision range","fromName":"Graham Cox","fromEmail":"graham@grahamcox.co.uk","sentAt":"2008-02-13T13:03:04Z","receivedAt":"2008-02-13T13:03:04Z","isPatch":false,"sender":{"key":"graham@grahamcox.co.uk","avatar":null},"body":"Hiya,\n\nWe have a small project that is being managed in a Git repository (MSysGit to \nbe exact) - mostly for backups and so on. The project is a mod for the \ncomputer game Civilization 4. (Actually a mod of a mod, but still...)  As \nsuch, to release the mod to other people to actually use the only thing that \nneeds to be released is all of the files that have actually been changed. (The \nactual git repository contains ~700MB of files, the vast majority of which \nhaven't changed since the initial import and so don't need to be downloaded by \npeople).\n\nI've managed to make it produce an archive that contains only the files that \nhave changed by using a combination of git-archive and git-whatchanged, along \nwith grep and sed, but it's kinda unwieldly. Is there a better way of doing \nthis?\n\nThe command line I used was something like (This is mostly from memory):\ngit-archive --format=zip . `git-whatchanged <start>..HEAD --pretty=oneline \n  | grep '^:' | sed 's/^.*\\t//'` > release.zip\n\nTo produce a zip containing all of the modified and added files for the \nrevision range <start>..HEAD.\n\n-- \nGraham Cox\n\n"},{"id":"68647","messageId":"alpine.LSU.1.00.0802131335120.30505@racer.site","threadId":"12071","inReplyTo":"20080213130304.GA19957@grahamcox.co.uk","subject":"Re: git-archive for files changed in revision range","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-02-13T13:37:33Z","receivedAt":"2008-02-13T13:37:33Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 13 Feb 2008, Graham Cox wrote:\n\n> We have a small project that is being managed in a Git repository \n> (MSysGit to be exact) - mostly for backups and so on. The project is a \n> mod for the computer game Civilization 4. (Actually a mod of a mod, but \n> still...)  As such, to release the mod to other people to actually use \n> the only thing that needs to be released is all of the files that have \n> actually been changed. (The actual git repository contains ~700MB of \n> files, the vast majority of which haven't changed since the initial \n> import and so don't need to be downloaded by people).\n> \n> I've managed to make it produce an archive that contains only the files \n> that have changed by using a combination of git-archive and \n> git-whatchanged, along with grep and sed, but it's kinda unwieldly. Is \n> there a better way of doing this?\n> \n> The command line I used was something like (This is mostly from memory):\n> git-archive --format=zip . `git-whatchanged <start>..HEAD --pretty=oneline \n>   | grep '^:' | sed 's/^.*\\t//'` > release.zip\n> \n> To produce a zip containing all of the modified and added files for the \n> revision range <start>..HEAD.\n\nMebbe\n\n\tgit archive --format=zip HEAD \\\n\t\t$(git diff-tree -r --name-only --diff-filter=AM \\\n\t\t\t<start>..HEAD)\n\nHmm?\n\nCiao,\nDscho\n"},{"id":"68648","messageId":"20080213134313.GA3617@coredump.intra.peff.net","threadId":"12071","inReplyTo":"20080213130304.GA19957@grahamcox.co.uk","subject":"Re: git-archive for files changed in revision range","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-02-13T13:43:13Z","receivedAt":"2008-02-13T13:43:13Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Feb 13, 2008 at 01:03:04PM +0000, Graham Cox wrote:\n\n> The command line I used was something like (This is mostly from memory):\n> git-archive --format=zip . `git-whatchanged <start>..HEAD --pretty=oneline \n>   | grep '^:' | sed 's/^.*\\t//'` > release.zip\n\nThat will list files multiple times if they were modified in more than\none commit. And really, there's no need to walk the history. You really\nare just comparing against two points (your baseline and your current\nstate). Walking the history will also erroneously include files which\nchanged, but then reverted back to their original state (though I expect\nthat is the uncommon case).\n\nHow about:\n\n  # mark our start point for this and future releases\n  git tag baseline `git rev-list HEAD | tail -n 1`\n\n  # find files which differ between then and now; but we only need\n  # to care about added and modified files, since deleted ones\n  # don't need to be shipped\n  git diff --diff-filter=AM --raw baseline HEAD | awk '{print $6}' >files\n\n  # and archive\n  git archive --format=zip HEAD `cat files`\n\nYou can even use diff's \"-z\" option if you have filenames that are hard\nto quote, but I will leave that as an exercise to the reader.\n\n-Peff\n"},{"id":"68649","messageId":"47B2F3FB.3020600@viscovery.net","threadId":"12071","inReplyTo":"20080213130304.GA19957@grahamcox.co.uk","subject":"Re: git-archive for files changed in revision range","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-02-13T13:43:23Z","receivedAt":"2008-02-13T13:43:23Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Graham Cox schrieb:\n> The command line I used was something like (This is mostly from memory):\n> git-archive --format=zip . `git-whatchanged <start>..HEAD --pretty=oneline \n>   | grep '^:' | sed 's/^.*\\t//'` > release.zip\n> \n> To produce a zip containing all of the modified and added files for the \n> revision range <start>..HEAD.\n\ngit diff-tree -r --name-only -z <start> HEAD | \\\n    xargs -0 git archive --format=zip HEAD > release.zip\n\n-- Hannes\n"}]}