Ignore .git dir when running echangelog in the repository root, fixes bug 199805...
authoridl0r <idl0r@gentoo.org>
Sat, 9 May 2009 18:47:54 +0000 (18:47 -0000)
committeridl0r <idl0r@gentoo.org>
Sat, 9 May 2009 18:47:54 +0000 (18:47 -0000)
svn path=/trunk/gentoolkit-dev/; revision=637

src/echangelog/echangelog

index 4315acf4d11b46e7e96642440c29a571c8b7e98c..e2886508178095a682d9f31a62d801b2e3010691 100755 (executable)
@@ -271,49 +271,44 @@ while (<C>) {
                my ($status, $filename) = ($1,$2);
 
                if($vcs eq "git") {
-                       open P, "git rev-parse --sq --show-prefix |";
+                       open(P, '-|', "git rev-parse --sq --show-prefix");
                        my $prefix = <P>;
-                       $prefix = substr($prefix, 0, -1);
-                       close P;
+                       close(P);
 
-                       if ($filename =~ /$prefix(\S*)/) {
-                               $filename = $1 ;
-                       }
-                       else {
-                               next;
+                       if (defined($prefix)) {
+                               chomp($prefix);
+
+                               if ($filename =~ /$prefix(\S*)/) {
+                                       $filename = $1 ;
+                               }
+                               else {
+                                       next;
+                               }
                        }
                }
 
-               if( -d $filename ) {
-                       next;
-               }
+               next if -d $filename;
 
-               push @files, $filename;
+               push(@files, $filename);
                ($actions{$filename} = $status) =~ tr/DARM/-+-/d;
        }
 }
 
-# git only shows files already added so we need to check for unknown files
-# separately here.
-if($vcs eq "git") {
-       find(\&git_unknown_objects, "./");
-}
-
 sub git_unknown_objects {
        my $object = $_;
-       my ($dev,$ino,$mode,$nlink,$uid,$gid);
 
-       # Ignore empty directories - git doesn't version them and cvs removes them.
-       if ( (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) && ! -d _ ) {
-               open C, $vcs." status $_ 2>&1 1>/dev/null |";
+       return if -d $object;
+       return if $File::Find::dir =~ m/^\.\/\.git\/?/;
 
-               while (<C>) {
-                       $_ = <C>;
-                       push @unknown, $object;
-               };
+       open(C, '-|', "${vcs} status ${object} 2>&1 1>/dev/null");
+       push(@unknown, $object) if defined(<C>);
+       close(C);
+}
 
-               close C;
-       };
+# git only shows files already added so we need to check for unknown files
+# separately here.
+if($vcs eq "git") {
+       find(\&git_unknown_objects, "./");
 }
 
 # Separate out the trivial files for now