Skip to contentSkip to conversation

git-svn: use svn:global-ignores when creating .gitignores

PATCH Superseded Alex Galvin via GitGitGadget 3 participants 13 messages Jul 17, 2024 – Aug 12, 2024

lore
Share & tools
lore
#0 lore raw

cover git-svn: use svn:global-ignores when creating .gitignores

Git-SVN does not currently use the svn:global-ignores property added in Subversion 1.8 when showing or creating .gitignore files. This causes Git-SVN to track files that are ignored by this directive in Subversion.

The following patches add svn:global-ignores to the list of public svn properties, and update git svn show-ignore and git svn create-ignore to use this attribute (as well as svn:ignore).

Alex Galvin (2):
git-svn: add public property svn:global-ignores
git-svn: use svn:global-ignores to create .gitignore

 git-svn.perl    | 45 +++++++++++++++++++++++++++++++--------------
 perl/Git/SVN.pm |  2 +-
 2 files changed, 32 insertions(+), 15 deletions(-)

base-commit: c2b3f2b3cdbf5ad9feb978dd367d77561a1271f7
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1747%2Fav-gal%2Fgit-svn-global-ignores-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1747/av-gal/git-svn-global-ignores-v1
Pull-Request: https://github.com/git/git/pull/1747

Signature · 1 line
gitgitgadget
#1 lore raw

PATCH 1/2 git-svn: add public property `svn:global-ignores`

From: Alex Galvin <[email protected]>

---
 perl/Git/SVN.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
perl/Git/SVN.pm +1 -1
index 7721708ce5d..b0913ca1b63 100644
@@ -763,7 +763,7 @@ sub prop_walk {
 		# this needs to be updated.
 		++$interesting_props if /^svn:(?:ignore|keywords|executable
 		                                 |eol-style|mime-type
-						 |externals|needs-lock)$/x;
+						 |externals|needs-lock|global-ignores)$/x;
 	}
 	&$sub($self, $p, $props) if $interesting_props;
 
Signature · 1 line
gitgitgadget
#2 lore raw

PATCH 2/2 git-svn: use `svn:global-ignores` to create .gitignore

In reply to Alex Galvin via GitGitGadget

From: Alex Galvin <[email protected]>

---
 git-svn.perl | 45 +++++++++++++++++++++++++++++++--------------
 1 file changed, 31 insertions(+), 14 deletions(-)
git-svn.perl +31 -14
index b0d0a50984b..a2a46608c9b 100755
@@ -1279,12 +1279,20 @@ sub cmd_show_ignore {
 	$gs->prop_walk($gs->path, $r, sub {
 		my ($gs, $path, $props) = @_;
 		print STDOUT "\n# $path\n";
-		my $s = $props->{'svn:ignore'} or return;
-		$s =~ s/[\r\n]+/\n/g;
-		$s =~ s/^\n+//;
-		chomp $s;
-		$s =~ s#^#$path#gm;
-		print STDOUT "$s\n";
+		if (my $s = $props->{'svn:ignore'}) {
+			$s =~ s/[\r\n]+/\n/g;
+			$s =~ s/^\n+//;
+			chomp $s;
+			$s =~ s#^#$path#gm;
+			print STDOUT "$s\n";
+		}
+		if (my $s = $props->{'svn:global-ignores'}) {
+			$s =~ s/[\r\n]+/\n/g;
+			$s =~ s/^\n+//;
+			chomp $s;
+			$s =~ s#^#$path**/#gm;
+			print STDOUT "$s\n";
+		}
 	});
 }
 
