From: idl0r Date: Sat, 9 May 2009 18:47:54 +0000 (-0000) Subject: Ignore .git dir when running echangelog in the repository root, fixes bug 199805... X-Git-Tag: gentoolkit-dev-0.2.6.12~5 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7fc2d82c74c2476310e4577cda8c9c567f437edb;p=gentoolkit.git 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 --- 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