git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add git-find-new-files to spot files added to the tree, but not the repository
@ 2005-07-23  7:42 Ryan Anderson
  2005-07-23 17:43 ` Linus Torvalds
  2005-07-23 20:44 ` Junio C Hamano
  0 siblings, 2 replies; 5+ messages in thread
From: Ryan Anderson @ 2005-07-23  7:42 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git

Add git-find-new-files to find files that are in the tree, but not checked into the repository.

Most users will probably want to "make clean" before using this for real
significant changes, as it does such a good job that it finds binaries that
just got built.

Signed-off-by: Ryan Anderson <ryan@michonline.com>
---

 Makefile           |    2 +-
 git-find-new-files |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 1 deletions(-)
 create mode 100755 git-find-new-files

028b21ae78dba3edab5e9b1a24cdf68011e42ab7
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -36,7 +36,7 @@ SCRIPTS=git git-apply-patch-script git-m
 	git-reset-script git-add-script git-checkout-script git-clone-script \
 	gitk git-cherry git-rebase-script git-relink-script git-repack-script \
 	git-format-patch-script git-sh-setup-script git-push-script \
-	git-branch-script git-parse-remote
+	git-branch-script git-parse-remote git-find-new-files
 
 PROG=   git-update-cache git-diff-files git-init-db git-write-tree \
 	git-read-tree git-commit-tree git-cat-file git-fsck-cache \
diff --git a/git-find-new-files b/git-find-new-files
new file mode 100755
--- /dev/null
+++ b/git-find-new-files
@@ -0,0 +1,48 @@
+#!/usr/bin/perl
+#
+# A simple script to take a look at all the files git knows about and compare
+# that to the files that we actually see in teh source tree, and output a
+# listing of the difference between them.
+#
+# The original command that did this is below, but a pure-Perl version can skip
+# the temp files.
+#
+#	find . -name .git -type d -prune -o -type f -print \
+#		| grep -v -e .tree1 -e .tree2 \
+#		| sed -e "s/^\.\///" \
+#		| sort >.tree1
+#	git-ls-files | grep -v -e .tree1 -e .tree2 \
+#		| sort >.tree2
+#	diff -u .tree1 .tree2
+
+use warnings;
+use strict;
+
+# Since we're using NUL (ASCII value of 0) to terminate strings,
+# set the field separator to that:
+$/ = "\0";
+
+my (%actual,%git);
+
+open(F,"-|","find . -name .git -type d -prune -o -type f -print0")
+	or die "Failed to open pipe from find: " . $!;
+
+while(<F>) {
+	chomp;
+	s#^\./##;
+	$actual{$_}++;
+}
+close(F);
+
+open(F,"-|","git-ls-files -z")
+	or die "Failed to open pipe from git-ls-files: " . $!;
+
+while(<F>) {
+	chomp;
+	delete $actual{$_};
+}
+close(F);
+
+foreach my $f (sort keys %actual) {
+	printf("A\t%s\n",$f);
+}
-- 

Ryan Anderson
  sometimes Pug Majere

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-07-25  6:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-23  7:42 [PATCH] Add git-find-new-files to spot files added to the tree, but not the repository Ryan Anderson
2005-07-23 17:43 ` Linus Torvalds
2005-07-23 17:48   ` Linus Torvalds
2005-07-25  6:00     ` Ryan Anderson
2005-07-23 20:44 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).