@@ -1315,16 +1323,25 @@ sub cmd_create_ignore {
 		# which git won't track
 		mkpath([$path]) unless -d $path;
 		my $ignore = $path . '.gitignore';
-		my $s = $props->{'svn:ignore'} or return;
 		open(GITIGNORE, '>', $ignore)
 		  or fatal("Failed to open `$ignore' for writing: $!");
-		$s =~ s/[\r\n]+/\n/g;
-		$s =~ s/^\n+//;
-		chomp $s;
-		# Prefix all patterns so that the ignore doesn't apply
-		# to sub-directories.
-		$s =~ s#^#/#gm;
-		print GITIGNORE "$s\n";
+		if (my $s = $props->{'svn:ignore'}) {
+			$s =~ s/[\r\n]+/\n/g;
+			$s =~ s/^\n+//;
+			chomp $s;
+			# Prefix all patterns so that the ignore doesn't apply
+			# to sub-directories.
+			$s =~ s#^#/#gm;
+			print GITIGNORE "$s\n";
+		}
+		if (my $s = $props->{'svn:global-ignores'}) {
+			$s =~ s/[\r\n]+/\n/g;
+			$s =~ s/^\n+//;
+			chomp $s;
+			# Global ignores apply to sub-directories, so they are
+			# not prefixed.
+			print GITIGNORE "$s\n";
+		}
 		close(GITIGNORE)
 		  or fatal("Failed to close `$ignore': $!");
 		command_noisy('add', '-f', $ignore);
Signature · 1 line
gitgitgadget
#3 lore raw
In reply to Alex Galvin via GitGitGadget
Quoted 3 lines · Alex Galvin via GitGitGadget

Git-SVN does not currently use the svn:global-ignores property added in Subversion 1.8 when showing or creating .gitignore files. This causes Git-SVN to track files that are ignored by this directive in Subversion.

That is a well written explanation of what issue the patches want to address.

Quoted 3 lines

The following patches add svn:global-ignores to the list of public svn properties, and update git svn show-ignore and git svn create-ignore to use this attribute (as well as svn:ignore).

Paying attention to the new property and get it reflected to .gitignore on Git side may be a reasonable solution, especially if we ignore older version of Subversion. But I have a naïve question. If a new version of git-svn starts to rely on the new property that is only available in SVN 1.8, would it create problems with folks whose SVN installation does not understand it? Would it cause problems to them?

Anyway, in this project, explanation of the problem the patches address, with the outline of the solution, should be in the proposed commit log message of the patches themselves, not just written in the cover letter. Can you redo the proposed log messages of these two patches, where you have none in this iteration?

Thanks.

Quoted 13 lines

Alex Galvin (2):
git-svn: add public property svn:global-ignores
git-svn: use svn:global-ignores to create .gitignore

 git-svn.perl    | 45 +++++++++++++++++++++++++++++++--------------
 perl/Git/SVN.pm |  2 +-
 2 files changed, 32 insertions(+), 15 deletions(-)

base-commit: c2b3f2b3cdbf5ad9feb978dd367d77561a1271f7
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1747%2Fav-gal%2Fgit-svn-global-ignores-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1747/av-gal/git-svn-global-ignores-v1
Pull-Request: https://github.com/git/git/pull/1747

#4 lore raw
Quoted 7 lines · Junio C Hamano

Paying attention to the new property and get it reflected to .gitignore on Git side may be a reasonable solution, especially if we ignore older version of Subversion. But I have a naïve question. If a new version of git-svn starts to rely on the new property that is only available in SVN 1.8, would it create problems with folks whose SVN installation does not understand it? Would it cause problems to them?

I don't believe so. Git doesn't do anything to set these properties, it just reads and translates them into the format used by .gitignore. So users on old versions of SVN should not be affected, their servers will not have this property set anywhere.

Quoted 7 lines

Anyway, in this project, explanation of the problem the patches address, with the outline of the solution, should be in the proposed commit log message of the patches themselves, not just written in the cover letter. Can you redo the proposed log messages of these two patches, where you have none in this iteration?

Thanks.

Sure thing. An amended patchset is incoming.

Thanks,
Alex

#5 lore raw

v2 cover git-svn: use svn:global-ignores when creating .gitignores

In reply to Alex Galvin via GitGitGadget

Git-SVN does not currently use the svn:global-ignores property added in Subversion 1.8 when showing or creating .gitignore files. This causes Git-SVN to track files that are ignored by this directive in Subversion.

The following patches add svn:global-ignores to the list of public svn properties, and update git svn show-ignore and git svn create-ignore to use this attribute (as well as svn:ignore).

Alex Galvin (2):
git-svn: add public property svn:global-ignores
git-svn: use svn:global-ignores to create .gitignore

 git-svn.perl    | 45 +++++++++++++++++++++++++++++++--------------
 perl/Git/SVN.pm |  2 +-
 2 files changed, 32 insertions(+), 15 deletions(-)

base-commit: c2b3f2b3cdbf5ad9feb978dd367d77561a1271f7
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1747%2Fav-gal%2Fgit-svn-global-ignores-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1747/av-gal/git-svn-global-ignores-v2
Pull-Request: https://github.com/git/git/pull/1747

Range-diff vs v1:

1: 27bee8de47b ! 1: 002750ea47a git-svn: add public property svn:global-ignores
@@ Metadata
## Commit message ##
git-svn: add public property svn:global-ignores

+ Subversion 1.8 added a new property svn:global-ignores. It
+ contains a list of patterns used to determine what files should
+ be ignored. If Git-SVN is going to ignore these files as well, it
+ is important that we do not skip over directories that have this
+ property set.
+

## perl/Git/SVN.pm ##
2: 10e240202f7 ! 2: 7735afb32af git-svn: use svn:global-ignores to create .gitignore
@@ Metadata
## Commit message ##
git-svn: use svn:global-ignores to create .gitignore

+ svn:global-ignores contains a list of file patterns that should
+ not be tracked in version control. The syntax of these patterns is
+ the same as svn:ignore. Their semantics differ: patterns in
+ svn:global-ignores apply to all paths under the directory where
+ they apply, while svn:ignore only applies to the directory's
+ immediate children.
+

## git-svn.perl ##

Signature · 1 line
gitgitgadget
#6 lore raw

PATCH v2 1/2 git-svn: add public property `svn:global-ignores`

From: Alex Galvin <[email protected]>

Subversion 1.8 added a new property svn:global-ignores. It contains a list of patterns used to determine what files should be ignored. If Git-SVN is going to ignore these files as well, it is important that we do not skip over directories that have this property set.

---
 perl/Git/SVN.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
perl/Git/SVN.pm +1 -1
index 7721708ce5d..b0913ca1b63 100644
@@ -763,7 +763,7 @@ sub prop_walk {
 		# this needs to be updated.
 		++$interesting_props if /^svn:(?:ignore|keywords|executable
 		                                 |eol-style|mime-type
-						 |externals|needs-lock)$/x;
+						 |externals|needs-lock|global-ignores)$/x;
 	}
 	&$sub($self, $p, $props) if $interesting_props;
 
