git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Galvin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Alex Galvin <agalvin@comqi.com>, Alex Galvin <agalvin@comqi.com>
Subject: [PATCH 2/2] git-svn: use `svn:global-ignores` to create .gitignore
Date: Wed, 17 Jul 2024 19:57:45 +0000	[thread overview]
Message-ID: <10e240202f79a0f50edf47391389c4e0892edf41.1721246266.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1747.git.git.1721246266.gitgitgadget@gmail.com>

From: Alex Galvin <agalvin@comqi.com>

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

  parent reply	other threads:[~2024-07-17 19:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-17 19:57 [PATCH 0/2] git-svn: use svn:global-ignores when creating .gitignores Alex Galvin via GitGitGadget
2024-07-17 19:57 ` [PATCH 1/2] git-svn: add public property `svn:global-ignores` Alex Galvin via GitGitGadget
2024-07-17 19:57 ` Alex Galvin via GitGitGadget [this message]
2024-07-17 20:45 ` [PATCH 0/2] git-svn: use svn:global-ignores when creating .gitignores Junio C Hamano
2024-07-18 19:59   ` Alex Galvin
2024-07-18 20:47 ` [PATCH v2 " Alex Galvin via GitGitGadget
2024-07-18 20:47   ` [PATCH v2 1/2] git-svn: add public property `svn:global-ignores` Alex Galvin via GitGitGadget
2024-07-18 20:47   ` [PATCH v2 2/2] git-svn: use `svn:global-ignores` to create .gitignore Alex Galvin via GitGitGadget
2024-08-12 16:58   ` [PATCH v3 0/3] git-svn: use svn:global-ignores when creating .gitignores Alex Galvin via GitGitGadget
2024-08-12 16:58     ` [PATCH v3 1/3] git-svn: add public property `svn:global-ignores` Alex Galvin via GitGitGadget
2024-08-12 16:58     ` [PATCH v3 2/3] git-svn: use `svn:global-ignores` to create .gitignore Alex Galvin via GitGitGadget
2024-08-12 16:58     ` [PATCH v3 3/3] git-svn: mention `svn:globalignores` in help Alex Galvin via GitGitGadget
2024-08-12 20:39     ` [PATCH v3 0/3] git-svn: use svn:global-ignores when creating .gitignores Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=10e240202f79a0f50edf47391389c4e0892edf41.1721246266.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=agalvin@comqi.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).