From 7fc2d82c74c2476310e4577cda8c9c567f437edb Mon Sep 17 00:00:00 2001 From: idl0r Date: Sat, 9 May 2009 18:47:54 +0000 Subject: [PATCH] Ignore .git dir when running echangelog in the repository root, fixes bug 199805 c8,c13. Improved git_unknown_objects(), git status parsing improved. Thanks to Andrew Gaffney for testing etc. svn path=/trunk/gentoolkit-dev/; revision=637 --- src/echangelog/echangelog | 51 ++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/src/echangelog/echangelog b/src/echangelog/echangelog index 4315acf..e288650 100755 --- a/src/echangelog/echangelog +++ b/src/echangelog/echangelog @@ -271,49 +271,44 @@ while () { 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 =

; - $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 () { - $_ = ; - push @unknown, $object; - }; + open(C, '-|', "${vcs} status ${object} 2>&1 1>/dev/null"); + push(@unknown, $object) if defined(); + 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 -- 2.26.2