Signature · 1 line
gitgitgadget
#7 lore raw

PATCH v2 2/2 git-svn: use `svn:global-ignores` to create .gitignore

In reply to Alex Galvin via GitGitGadget

From: Alex Galvin <[email protected]>

svn:global-ignores contains a list of file patterns that should not be tracked in version control. The syntax of these patterns is the same as svn:ignore. Their semantics differ: patterns in svn:global-ignores apply to all paths under the directory where they apply, while svn:ignore only applies to the directory's immediate children.

---
 git-svn.perl | 45 +++++++++++++++++++++++++++++++--------------
 1 file changed, 31 insertions(+), 14 deletions(-)
git-svn.perl +31 -14
index b0d0a50984b..a2a46608c9b 100755
@@ -1279,12 +1279,20 @@ sub cmd_show_ignore {
 	$gs->prop_walk($gs->path, $r, sub {
 		my ($gs, $path, $props) = @_;
 		print STDOUT "\n# $path\n";
-		my $s = $props->{'svn:ignore'} or return;
-		$s =~ s/[\r\n]+/\n/g;
-		$s =~ s/^\n+//;
-		chomp $s;
-		$s =~ s#^#$path#gm;
-		print STDOUT "$s\n";
+		if (my $s = $props->{'svn:ignore'}) {
+			$s =~ s/[\r\n]+/\n/g;
+			$s =~ s/^\n+//;
+			chomp $s;
+			$s =~ s#^#$path#gm;
+			print STDOUT "$s\n";
+		}
+		if (my $s = $props->{'svn:global-ignores'}) {
+			$s =~ s/[\r\n]+/\n/g;
+			$s =~ s/^\n+//;
+			chomp $s;
+			$s =~ s#^#$path**/#gm;
+			print STDOUT "$s\n";
+		}
 	});
 }
 
