{"thread":{"id":"1617","subject":"git-ls-new-files & make patch, pull, etc.","startedAt":"2005-08-23T02:07:13Z","lastAt":"2005-09-09T03:19:46Z","messageCount":8,"participants":["Jeff Carr","Junio C Hamano","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"7638","messageId":"430A84D1.2050206@linuxmachines.com","threadId":"1617","inReplyTo":null,"subject":"git-ls-new-files & make patch, pull, etc.","fromName":"Jeff Carr","fromEmail":"jcarr@linuxmachines.com","sentAt":"2005-08-23T02:07:13Z","receivedAt":"2005-08-23T02:07:13Z","isPatch":false,"sender":{"key":"jcarr@linuxmachines.com","avatar":null},"body":"Something simple like the perl script at the bottom would be useful for\nshowing files that haven't been added via git-update-cache --add already.\n\nI've also found it useful to start adding things to the Makefile's of\nthe projects I'm putting in git repositories. I think it would be useful\nto come up with some standard or recommended names. That could start to\nextend the common \"make\" \"make install\" with a few other options for\nprojects that use git as their SCM.\n\nThanks,\nJeff\n\npatch:\n\tgit-diff-files -p\n\npush:\n\tgit-send-pack `cat .git/branches/origin`\n\npull:\n\tgit-pull-script `cat .git/branches/origin`\n\tgit-read-tree -m HEAD\n\tgit-checkout-cache -q -f -u -a\n\ncommit:\n\tvi changelog.txt\n\tGIT_AUTHOR_NAME=\"$(GIT_AUTHOR_NAME)\" \\\n\tGIT_AUTHOR_EMAIL=\"$(GIT_AUTHOR_EMAIL)\" \\\n\tgit-commit-tree `git-write-tree` -p $(HEAD) < changelog.txt > .git/HEAD\n\trm changelog.txt\n\nadd_all:\n\t./git-ls-new-files |xargs -n 1 git-update-cache --add\n\n\n\n\n#!/usr/bin/perl\n\n# Shows you what files have not been added to your git repository\n\nmy %allfiles;\n\n# make a hash of all the files except the .git/ directory\n\nforeach my $file ( `find . -type f` ) {\n\tchomp $file;\n\tnext if substr($file, 0, 7) eq \"./.git/\";\n\t$allfiles{ $file } = \"\";\n}\n\n# now delete all the files from the hash that are already commited\n\nforeach my $file ( split \"\\n\", `git-ls-files` ) {\n\tchomp $file;\n\tdelete $allfiles{ \"./$file\" };\n}\n\n# print out what's left\n\nforeach my $file ( sort keys %allfiles ) {\n\tprint \"$file\\n\";\n}\n"},{"id":"7639","messageId":"7v1x4lz118.fsf@assigned-by-dhcp.cox.net","threadId":"1617","inReplyTo":"430A84D1.2050206@linuxmachines.com","subject":"Re: git-ls-new-files & make patch, pull, etc.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-08-23T05:15:47Z","receivedAt":"2005-08-23T05:15:47Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff Carr <jcarr@linuxmachines.com> writes:\n\n> Something simple like the perl script at the bottom would be useful for\n> showing files that haven't been added via git-update-cache --add already.\n\nIf I am not mistaken, you just reinvented:\n\n    $ git ls-files --others\n\nin a very expensive way.  Notice your `find . -type f` that does\nnot prune .git directory upfront.\n\nAlso you may want to take a look at:\n\n    $ git ls-files --others --exclude-from=.git/info/exclude\n"},{"id":"7643","messageId":"Pine.LNX.4.63.0508230846180.26600@wgmdd8.biozentrum.uni-wuerzburg.de","threadId":"1617","inReplyTo":"430A84D1.2050206@linuxmachines.com","subject":"Re: git-ls-new-files & make patch, pull, etc.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-08-23T06:48:26Z","receivedAt":"2005-08-23T06:48:26Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 22 Aug 2005, Jeff Carr wrote:\n\n> patch:\n> \tgit-diff-files -p\n\n\"git diff\"\n\n> push:\n> \tgit-send-pack `cat .git/branches/origin`\n\n\"git push origin\" (or maybe \"git push HEAD:origin\")\n\n> pull:\n> \tgit-pull-script `cat .git/branches/origin`\n> \tgit-read-tree -m HEAD\n> \tgit-checkout-cache -q -f -u -a\n\n\"git pull origin\"\n\n> commit:\n> \tvi changelog.txt\n> \tGIT_AUTHOR_NAME=\"$(GIT_AUTHOR_NAME)\" \\\n> \tGIT_AUTHOR_EMAIL=\"$(GIT_AUTHOR_EMAIL)\" \\\n> \tgit-commit-tree `git-write-tree` -p $(HEAD) < changelog.txt > .git/HEAD\n> \trm changelog.txt\n\n\"git commit\"\n\n> add_all:\n> \t./git-ls-new-files |xargs -n 1 git-update-cache --add\n\n\"git add $(git ls-files --others)\"\n\nCiao,\nDscho\n"},{"id":"8134","messageId":"431DE8A9.7010404@linuxmachines.com","threadId":"1617","inReplyTo":"Pine.LNX.4.63.0508230846180.26600@wgmdd8.biozentrum.uni-wuerzburg.de","subject":"Re: git-ls-new-files & make patch, pull, etc.","fromName":"Jeff Carr","fromEmail":"jcarr@linuxmachines.com","sentAt":"2005-09-06T19:06:17Z","receivedAt":"2005-09-06T19:06:17Z","isPatch":false,"sender":{"key":"jcarr@linuxmachines.com","avatar":null},"body":"On 08/22/2005 11:48 PM, Johannes Schindelin wrote:\n> \n>>patch:\n> \n> \"git diff\"\n> \n> \n>>push:\n> \n> \"git push origin\" (or maybe \"git push HEAD:origin\")\n> \n> \n>>pull:\n> \n> \"git pull origin\"\n> \n> \n>>commit:\n>>\tvi changelog.txt\n>>\tGIT_AUTHOR_NAME=\"$(GIT_AUTHOR_NAME)\" \\\n>>\tGIT_AUTHOR_EMAIL=\"$(GIT_AUTHOR_EMAIL)\" \\\n>>\tgit-commit-tree `git-write-tree` -p $(HEAD) < changelog.txt > .git/HEAD\n>>\trm changelog.txt\n> \n> \n> \"git commit\"\n\nWell, I did that by hand so at the end I could have it append the\nchanges to a changelog file in the archive itself.\n\n>>add_all:\n>>\t./git-ls-new-files |xargs -n 1 git-update-cache --add\n> \n> \n> \"git add $(git ls-files --others)\"\n\nI was using the version of git that was in debian sarge; it was too old\nand didn't do the commands. I've updated and everything is working now.\n\nThanks for the help!\nJeff\n"},{"id":"8140","messageId":"431DFF30.7010009@linuxmachines.com","threadId":"1617","inReplyTo":"7v1x4lz118.fsf@assigned-by-dhcp.cox.net","subject":"Re: git-ls-new-files & make patch, pull, etc.","fromName":"Jeff Carr","fromEmail":"jcarr@linuxmachines.com","sentAt":"2005-09-06T20:42:24Z","receivedAt":"2005-09-06T20:42:24Z","isPatch":false,"sender":{"key":"jcarr@linuxmachines.com","avatar":null},"body":"On 08/22/2005 10:15 PM, Junio C Hamano wrote:\n> Jeff Carr <jcarr@linuxmachines.com> writes:\n> \n> \n>>Something simple like the perl script at the bottom would be useful for\n>>showing files that haven't been added via git-update-cache --add already.\n> \n> \n> If I am not mistaken, you just reinvented:\n> \n>     $ git ls-files --others\n> \n> in a very expensive way.  Notice your `find . -type f` that does\n> not prune .git directory upfront.\n> \n> Also you may want to take a look at:\n> \n>     $ git ls-files --others --exclude-from=.git/info/exclude\n\nYes, you are right -- I did reinvent the above poorly :)\n\nI also was using a perl script to parse the output of git-whatchanged to\nset the datestamps on the files to the last modified time. If I remember\ncorrectly, there was some threads at the beginning of git about how\ndatestamps were not accurate so there was no point in setting them(?) Or\nmaybe I mis-understood. In any case, sometimes it is useful for me\nbecause I just want to look at what files I changed today or yesterday\nor something to that effect. Sometimes in the kernel/Documentation\ndirectories it is useful because you can see what documentation was\ndone/changed this year. Sometimes that's nice if you are looking for new\nthings you might not know much about; recently I was digging around in\nthe I2C stuff to try to figure out if I could read the right temperature\nsensor on the smbus on a machine. Anyway, I'll just use that but perhaps\nthere is also a \"correct\" way to keep timestamps?\n\nBTW, for what it's worth, you can't package git under debian sarge\nbecause asciidoc doesn't support \"-b xhtml11\". I pulled it from sid and\nit packaged it fine. Just an FYI. I emailed the asciidoc maintainer for\nwhat it's worth.\n\nThanks a lot,\nJeff\n"},{"id":"8142","messageId":"7virxdj45i.fsf@assigned-by-dhcp.cox.net","threadId":"1617","inReplyTo":"431DFF30.7010009@linuxmachines.com","subject":"Re: git-ls-new-files & make patch, pull, etc.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-09-06T21:08:09Z","receivedAt":"2005-09-06T21:08:09Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff Carr <jcarr@linuxmachines.com> writes:\n\n> ... If I remember\n> correctly, there was some threads at the beginning of git about how\n> datestamps were not accurate so there was no point in setting them(?) Or\n> maybe I mis-understood.\n\nThe point of those thread was that clocks on machines tend to be\nnot so accurate and we should not take the timestamps *too*\nseriously.  We do record the time as accurately as the clock is\nmaintained on the machine the commit is made, provided if the\nuser does not override it with the GIT_COMMIT_DATE environment\nvariable with a bogus value.\n\nThe way you use it to show changes made in a certain timeperiod\nis a good example that the information is useful.  The argument\nagainst relying on timestamp too much in that thread you are\nremembering was that it should not be used to see which commit\ncame before which other commit when there is no parent-child\nancestry between them.  It is still a useful hint, and we do use\nit as such, but as the recent merge-base fixes show it is just a\nhint and relying on it too much tends to screw things up.\n"},{"id":"8220","messageId":"4320B8D7.7070004@linuxmachines.com","threadId":"1617","inReplyTo":"7virxdj45i.fsf@assigned-by-dhcp.cox.net","subject":"Re: git-ls-new-files & make patch, pull, etc.","fromName":"Jeff Carr","fromEmail":"jcarr@linuxmachines.com","sentAt":"2005-09-08T22:19:03Z","receivedAt":"2005-09-08T22:19:03Z","isPatch":false,"sender":{"key":"jcarr@linuxmachines.com","avatar":null},"body":"On 09/06/2005 02:08 PM, Junio C Hamano wrote:\n> Jeff Carr <jcarr@linuxmachines.com> writes:\n> \n> \n>>... If I remember\n>>correctly, there was some threads at the beginning of git about how\n>>datestamps were not accurate so there was no point in setting them(?) Or\n>>maybe I mis-understood.\n> \n> \n> The point of those thread was that clocks on machines tend to be\n> not so accurate and we should not take the timestamps *too*\n> seriously.  We do record the time as accurately as the clock is\n> maintained on the machine the commit is made, provided if the\n> user does not override it with the GIT_COMMIT_DATE environment\n> variable with a bogus value.\n> \n> The way you use it to show changes made in a certain timeperiod\n> is a good example that the information is useful.  The argument\n> against relying on timestamp too much in that thread you are\n> remembering was that it should not be used to see which commit\n> came before which other commit when there is no parent-child\n> ancestry between them.  It is still a useful hint, and we do use\n> it as such, but as the recent merge-base fixes show it is just a\n> hint and relying on it too much tends to screw things up.\n\n\nOK, I understand better now. I was just setting the mtime via the last\ntime the file showed up in the git-whatchanged output. When I check out\na repository I do:\n\ngit-read-tree -m HEAD && git-checkout-cache -q -f -u -a\ngit-restore-mtime\n\nThis is probably also a really bad reimplementation of something. :)\n\nAll and all, really enjoying using git. It's better.\nJeff\n\n\n#!/usr/bin/perl\n# parses git-whatchanged output and then\n# sets the mtime for all the files  # copyleft GPL\n\nuse strict;\nuse HTTP::Date;\n\n# my $string = time2str($time);    # Format as GMT ASCII time\n# my $now = str2time($string);    # convert ASCII date to machine time\n\nmy $oldest = localtime();\nmy %allfiles;\nmy $time;\n\n# make a hash of all the files \nforeach my $file ( split \"\\n\", `git-ls-files` ) {\n\tchomp $file;\n\t$allfiles{ $file } = 0;\n}\n\n# get the newest mtime for each one\nforeach my $line ( `git-whatchanged` ) {\n\tchomp $line;\n\tmy @parts = split \" \", $line;\n\tif( $parts[0] eq \"Date:\" ) {\n\t\tshift @parts;\n\t\tpop @parts;\n\t\t$time = str2time( join \" \", @parts );\n\t\tnext;\n\t}\n\tif( $line =~ /^:/ ) {\n\t\tmy $name = pop @parts;\n\t\tif( $allfiles{ $name } lt $time ) {\n\t\t\t# print \"$name was $allfiles{ $name } now: $time\\n\";\n\t\t\t$allfiles{ $name } = $time;\n\t\t}\n\t\tif( $time lt $oldest ) {\n\t\t\t$oldest = $time;\n\t\t}\n\t}\n}\n\n# set the mtime for each one\nforeach my $name ( sort keys %allfiles ) {\n\tif ( $allfiles{$name} eq 0 ) {\n\t\t# print \"$name mtime $allfiles{$name}\\n\";\n\t\tutime $oldest, $oldest, $name;\n\t} else {\n\t\t# print \"$name mtime $allfiles{$name}\\n\";\n\t\tutime $allfiles{$name}, $allfiles{$name}, $name;\n\t}\n}\n\n"},{"id":"8227","messageId":"7v64tbrkq5.fsf@assigned-by-dhcp.cox.net","threadId":"1617","inReplyTo":"4320B8D7.7070004@linuxmachines.com","subject":"Re: git-ls-new-files & make patch, pull, etc.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-09-09T03:19:46Z","receivedAt":"2005-09-09T03:19:46Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"In my opinion, setting the file timestamp to the commit time (or\nany other time other than the time of checkout) tends to screw\nyou up more than help you.\n\nSuppose you have the latest checked out in your working tree,\nyou build and test, and find regressions.  You'd want to check\nout from an older commit, rebuild and make sure things used to\nwork correctly.  If the checkout used the timestamp of the older\ncommit, however, all the things you built from the latest would\nhave timestamps newer than the source, so you would end up\nalways having to run \"make clean\" before rebuilding.\n"}]}