@matheusbsbs / matheus-bagliano / commits / 8f22562c6b
Fork 0

contrib/git-svn: add show-ignore command

Recursively finds and lists the svn:ignore property on directories. The output is suitable for appending to the $GIT_DIR/info/exclude file. Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <junkio@cox.net>

Eric Wong committed Feb 26, 2006 at 02:22 UTC 8f22562c6bfa413c621517dd654b58ed39e98045
2 files changed +32
contrib/git-svn/git-svn.perl
+25
@@ -49,6 +49,7 @@ my %cmd = (
49 fetch => [ \&fetch, "Download new revisions from SVN" ],
50 init => [ \&init, "Initialize and fetch (import)"],
51 commit => [ \&commit, "Commit git revisions to SVN" ],
52 + 'show-ignore' => [ \&show_ignore, "Show svn:ignore listings" ],
53 rebuild => [ \&rebuild, "Rebuild git-svn metadata (after git clone)" ],
54 help => [ \&usage, "Show help" ],
55 );
@@ -258,6 +259,30 @@ sub commit {
259
260 }
261
262 +sub show_ignore {
263 + require File::Find or die $!;
264 + my $exclude_file = "$GIT_DIR/info/exclude";
265 + open my $fh, '<', $exclude_file or croak $!;
266 + chomp(my @excludes = (<$fh>));
267 + close $fh or croak $!;
268 +
269 + $SVN_URL ||= file_to_s("$GIT_DIR/$GIT_SVN/info/url");
270 + chdir $SVN_WC or croak $!;
271 + my %ign;
272 + File::Find::find({wanted=>sub{if(lstat $_ && -d _ && -d "$_/.svn"){
273 + s#^\./##;
274 + @{$ign{$_}} = safe_qx(qw(svn propget svn:ignore),$_);
275 + }}, no_chdir=>1},'.');
276 +
277 + print "\n# /\n";
278 + foreach (@{$ign{'.'}}) { print '/',$_ if /\S/ }
279 + delete $ign{'.'};
280 + foreach my $i (sort keys %ign) {
281 + print "\n# ",$i,"\n";
282 + foreach (@{$ign{$i}}) { print '/',$i,'/',$_ if /\S/ }
283 + }
284 +}
285 +
286 ########################### utility functions #########################
287
288 sub setup_git_svn {
contrib/git-svn/git-svn.txt
+7
@@ -61,6 +61,11 @@ rebuild::
61 the directory/repository you're tracking has moved or changed
62 protocols.
63
64 +show-ignore::
65 + Recursively finds and lists the svn:ignore property on
66 + directories. The output is suitable for appending to
67 + the $GIT_DIR/info/exclude file.
68 +
69 OPTIONS
70 -------
71 -r <ARG>::
@@ -152,6 +157,8 @@ Tracking and contributing to an Subversion managed-project:
157 git commit git-svn-HEAD..my-branch
158 # Something is committed to SVN, pull the latest into your branch::
159 git-svn fetch && git pull . git-svn-HEAD
160 +# Append svn:ignore settings to the default git exclude file:
161 + git-svn show-ignore >> .git/info/exclude
162
163 DESIGN PHILOSOPHY
164 -----------------