@@ -1315,16 +1323,25 @@ sub cmd_create_ignore {
 		# which git won't track
 		mkpath([$path]) unless -d $path;
 		my $ignore = $path . '.gitignore';
-		my $s = $props->{'svn:ignore'} or return;
 		open(GITIGNORE, '>', $ignore)
 		  or fatal("Failed to open `$ignore' for writing: $!");
-		$s =~ s/[\r\n]+/\n/g;
-		$s =~ s/^\n+//;
-		chomp $s;
-		# Prefix all patterns so that the ignore doesn't apply
-		# to sub-directories.
-		$s =~ s#^#/#gm;
-		print GITIGNORE "$s\n";
+		if (my $s = $props->{'svn:ignore'}) {
+			$s =~ s/[\r\n]+/\n/g;
+			$s =~ s/^\n+//;
+			chomp $s;
+			# Prefix all patterns so that the ignore doesn't apply
+			# to sub-directories.
+			$s =~ s#^#/#gm;
+			print GITIGNORE "$s\n";
+		}
+		if (my $s = $props->{'svn:global-ignores'}) {
+			$s =~ s/[\r\n]+/\n/g;
+			$s =~ s/^\n+//;
+			chomp $s;
+			# Global ignores apply to sub-directories, so they are
+			# not prefixed.
+			print GITIGNORE "$s\n";
+		}
 		close(GITIGNORE)
 		  or fatal("Failed to close `$ignore': $!");
 		command_noisy('add', '-f', $ignore);
Signature · 1 line
gitgitgadget
#8 lore raw

v3 cover git-svn: use svn:global-ignores when creating .gitignores

In reply to Alex Galvin via GitGitGadget

Git-SVN does not currently use the svn:global-ignores property added in Subversion 1.8 when showing or creating .gitignore files. This causes Git-SVN to track files that are ignored by this directive in Subversion.

The following patches add svn:global-ignores to the list of public svn properties, and update git svn show-ignore and git svn create-ignore to use this attribute (as well as svn:ignore).

Alex Galvin (3):
git-svn: add public property svn:global-ignores
git-svn: use svn:global-ignores to create .gitignore
git-svn: mention svn:globalignores in help

 git-svn.perl    | 49 +++++++++++++++++++++++++++++++++----------------
 perl/Git/SVN.pm |  2 +-
 2 files changed, 34 insertions(+), 17 deletions(-)

base-commit: c2b3f2b3cdbf5ad9feb978dd367d77561a1271f7
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1747%2Fav-gal%2Fgit-svn-global-ignores-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1747/av-gal/git-svn-global-ignores-v3
Pull-Request: https://github.com/git/git/pull/1747

Range-diff vs v2:

 1:  002750ea47a = 1:  002750ea47a git-svn: add public property `svn:global-ignores`
 2:  7735afb32af = 2:  7735afb32af git-svn: use `svn:global-ignores` to create .gitignore
 -:  ----------- > 3:  18dffbe992e git-svn: mention `svn:globalignores` in help
Signature · 1 line
gitgitgadget
#9 lore raw

PATCH v3 1/3 git-svn: add public property `svn:global-ignores`

From: Alex Galvin <[email protected]>

Subversion 1.8 added a new property svn:global-ignores. It contains a list of patterns used to determine what files should be ignored. If Git-SVN is going to ignore these files as well, it is important that we do not skip over directories that have this property set.

---
 perl/Git/SVN.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
perl/Git/SVN.pm +1 -1
index 7721708ce5d..b0913ca1b63 100644
@@ -763,7 +763,7 @@ sub prop_walk {
 		# this needs to be updated.
 		++$interesting_props if /^svn:(?:ignore|keywords|executable
 		                                 |eol-style|mime-type
-						 |externals|needs-lock)$/x;
+						 |externals|needs-lock|global-ignores)$/x;
 	}
 	&$sub($self, $p, $props) if $interesting_props;
 
Signature · 1 line
gitgitgadget
#10 lore raw

PATCH v3 2/3 git-svn: use `svn:global-ignores` to create .gitignore

In reply to Alex Galvin via GitGitGadget

From: Alex Galvin <[email protected]>

svn:global-ignores contains a list of file patterns that should not be tracked in version control. The syntax of these patterns is the same as svn:ignore. Their semantics differ: patterns in svn:global-ignores apply to all paths under the directory where they apply, while svn:ignore only applies to the directory's immediate children.

---
 git-svn.perl | 45 +++++++++++++++++++++++++++++++--------------
 1 file changed, 31 insertions(+), 14 deletions(-)
