Skip to content

Commit d97956b

Browse files
committed
Merge branch 'ag/git-svn-global-ignores'
"git svn" has been taught about svn:global-ignores property recent versions of Subversion has. * ag/git-svn-global-ignores: git-svn: mention `svn:global-ignores` in help+docs git-svn: use `svn:global-ignores` to create .gitignore git-svn: add public property `svn:global-ignores`
2 parents 80ccd8a + be9bd46 commit d97956b

File tree

3 files changed

+42
-25
lines changed

3 files changed

+42
-25
lines changed

Documentation/git-svn.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -431,14 +431,14 @@ Any other arguments are passed directly to 'git log'
431431
independently of 'git svn' functions.
432432

433433
'create-ignore'::
434-
Recursively finds the svn:ignore property on directories and
435-
creates matching .gitignore files. The resulting files are staged to
436-
be committed, but are not committed. Use -r/--revision to refer to a
437-
specific revision.
434+
Recursively finds the svn:ignore and svn:global-ignores properties
435+
on directories and creates matching .gitignore files. The resulting
436+
files are staged to be committed, but are not committed. Use
437+
-r/--revision to refer to a specific revision.
438438

439439
'show-ignore'::
440-
Recursively finds and lists the svn:ignore property on
441-
directories. The output is suitable for appending to
440+
Recursively finds and lists the svn:ignore and svn:global-ignores
441+
properties on directories. The output is suitable for appending to
442442
the $GIT_DIR/info/exclude file.
443443

444444
'mkdirs'::
@@ -871,7 +871,7 @@ Tracking and contributing to the trunk of a Subversion-managed project
871871
# Now commit your changes (that were committed previously using Git) to SVN,
872872
# as well as automatically updating your working HEAD:
873873
git svn dcommit
874-
# Append svn:ignore settings to the default Git exclude file:
874+
# Append svn:ignore and svn:global-ignores settings to the default Git exclude file:
875875
git svn show-ignore >> .git/info/exclude
876876
------------------------------------------------------------------------
877877

git-svn.perl

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,11 @@ sub _req_svn {
219219
"Set an SVN repository to a git tree-ish",
220220
{ 'stdin' => \$_stdin, %cmt_opts, %fc_opts, } ],
221221
'create-ignore' => [ \&cmd_create_ignore,
222-
'Create a .gitignore per svn:ignore',
222+
"Create a .gitignore per directory with SVN ignore properties",
223223
{ 'revision|r=i' => \$_revision
224224
} ],
225225
'mkdirs' => [ \&cmd_mkdirs ,
226-
"recreate empty directories after a checkout",
226+
"Recreate empty directories after a checkout",
227227
{ 'revision|r=i' => \$_revision } ],
228228
'propget' => [ \&cmd_propget,
229229
'Print the value of a property on a file or directory',
@@ -234,7 +234,7 @@ sub _req_svn {
234234
'proplist' => [ \&cmd_proplist,
235235
'List all properties of a file or directory',
236236
{ 'revision|r=i' => \$_revision } ],
237-
'show-ignore' => [ \&cmd_show_ignore, "Show svn:ignore listings",
237+
'show-ignore' => [ \&cmd_show_ignore, "Show .gitignore patterns from SVN ignore properties",
238238
{ 'revision|r=i' => \$_revision
239239
} ],
240240
'show-externals' => [ \&cmd_show_externals, "Show svn:externals listings",
@@ -1279,12 +1279,20 @@ sub cmd_show_ignore {
12791279
$gs->prop_walk($gs->path, $r, sub {
12801280
my ($gs, $path, $props) = @_;
12811281
print STDOUT "\n# $path\n";
1282-
my $s = $props->{'svn:ignore'} or return;
1283-
$s =~ s/[\r\n]+/\n/g;
1284-
$s =~ s/^\n+//;
1285-
chomp $s;
1286-
$s =~ s#^#$path#gm;
1287-
print STDOUT "$s\n";
1282+
if (my $s = $props->{'svn:ignore'}) {
1283+
$s =~ s/[\r\n]+/\n/g;
1284+
$s =~ s/^\n+//;
1285+
chomp $s;
1286+
$s =~ s#^#$path#gm;
1287+
print STDOUT "$s\n";
1288+
}
1289+
if (my $s = $props->{'svn:global-ignores'}) {
1290+
$s =~ s/[\r\n]+/\n/g;
1291+
$s =~ s/^\n+//;
1292+
chomp $s;
1293+
$s =~ s#^#$path**/#gm;
1294+
print STDOUT "$s\n";
1295+
}
12881296
});
12891297
}
12901298

@@ -1315,16 +1323,25 @@ sub cmd_create_ignore {
13151323
# which git won't track
13161324
mkpath([$path]) unless -d $path;
13171325
my $ignore = $path . '.gitignore';
1318-
my $s = $props->{'svn:ignore'} or return;
13191326
open(GITIGNORE, '>', $ignore)
13201327
or fatal("Failed to open `$ignore' for writing: $!");
1321-
$s =~ s/[\r\n]+/\n/g;
1322-
$s =~ s/^\n+//;
1323-
chomp $s;
1324-
# Prefix all patterns so that the ignore doesn't apply
1325-
# to sub-directories.
1326-
$s =~ s#^#/#gm;
1327-
print GITIGNORE "$s\n";
1328+
if (my $s = $props->{'svn:ignore'}) {
1329+
$s =~ s/[\r\n]+/\n/g;
1330+
$s =~ s/^\n+//;
1331+
chomp $s;
1332+
# Prefix all patterns so that the ignore doesn't apply
1333+
# to sub-directories.
1334+
$s =~ s#^#/#gm;
1335+
print GITIGNORE "$s\n";
1336+
}
1337+
if (my $s = $props->{'svn:global-ignores'}) {
1338+
$s =~ s/[\r\n]+/\n/g;
1339+
$s =~ s/^\n+//;
1340+
chomp $s;
1341+
# Global ignores apply to sub-directories, so they are
1342+
# not prefixed.
1343+
print GITIGNORE "$s\n";
1344+
}
13281345
close(GITIGNORE)
13291346
or fatal("Failed to close `$ignore': $!");
13301347
command_noisy('add', '-f', $ignore);

perl/Git/SVN.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ sub prop_walk {
763763
# this needs to be updated.
764764
++$interesting_props if /^svn:(?:ignore|keywords|executable
765765
|eol-style|mime-type
766-
|externals|needs-lock)$/x;
766+
|externals|needs-lock|global-ignores)$/x;
767767
}
768768
&$sub($self, $p, $props) if $interesting_props;
769769

0 commit comments

Comments
 (0)