{"thread":{"id":"322","subject":"[PATCH] cg-export to tarball","startedAt":"2005-04-26T07:12:46Z","lastAt":"2005-04-26T22:24:14Z","messageCount":3,"participants":["Joshua T. Corbin","Petr Baudis","Rene Scharfe"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"1719","messageId":"200504260312.46320.jcorbin@wunjo.org","threadId":"322","inReplyTo":null,"subject":"[PATCH] cg-export to tarball","fromName":"Joshua T. Corbin","fromEmail":"jcorbin@wunjo.org","sentAt":"2005-04-26T07:12:46Z","receivedAt":"2005-04-26T07:12:46Z","isPatch":true,"sender":{"key":"jcorbin@wunjo.org","avatar":null},"body":"The following patch to cg-export will simlpy create a tarball if the argument \nends in .tar.gz, .tar.bz2, or .tar.\n\nSigned-off-by; Joshua T. Corbin <jcorbin@wunjo.org>\n\nIndex: cg-export\n===================================================================\n--- c7eec90959408a71c465b36e728113a2754f99df/cg-export  (mode:100755 \nsha1:94d419de48a12f1ea1059451ac4cd489f7008916)\n+++ b839b802f91e79ea7b0bb7dcf3e228659bf96a87/cg-export  (mode:100755 \nsha1:29834b2749b0a8d7c71a4c67325e4f5ece9d28a0)\n@@ -24,8 +24,33 @@\n \n [ -e \"$destdir\" ] && die \"$destdir already exists.\"\n \n+case $destdir in\n+  *.tar*)\n+    tarfile=$destdir\n+    destdir=${destdir%.tar*}\n+    ;;\n+esac\n+\n mkdir -p $destdir || die \"cannot create $destdir\"\n export GIT_INDEX_FILE=\"$destdir/.git-index\"\n read-tree $id\n checkout-cache \"--prefix=$destdir/\" -a\n rm $GIT_INDEX_FILE\n+\n+[ -z \"$tarfile\" ] && exit 0\n+\n+case $tarfile in\n+  *.tar.gz)\n+    tar -cvzf $tarfile $destdir || die \"Failed to create $tarfile\"\n+    ;;\n+  *.tar.bz2)\n+    tar -cvjf $tarfile $destdir || die \"Failed to create $tarfile\"\n+    ;;\n+  *.tar)\n+    tar -cvf $tarfile $destdir || die \"Failed to create $tarfile\"\n+    ;;\n+  *)\n+    die \"Don't know how to make a ${tarfile#$destdir} file\"\n+    ;;\n+esac\n+rm -fr $destdir\n"},{"id":"1784","messageId":"20050426202014.GJ13224@pasky.ji.cz","threadId":"322","inReplyTo":"200504260312.46320.jcorbin@wunjo.org","subject":"Re: [PATCH] cg-export to tarball","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-04-26T20:20:14Z","receivedAt":"2005-04-26T20:20:14Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Tue, Apr 26, 2005 at 09:12:46AM CEST, I got a letter\nwhere \"Joshua T. Corbin\" <jcorbin@wunjo.org> told me that...\n> The following patch to cg-export will simlpy create a tarball if the argument \n> ends in .tar.gz, .tar.bz2, or .tar.\n> \n> Signed-off-by; Joshua T. Corbin <jcorbin@wunjo.org>\n\nWhat about cooperating with Rene Scharfe and using his tar-tree?\nI didn't actually try it yet (not even look at the code so far),\nit'd be cool if someone would give it some review and testing.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"},{"id":"1813","messageId":"426EBF8E.5000906@lsrfire.ath.cx","threadId":"322","inReplyTo":"20050426202014.GJ13224@pasky.ji.cz","subject":"Re: [PATCH] cg-export to tarball","fromName":"Rene Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2005-04-26T22:24:14Z","receivedAt":"2005-04-26T22:24:14Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Petr Baudis schrieb:\n> Dear diary, on Tue, Apr 26, 2005 at 09:12:46AM CEST, I got a letter \n> where \"Joshua T. Corbin\" <jcorbin@wunjo.org> told me that...\n> \n>> The following patch to cg-export will simlpy create a tarball if \n>> the argument ends in .tar.gz, .tar.bz2, or .tar.\n>> \n>> Signed-off-by; Joshua T. Corbin <jcorbin@wunjo.org>\n> \n> \n> What about cooperating with Rene Scharfe and using his tar-tree? I \n> didn't actually try it yet (not even look at the code so far), it'd \n> be cool if someone would give it some review and testing.\n\nYes, this looks like a job for tar-tree.  You could do something like this:\n\n   destbasename=${destdir##*/}\n   case \"$destdir\" in\n   *.tar)\n       tar-tree $id \"${destbasename%.tar}\" > \"$destdir\"\n       ;;\n   *.tgz)\n       tar-tree $id \"${destbasename%.tgz}\" | gzip -9 > \"$destdir\"\n       ;;\n   # *.tar.gz, *.tar.bz2, ...\n   *)\n       mkdir -p \"$destdir\" || die \"cannot create $destdir\"\n       export GIT_INDEX_FILE=\"$destdir/.git-index\"\n       read-tree $id\n       checkout-cache \"--prefix=$destdir/\" -a\n       rm \"$GIT_INDEX_FILE\"\n       ;;\n   esac\n\nThe second parameter to tar-tree is an optional prefix for all paths\ninside the archive (official kernel tarballs always have linux-2.x.xx as\na prefix).  It makes some sense to set this value to the archive\nfilename, \"cg-export linux-2.6.12-rc3.tar.bz2\" would than work as expected.\n\nWhat do you think?  If you like it I'll cook up a patch later unless you\nbeat me to it.\n\nThanks,\nRene\n"}]}