git-svn.perl +31 -14
index b0d0a50984b..a2a46608c9b 100755
@@ -1279,12 +1279,20 @@ sub cmd_show_ignore {
 	$gs->prop_walk($gs->path, $r, sub {
 		my ($gs, $path, $props) = @_;
 		print STDOUT "\n# $path\n";
-		my $s = $props->{'svn:ignore'} or return;
-		$s =~ s/[\r\n]+/\n/g;
-		$s =~ s/^\n+//;
-		chomp $s;
-		$s =~ s#^#$path#gm;
-		print STDOUT "$s\n";
+		if (my $s = $props->{'svn:ignore'}) {
+			$s =~ s/[\r\n]+/\n/g;
+			$s =~ s/^\n+//;
+			chomp $s;
+			$s =~ s#^#$path#gm;
+			print STDOUT "$s\n";
+		}
+		if (my $s = $props->{'svn:global-ignores'}) {
+			$s =~ s/[\r\n]+/\n/g;
+			$s =~ s/^\n+//;
+			chomp $s;
+			$s =~ s#^#$path**/#gm;
+			print STDOUT "$s\n";
+		}
 	});
 }
 
@@ -1315,16 +1323,25 @@ sub cmd_create_ignore {
 		# which git won't track
 		mkpath([$path]) unless -d $path;
 		my $ignore = $path . '.gitignore';
-		my $s = $props->{'svn:ignore'} or return;
 		open(GITIGNORE, '>', $ignore)
 		  or fatal("Failed to open `$ignore' for writing: $!");
-		$s =~ s/[\r\n]+/\n/g;
-		$s =~ s/^\n+//;
-		chomp $s;
-		# Prefix all patterns so that the ignore doesn't apply
-		# to sub-directories.
-		$s =~ s#^#/#gm;
-		print GITIGNORE "$s\n";
+		if (my $s = $props->{'svn:ignore'}) {
+			$s =~ s/[\r\n]+/\n/g;
+			$s =~ s/^\n+//;
+			chomp $s;
+			# Prefix all patterns so that the ignore doesn't apply
+			# to sub-directories.
+			$s =~ s#^#/#gm;
+			print GITIGNORE "$s\n";
+		}
+		if (my $s = $props->{'svn:global-ignores'}) {
+			$s =~ s/[\r\n]+/\n/g;
+			$s =~ s/^\n+//;
+			chomp $s;
+			# Global ignores apply to sub-directories, so they are
+			# not prefixed.
+			print GITIGNORE "$s\n";
+		}
 		close(GITIGNORE)
 		  or fatal("Failed to close `$ignore': $!");
 		command_noisy('add', '-f', $ignore);
Signature · 1 line
gitgitgadget
#11 lore raw

PATCH v3 3/3 git-svn: mention `svn:globalignores` in help

In reply to Alex Galvin via GitGitGadget

From: Alex Galvin <[email protected]>

---
 git-svn.perl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
git-svn.perl +2 -2
index a2a46608c9b..b824011154b 100755
@@ -219,7 +219,7 @@ my %cmd = (
 	                "Set an SVN repository to a git tree-ish",
 			{ 'stdin' => \$_stdin, %cmt_opts, %fc_opts, } ],
 	'create-ignore' => [ \&cmd_create_ignore,
-			     'Create a .gitignore per svn:ignore',
+			     'Create a .gitignore per svn:ignore and svn:globalignores',
 			     { 'revision|r=i' => \$_revision
 			     } ],
 	'mkdirs' => [ \&cmd_mkdirs ,
@@ -234,7 +234,7 @@ my %cmd = (
         'proplist' => [ \&cmd_proplist,
 		       'List all properties of a file or directory',
 		       { 'revision|r=i' => \$_revision } ],
-	'show-ignore' => [ \&cmd_show_ignore, "Show svn:ignore listings",
+	'show-ignore' => [ \&cmd_show_ignore, "Show svn:ignore and svn:globalignores listings",
 			{ 'revision|r=i' => \$_revision
 			} ],
 	'show-externals' => [ \&cmd_show_externals, "Show svn:externals listings",
Signature · 1 line
gitgitgadget
#12 lore raw
In reply to Alex Galvin via GitGitGadget
Quoted 3 lines · Alex Galvin via GitGitGadget

Git-SVN does not currently use the svn:global-ignores property added in Subversion 1.8 when showing or creating .gitignore files. This causes Git-SVN to track files that are ignored by this directive in Subversion.

THe v2 iteration of the topic has already been merged to 'next' last week, and I was hoping we were done. Can you make it an incremental update on top of d7969a5127, which was the previous round?

Thanks.