{"thread":{"id":"1489","subject":"Fwd: Re: git checkout -f branch doesn't remove extra files","startedAt":"2005-08-13T04:17:37Z","lastAt":"2005-08-13T12:33:11Z","messageCount":8,"participants":["Dave Jones","Linus Torvalds","Petr Baudis","Sergey Vlasov"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"7168","messageId":"20050813041737.GB25236@redhat.com","threadId":"1489","inReplyTo":null,"subject":"Fwd: Re: git checkout -f branch doesn't remove extra files","fromName":"Dave Jones","fromEmail":"davej@redhat.com","sentAt":"2005-08-13T04:17:37Z","receivedAt":"2005-08-13T04:17:37Z","isPatch":false,"sender":{"key":"davej@redhat.com","avatar":null},"body":"Gar, got caught by the 'reply-to' going to Tony only...\n\n\t\tDave\n\n\n\nOn Fri, Aug 12, 2005 at 10:31:17AM -0700, Luck, Tony wrote:\n > I've just got around to noticing some of the new (to\n > me) features in git, and started experimenting with\n > branches.\n\nSeems a good day to learn new features, I was completely\nunaware of git-ls-files somehow.\n\nMy git snapshot creator that builds the hourly tarballs at\nhttp://www.codemonkey.org.uk/projects/git-snapshots/\ncurrently does an rsync, and then a checkout, and finally\nit cleans up by removing all the checked out files.\nIt currently does this by hand, but on learning about\nthis 'new' command, I thought, cool, now I can do..\n\ngit-ls-files | xargs rm -rf\n\nhowever, this then leaves a bunch of empty subdirs, as\ngit-ls-files doesn't list the subdirs by themselves in\nthe output.  Am I missing some other option ?\n\n\t\tDave\n\n"},{"id":"7169","messageId":"Pine.LNX.4.58.0508122151120.19049@g5.osdl.org","threadId":"1489","inReplyTo":"20050813041737.GB25236@redhat.com","subject":"Re: Fwd: Re: git checkout -f branch doesn't remove extra files","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-08-13T05:05:11Z","receivedAt":"2005-08-13T05:05:11Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sat, 13 Aug 2005, Dave Jones wrote:\n>\n> My git snapshot creator that builds the hourly tarballs at\n> http://www.codemonkey.org.uk/projects/git-snapshots/\n> currently does an rsync, and then a checkout, and finally\n> it cleans up by removing all the checked out files.\n> It currently does this by hand, but on learning about\n> this 'new' command, I thought, cool, now I can do..\n> \n> git-ls-files | xargs rm -rf\n> \n> however, this then leaves a bunch of empty subdirs, as\n> git-ls-files doesn't list the subdirs by themselves in\n> the output.  Am I missing some other option ?\n\nNope, you're not missing anything, except that you shouldn't do that.\n\n\"git-ls-files\" is very nice for things like\n\n\tgit-ls-files | xargs grep ....\n\nbut your example is not one of them. Not without options, and not _with_\nstrange options.\n\nYour example is an example of just not doing it the right way.\n\nIf you really want a temporary tree, what you do is something like\n\n\tgit-checkout-cache --prefix=tmp-dir/ -f -a\n\nand when you're done, you just do\n\n\trm -rf tmp-dir\n\nand you're done.\n\nNOTE NOTE NOTE! In the above, the order of the parameters is really really \nimportant! \"-a\" takes effect when it is seen, so it needs to be last. \nAlso, the \"--prefix\" thing really _really_ needs the slash at the end, \nbecause it's literally used to prefix the pathname.\n\nHOWEVER, if all you want to do is just a tar-file, then there's a better \nsolution. It's called\n\n\tsnap=git-snapshot-$(date +\"%Y%m%d\")\n\tgit-tar-tree HEAD $snap | gzip -9 > $snap.tar.gz\n\nwhich is even easier, and a hell of a lot more efficient.\n\nGit actually has a _lot_ of nifty tools. I didn't realize that people \ndidn't know about such basic stuff as \"git-tar-tree\" and \"git-ls-files\". \n\n\t\tLinus\n"},{"id":"7173","messageId":"20050813052731.GC11456@redhat.com","threadId":"1489","inReplyTo":"Pine.LNX.4.58.0508122151120.19049@g5.osdl.org","subject":"Re: Fwd: Re: git checkout -f branch doesn't remove extra files","fromName":"Dave Jones","fromEmail":"davej@redhat.com","sentAt":"2005-08-13T05:27:32Z","receivedAt":"2005-08-13T05:27:32Z","isPatch":false,"sender":{"key":"davej@redhat.com","avatar":null},"body":"On Fri, Aug 12, 2005 at 10:05:11PM -0700, Linus Torvalds wrote:\n\n > HOWEVER, if all you want to do is just a tar-file, then there's a better \n > solution. It's called\n > \n > \tsnap=git-snapshot-$(date +\"%Y%m%d\")\n > \tgit-tar-tree HEAD $snap | gzip -9 > $snap.tar.gz\n > \n > which is even easier, and a hell of a lot more efficient.\n\nNice. That takes noticably less time to create the sparse/git snapshots\ncompared to my crappy old script. And its now less than half the size.\nI'm sold.\n\n > Git actually has a _lot_ of nifty tools. I didn't realize that people \n > didn't know about such basic stuff as \"git-tar-tree\" and \"git-ls-files\". \n\nMaybe its because things are moving so fast :)  Or maybe I just wasn't\npaying attention on that day. (I even read the git changes via RSS,\nso I should have no excuse).\n\n\t\tDave\n"},{"id":"7174","messageId":"Pine.LNX.4.58.0508122230200.19049@g5.osdl.org","threadId":"1489","inReplyTo":"Pine.LNX.4.58.0508122151120.19049@g5.osdl.org","subject":"Re: Fwd: Re: git checkout -f branch doesn't remove extra files","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-08-13T05:33:22Z","receivedAt":"2005-08-13T05:33:22Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Fri, 12 Aug 2005, Linus Torvalds wrote:\n> \n> Git actually has a _lot_ of nifty tools. I didn't realize that people \n> didn't know about such basic stuff as \"git-tar-tree\" and \"git-ls-files\". \n\nBtw, I just checked that git-tar-tree is documented and has a man-page. It \ndoes. However, that man-page attributes authorship to me, which is wrong. \ngit-tar-tree was written by Rene Scharfe <rene.scharfe@lsrfire.ath.cx>.\n\nDon't know how many other man-pages say I wrote something just because \npeople copied another man-page around. Worth fixing, though.\n\n\t\tLinus\n"},{"id":"7175","messageId":"Pine.LNX.4.58.0508122235120.19049@g5.osdl.org","threadId":"1489","inReplyTo":"20050813052731.GC11456@redhat.com","subject":"Re: Fwd: Re: git checkout -f branch doesn't remove extra files","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-08-13T05:39:48Z","receivedAt":"2005-08-13T05:39:48Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sat, 13 Aug 2005, Dave Jones wrote:\n> \n>  > Git actually has a _lot_ of nifty tools. I didn't realize that people \n>  > didn't know about such basic stuff as \"git-tar-tree\" and \"git-ls-files\". \n> \n> Maybe its because things are moving so fast :)  Or maybe I just wasn't\n> paying attention on that day. (I even read the git changes via RSS,\n> so I should have no excuse).\n\nWell, git-tar-tree has been there since late April - it's actually one of \nthose really early commands. I'm pretty sure the RSS feed came later ;)\n\nI use it all the time in doing releases, it's a lot faster than creating a \ntar tree by reading the filesystem (even if you don't have to check things \nout). A hidden pearl.\n\nThis is my crappy \"release-script\":\n\n\t[torvalds@g5 ~]$ cat bin/release-script\n\t#!/bin/sh\n\tstable=\"$1\"\n\tlast=\"$2\"\n\tnew=\"$3\"\n\techo \"# git-tag-script v$new\"\n\techo \"git-tar-tree v$new linux-$new | gzip -9 > ../linux-$new.tar.gz\"\n\techo \"git-diff-tree -p v$stable v$new | gzip -9 > ../patch-$new.gz\"\n\techo \"git-rev-list --pretty v$new ^v$last > ../ChangeLog-$new\"\n\techo \"git-rev-list --pretty=short v$new ^v$last | git-shortlog > ../ShortLog\"\n\techo \"git-diff-tree -p v$last v$new | git-apply --stat > ../diffstat-$new\"\n\nand when I want to do a new kernel release I literally first tag it, and \nthen do\n\n\trelease-script 2.6.12 2.6.13-rc6 2.6.13-rc7\n\nand check that things look sane, and then just cut-and-paste the commands.\n\nYeah, it's stupid.\n\n\t\tLinus\n"},{"id":"7186","messageId":"20050813110050.GA5608@pasky.ji.cz","threadId":"1489","inReplyTo":"Pine.LNX.4.58.0508122151120.19049@g5.osdl.org","subject":"Re: Fwd: Re: git checkout -f branch doesn't remove extra files","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2005-08-13T11:00:51Z","receivedAt":"2005-08-13T11:00:51Z","isPatch":false,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Sat, Aug 13, 2005 at 07:05:11AM CEST, I got a letter\nwhere Linus Torvalds <torvalds@osdl.org> told me that...\n> If you really want a temporary tree, what you do is something like\n> \n> \tgit-checkout-cache --prefix=tmp-dir/ -f -a\n> \n> and when you're done, you just do\n> \n> \trm -rf tmp-dir\n> \n> and you're done.\n> \n> NOTE NOTE NOTE! In the above, the order of the parameters is really really \n> important! \"-a\" takes effect when it is seen, so it needs to be last. \n> Also, the \"--prefix\" thing really _really_ needs the slash at the end, \n> because it's literally used to prefix the pathname.\n> \n> HOWEVER, if all you want to do is just a tar-file, then there's a better \n> solution. It's called\n> \n> \tsnap=git-snapshot-$(date +\"%Y%m%d\")\n> \tgit-tar-tree HEAD $snap | gzip -9 > $snap.tar.gz\n> \n> which is even easier, and a hell of a lot more efficient.\n\nTo put my two cents too, Cogito has cg-export for this:\n\n\tcg-export tmp-dir\n\nto export to a temporary directory and\n\n\tcg-export git-snapshot.tar.gz\n\nto export to a gzipped tarball (it can also do .tar, .tgz and .tar.bz2).\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nIf you want the holes in your knowledge showing up try teaching\nsomeone.  -- Alan Cox\n"},{"id":"7188","messageId":"20050813161053.29593972.vsu@altlinux.ru","threadId":"1489","inReplyTo":"20050813110050.GA5608@pasky.ji.cz","subject":"Re: Fwd: Re: git checkout -f branch doesn't remove extra files","fromName":"Sergey Vlasov","fromEmail":"vsu@altlinux.ru","sentAt":"2005-08-13T12:10:53Z","receivedAt":"2005-08-13T12:10:53Z","isPatch":false,"sender":{"key":"vsu@altlinux.ru","avatar":"https://avatars.githubusercontent.com/u/616082?v=4"},"body":"On Sat, 13 Aug 2005 13:00:51 +0200 Petr Baudis wrote:\n\n> Dear diary, on Sat, Aug 13, 2005 at 07:05:11AM CEST, I got a letter\n> where Linus Torvalds <torvalds@osdl.org> told me that...\n[...]\n> > \tsnap=git-snapshot-$(date +\"%Y%m%d\")\n> > \tgit-tar-tree HEAD $snap | gzip -9 > $snap.tar.gz\n> > \n> > which is even easier, and a hell of a lot more efficient.\n> \n> To put my two cents too, Cogito has cg-export for this:\n> \n> \tcg-export tmp-dir\n> \n> to export to a temporary directory and\n> \n> \tcg-export git-snapshot.tar.gz\n> \n> to export to a gzipped tarball (it can also do .tar, .tgz and .tar.bz2).\n\nHowever, cg-export is buggy - if you use the second argument\n(cg-export DESTFILE TREE_ID), the resulting tar file is different\nfrom what git-tar-tree produces for the same TREE_ID (unless that\nTREE_ID actually points to a tree - but in practice a commit or even\ntag ID is typically used).\n\nThe problem is in this line:\n\nid=$(tree-id \"$2\")\n\nThis converts the passed commit or tag to the underlying tree, which\nis then passed to git-tar-tree.  However, git-tar-tree can follow\nsuch links itself, and, what's more important, it actually uses some\ninformation from the passed commit (it writes the commit ID to the\ntar file as an extended header, and sets timestamp of all archive\nmembers to the time of the commit).  Therefore reducing the ID\npassed to git-tar-tree to a plain tree ID is wrong - if a commit ID\nis available, it should be used.\n\n-- \nSergey Vlasov\n"},{"id":"7190","messageId":"20050813123311.GD5608@pasky.ji.cz","threadId":"1489","inReplyTo":"20050813161053.29593972.vsu@altlinux.ru","subject":"Re: Fwd: Re: git checkout -f branch doesn't remove extra files","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2005-08-13T12:33:11Z","receivedAt":"2005-08-13T12:33:11Z","isPatch":false,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Sat, Aug 13, 2005 at 02:10:53PM CEST, I got a letter\nwhere Sergey Vlasov <vsu@altlinux.ru> told me that...\n> However, cg-export is buggy - if you use the second argument\n> (cg-export DESTFILE TREE_ID), the resulting tar file is different\n> from what git-tar-tree produces for the same TREE_ID (unless that\n> TREE_ID actually points to a tree - but in practice a commit or even\n> tag ID is typically used).\n> \n> The problem is in this line:\n> \n> id=$(tree-id \"$2\")\n> \n> This converts the passed commit or tag to the underlying tree, which\n> is then passed to git-tar-tree.  However, git-tar-tree can follow\n> such links itself, and, what's more important, it actually uses some\n> information from the passed commit (it writes the commit ID to the\n> tar file as an extended header, and sets timestamp of all archive\n> members to the time of the commit).  Therefore reducing the ID\n> passed to git-tar-tree to a plain tree ID is wrong - if a commit ID\n> is available, it should be used.\n\nAha! Good catch, fixed, thanks.\n\nBTW, I also changed cg-export usage to be more consistent and flexible,\nby changing it from\n\n\tcg-export DESTFILE [TREE_ID]\n\nto\n\n\tcg-export [-r TREE_ID] DESTFILE\n\nsince I think not many people are using cg-export anyway and much less\nof them passing it TREE_ID explicitly.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nIf you want the holes in your knowledge showing up try teaching\nsomeone.  -- Alan Cox\n"}]}