git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Alex Galvin via GitGitGadget <gitgitgadget@gmail.com>
Date
Aug 12, 2024, 16:58 UTC
Message-ID
<7735afb32afd601e8306635e1cb3767f3f923f43.1723481908.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1747.v3.git.git.1723481908.gitgitgadget@gmail.com>
From: Alex Galvin <agalvin@comqi.com>

`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.

Signed-off-by: Alex Galvin <agalvin@comqi.com>
---
 git-svn.perl | 45 +++++++++++++++++++++++++++++++--------------
 1 file changed, 31 insertions(+), 14 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index b0d0a50984b..a2a46608c9b 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -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);
-- 
gitgitgadget
Previous: Alex Galvin via GitGitGadgetNext: Alex Galvin via GitGitGadget
Message 11 of 13 in “git-svn: use svn:global-ignores when creating .gitignores”
  1. 0/2 git-svn: use svn:global-ignores when creating .gitignoresAlex Galvin via GitGitGadget, Jul 17, 2024
  2. 1/2 git-svn: add public property `svn:global-ignores`Alex Galvin via GitGitGadget, Jul 17, 2024
  3. 2/2 git-svn: use `svn:global-ignores` to create .gitignoreAlex Galvin via GitGitGadget, Jul 17, 2024
  4. Junio C HamanoJul 17, 2024
  5. Alex GalvinJul 18, 2024
  6. 0/2 git-svn: use svn:global-ignores when creating .gitignoresAlex Galvin via GitGitGadget, Jul 18, 2024
  7. 1/2 git-svn: add public property `svn:global-ignores`Alex Galvin via GitGitGadget, Jul 18, 2024
  8. 2/2 git-svn: use `svn:global-ignores` to create .gitignoreAlex Galvin via GitGitGadget, Jul 18, 2024
  9. 0/3 git-svn: use svn:global-ignores when creating .gitignoresAlex Galvin via GitGitGadget, Aug 12, 2024
  10. 1/3 git-svn: add public property `svn:global-ignores`Alex Galvin via GitGitGadget, Aug 12, 2024
  11. 2/3 git-svn: use `svn:global-ignores` to create .gitignoreAlex Galvin via GitGitGadget, Aug 12, 2024
  12. 3/3 git-svn: mention `svn:globalignores` in helpAlex Galvin via GitGitGadget, Aug 12, 2024
  13. Junio C HamanoAug 12, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.