{"thread":{"id":"1318","subject":"[PATCH] Add git-find-new-files to spot files added to the tree, but not the repository","startedAt":"2005-07-23T07:42:19Z","lastAt":"2005-07-25T06:00:30Z","messageCount":5,"participants":["Ryan Anderson","Linus Torvalds","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"6370","messageId":"20050723074219.GB3255@mythryan2.michonline.com","threadId":"1318","inReplyTo":null,"subject":"[PATCH] Add git-find-new-files to spot files added to the tree, but not the repository","fromName":"Ryan Anderson","fromEmail":"ryan@michonline.com","sentAt":"2005-07-23T07:42:19Z","receivedAt":"2005-07-23T07:42:19Z","isPatch":true,"sender":{"key":"ryan@michonline.com","avatar":null},"body":"Add git-find-new-files to find files that are in the tree, but not checked into the repository.\n\nMost users will probably want to \"make clean\" before using this for real\nsignificant changes, as it does such a good job that it finds binaries that\njust got built.\n\nSigned-off-by: Ryan Anderson <ryan@michonline.com>\n---\n\n Makefile           |    2 +-\n git-find-new-files |   48 ++++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 49 insertions(+), 1 deletions(-)\n create mode 100755 git-find-new-files\n\n028b21ae78dba3edab5e9b1a24cdf68011e42ab7\ndiff --git a/Makefile b/Makefile\n--- a/Makefile\n+++ b/Makefile\n@@ -36,7 +36,7 @@ SCRIPTS=git git-apply-patch-script git-m\n \tgit-reset-script git-add-script git-checkout-script git-clone-script \\\n \tgitk git-cherry git-rebase-script git-relink-script git-repack-script \\\n \tgit-format-patch-script git-sh-setup-script git-push-script \\\n-\tgit-branch-script git-parse-remote\n+\tgit-branch-script git-parse-remote git-find-new-files\n \n PROG=   git-update-cache git-diff-files git-init-db git-write-tree \\\n \tgit-read-tree git-commit-tree git-cat-file git-fsck-cache \\\ndiff --git a/git-find-new-files b/git-find-new-files\nnew file mode 100755\n--- /dev/null\n+++ b/git-find-new-files\n@@ -0,0 +1,48 @@\n+#!/usr/bin/perl\n+#\n+# A simple script to take a look at all the files git knows about and compare\n+# that to the files that we actually see in teh source tree, and output a\n+# listing of the difference between them.\n+#\n+# The original command that did this is below, but a pure-Perl version can skip\n+# the temp files.\n+#\n+#\tfind . -name .git -type d -prune -o -type f -print \\\n+#\t\t| grep -v -e .tree1 -e .tree2 \\\n+#\t\t| sed -e \"s/^\\.\\///\" \\\n+#\t\t| sort >.tree1\n+#\tgit-ls-files | grep -v -e .tree1 -e .tree2 \\\n+#\t\t| sort >.tree2\n+#\tdiff -u .tree1 .tree2\n+\n+use warnings;\n+use strict;\n+\n+# Since we're using NUL (ASCII value of 0) to terminate strings,\n+# set the field separator to that:\n+$/ = \"\\0\";\n+\n+my (%actual,%git);\n+\n+open(F,\"-|\",\"find . -name .git -type d -prune -o -type f -print0\")\n+\tor die \"Failed to open pipe from find: \" . $!;\n+\n+while(<F>) {\n+\tchomp;\n+\ts#^\\./##;\n+\t$actual{$_}++;\n+}\n+close(F);\n+\n+open(F,\"-|\",\"git-ls-files -z\")\n+\tor die \"Failed to open pipe from git-ls-files: \" . $!;\n+\n+while(<F>) {\n+\tchomp;\n+\tdelete $actual{$_};\n+}\n+close(F);\n+\n+foreach my $f (sort keys %actual) {\n+\tprintf(\"A\\t%s\\n\",$f);\n+}\n-- \n\nRyan Anderson\n  sometimes Pug Majere\n"},{"id":"6389","messageId":"Pine.LNX.4.58.0507231039290.6074@g5.osdl.org","threadId":"1318","inReplyTo":"20050723074219.GB3255@mythryan2.michonline.com","subject":"Re: [PATCH] Add git-find-new-files to spot files added to the tree, but not the repository","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-07-23T17:43:23Z","receivedAt":"2005-07-23T17:43:23Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sat, 23 Jul 2005, Ryan Anderson wrote:\n>\n> Add git-find-new-files to find files that are in the tree, but not checked into the repository.\n> \n> Most users will probably want to \"make clean\" before using this for real\n> significant changes, as it does such a good job that it finds binaries that\n> just got built.\n\nYou really want to run \"file\" on the files. We almost certainly don't want \nto add binary executables, object files etc etc to the tree, so why even \nshow them?\n\nYou should also filter the list by the \"ignore\" file. And I'd suggest\nignoring dot-files by default, for example (maybe add a \"-a\" flag to \ndisable that, the same way \"ls\" does).\n\n\t\tLinus\n"},{"id":"6390","messageId":"Pine.LNX.4.58.0507231043330.6074@g5.osdl.org","threadId":"1318","inReplyTo":"Pine.LNX.4.58.0507231039290.6074@g5.osdl.org","subject":"Re: [PATCH] Add git-find-new-files to spot files added to the tree, but not the repository","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-07-23T17:48:39Z","receivedAt":"2005-07-23T17:48:39Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sat, 23 Jul 2005, Linus Torvalds wrote:\n\n> \n> \n> On Sat, 23 Jul 2005, Ryan Anderson wrote:\n> >\n> > Add git-find-new-files to find files that are in the tree, but not checked into the repository.\n> > \n> > Most users will probably want to \"make clean\" before using this for real\n> > significant changes, as it does such a good job that it finds binaries that\n> > just got built.\n> \n> You really want to run \"file\" on the files. We almost certainly don't want \n> to add binary executables, object files etc etc to the tree, so why even \n> show them?\n> \n> You should also filter the list by the \"ignore\" file. And I'd suggest\n> ignoring dot-files by default, for example (maybe add a \"-a\" flag to \n> disable that, the same way \"ls\" does).\n\nOh, and btw, maybe you didn't realize that \"git-ls-files --others\" already \nbasically does what your script does? Without any filtering - it was meant \nto be run from a script, so something like\n\n\tfor i in $(git-ls-files --others)\n\tdo\n\t\tif [ ! match_ignore \"$i\" ]; then\n\t\t\tcase $(file -b $i)\n\t\t\tELF*)\n\t\t\t\t;;\n\t\t\t*)\n\t\t\t\techo $i\n\t\t\t\t;;\n\t\t\tesac\n\t\tfi\n\tdone\n\nwas what I was thinking of.\n\n\t\tLinus\n"},{"id":"6393","messageId":"7vsly5qmkd.fsf@assigned-by-dhcp.cox.net","threadId":"1318","inReplyTo":"20050723074219.GB3255@mythryan2.michonline.com","subject":"Re: [PATCH] Add git-find-new-files to spot files added to the tree, but not the repository","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-07-23T20:44:50Z","receivedAt":"2005-07-23T20:44:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ryan Anderson <ryan@michonline.com> writes:\n\n> Add git-find-new-files to find files that are in the tree, but\n> not checked into the repository.\n\nYou _ought_ to be able to just say:\n\n $ git-ls-files --others --exclude-from=<exclude pattern file>\n\nand be done with it.  Also please see the thread about Cogito\nand StGIT's use of .gitignore and .git/exclude files.\n\nThe current implementation of \"git-ls-files\" exclude mechanism\nmay have rooms for improvements; the last time I checked, it\nonly did the matching of patterns against filename without\nleading directories).  The world will be a better place if\nsomebody extends it, instead of working around its limitation.\n\nI may be tempted to doing it myself, but I'm in the middle of\nsomething else, so ...\n\n> +#\tfind . -name .git -type d -prune -o -type f -print \\\n> +#\t\t| grep -v -e .tree1 -e .tree2 \\\n> +#\t\t| sed -e \"s/^\\.\\///\" \\\n> +#\t\t| sort >.tree1\n> +#\tgit-ls-files | grep -v -e .tree1 -e .tree2 \\\n> +#\t\t| sort >.tree2\n> +#\tdiff -u .tree1 .tree2\n\nIt does not matter since the above is just an example and I\nthink you should be able to just use \"ls-files --others\", but\njust FYI, you could have written \"comm -23 .tree1 .tree2\" above\ninstead of \"diff -u\".\n"},{"id":"6420","messageId":"20050725060029.GC6098@mythryan2.michonline.com","threadId":"1318","inReplyTo":"Pine.LNX.4.58.0507231043330.6074@g5.osdl.org","subject":"Re: [PATCH] Add git-find-new-files to spot files added to the tree, but not the repository","fromName":"Ryan Anderson","fromEmail":"ryan@michonline.com","sentAt":"2005-07-25T06:00:30Z","receivedAt":"2005-07-25T06:00:30Z","isPatch":true,"sender":{"key":"ryan@michonline.com","avatar":null},"body":"On Sat, Jul 23, 2005 at 10:48:39AM -0700, Linus Torvalds wrote:\n> \n> Oh, and btw, maybe you didn't realize that \"git-ls-files --others\" already \n> basically does what your script does? Without any filtering - it was meant \n> to be run from a script, so something like\n\nThat's exactly what I was missing.\n\nThe usage on a lot of the commands is very, well, \"terse\".\n\nI totally missed \"others\" and I'm not sure I would have caught the\nsignificance right away, anyway.\n\nI was going to start a patch series to pull the man pages into each\nprogram - but then I just decided it'd be easier to install the man\npages.\n\n-- \n\nRyan Anderson\n  sometimes Pug Majere\n"}]}