public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
* [PATCH] git-svn: Support svn:global-ignores property
@ 2013-11-21 10:41 Aleksey Vasenev
  2013-11-21 12:28 ` Aleksey Vasenev
  0 siblings, 1 reply; 4+ messages in thread
From: Aleksey Vasenev @ 2013-11-21 10:41 UTC (permalink / raw)
  To: git; +Cc: Benoit Sigoure

---
  Documentation/git-svn.txt | 12 ++++++------
  git-svn.perl              | 46 
++++++++++++++++++++++++++++++++--------------
  2 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index 30c5ee2..0c1cd46 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -405,14 +405,14 @@ Any other arguments are passed directly to 'git log'
      independently of 'git svn' functions.

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

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

  'mkdirs'::
diff --git a/git-svn.perl b/git-svn.perl
index 7349ffe..a2565e1 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1261,6 +1261,15 @@ sub cmd_rebase {
      }
  }

+sub get_svn_ignore {
+    my ($props, $prop) = @_;
+    my $s = $props->{$prop} or return;
+    $s =~ s/[\r\n]+/\n/g;
+    $s =~ s/^\n+//;
+    chomp $s;
+    return $s;
+}
+
  sub cmd_show_ignore {
      my ($url, $rev, $uuid, $gs) = working_head_info('HEAD');
      $gs ||= Git::SVN->new;
@@ -1268,12 +1277,17 @@ 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";
+        my $s = &get_svn_ignore($props, 'svn:ignore');
+        my $s_global = &get_svn_ignore($props, 'svn:global-ignores');
+        $s or $s_global or return;
+        if ($s) {
+            $s =~ s#^#$path#gm;
+            print STDOUT "$s\n";
+        }
+        if ($s_global) {
+            $s_global =~ s#^#$path**/#gm;
+            print STDOUT "$s_global\n";
+        }
      });
  }

@@ -1304,16 +1318,20 @@ 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;
+        my $s = &get_svn_ignore($props, 'svn:ignore');
+        my $s_global = &get_svn_ignore($props, 'svn:global-ignores');
+        $s or $s_global 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 ($s) {
+            # Prefix all patterns so that the ignore doesn't apply
+            # to sub-directories.
+            $s =~ s#^#/#gm;
+            print GITIGNORE "$s\n";
+        }
+        if ($s_global) {
+            print GITIGNORE "$s_global\n";
+        }
          close(GITIGNORE)
            or fatal("Failed to close `$ignore': $!");
          command_noisy('add', '-f', $ignore);
-- 
1.8.3.msysgit.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] git-svn: Support svn:global-ignores property
  2013-11-21 10:41 [PATCH] git-svn: Support svn:global-ignores property Aleksey Vasenev
@ 2013-11-21 12:28 ` Aleksey Vasenev
  2013-11-24  8:42   ` Thomas Rast
  2013-12-16 22:23   ` Eric Wong
  0 siblings, 2 replies; 4+ messages in thread
From: Aleksey Vasenev @ 2013-11-21 12:28 UTC (permalink / raw)
  To: git; +Cc: Benoit Sigoure, Aleksey Vasenev

---
 Documentation/git-svn.txt | 12 ++++++------
 git-svn.perl              | 46 ++++++++++++++++++++++++++++++++--------------
 2 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index 30c5ee2..0c1cd46 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -405,14 +405,14 @@ Any other arguments are passed directly to 'git log'
 	independently of 'git svn' functions.
 
 'create-ignore'::
-	Recursively finds the svn:ignore property on directories and
-	creates matching .gitignore files. The resulting files are staged to
-	be committed, but are not committed. Use -r/--revision to refer to a
-	specific revision.
+	Recursively finds svn:ignore and svn:global-ignores properties on
+	directories and creates matching .gitignore files. The resulting
+	files are staged to be committed, but are not committed.
+	Use -r/--revision to refer to a specific revision.
 
 'show-ignore'::
-	Recursively finds and lists the svn:ignore property on
-	directories.  The output is suitable for appending to
+	Recursively finds and lists svn:ignore and svn:global-ignores
+	properties on directories. The output is suitable for appending to
 	the $GIT_DIR/info/exclude file.
 
 'mkdirs'::
diff --git a/git-svn.perl b/git-svn.perl
index 7349ffe..a2565e1 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1261,6 +1261,15 @@ sub cmd_rebase {
 	}
 }
 
+sub get_svn_ignore {
+	my ($props, $prop) = @_;
+	my $s = $props->{$prop} or return;
+	$s =~ s/[\r\n]+/\n/g;
+	$s =~ s/^\n+//;
+	chomp $s;
+	return $s;
+}
+
 sub cmd_show_ignore {
 	my ($url, $rev, $uuid, $gs) = working_head_info('HEAD');
 	$gs ||= Git::SVN->new;
@@ -1268,12 +1277,17 @@ 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";
+		my $s = &get_svn_ignore($props, 'svn:ignore');
+		my $s_global = &get_svn_ignore($props, 'svn:global-ignores');
+		$s or $s_global or return;
+		if ($s) {
+			$s =~ s#^#$path#gm;
+			print STDOUT "$s\n";
+		}
+		if ($s_global) {
+			$s_global =~ s#^#$path**/#gm;
+			print STDOUT "$s_global\n";
+		}
 	});
 }
 
@@ -1304,16 +1318,20 @@ 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;
+		my $s = &get_svn_ignore($props, 'svn:ignore');
+		my $s_global = &get_svn_ignore($props, 'svn:global-ignores');
+		$s or $s_global 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 ($s) {
+			# Prefix all patterns so that the ignore doesn't apply
+			# to sub-directories.
+			$s =~ s#^#/#gm;
+			print GITIGNORE "$s\n";
+		}
+		if ($s_global) {
+			print GITIGNORE "$s_global\n";
+		}
 		close(GITIGNORE)
 		  or fatal("Failed to close `$ignore': $!");
 		command_noisy('add', '-f', $ignore);
-- 
1.8.3.msysgit.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] git-svn: Support svn:global-ignores property
  2013-11-21 12:28 ` Aleksey Vasenev
@ 2013-11-24  8:42   ` Thomas Rast
  2013-12-16 22:23   ` Eric Wong
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Rast @ 2013-11-24  8:42 UTC (permalink / raw)
  To: Aleksey Vasenev; +Cc: git, Benoit Sigoure, Eric Wong

Hi Aleksey

Thanks for your patch.  I added Eric Wong to the Cc list; all git-svn
patches should go to him.

Aleksey Vasenev <margtu-fivt@ya•ru> writes:

> ---

Can you write a commit message?  If you need a guideline for what to
write there, consider this snippet from Documentation/SubmittingPatches:

  The body should provide a meaningful commit message, which:

  . explains the problem the change tries to solve, iow, what is wrong
    with the current code without the change.

  . justifies the way the change solves the problem, iow, why the
    result with the change is better.

  . alternate solutions considered but discarded, if any.

In particular, I'm curious about how global-ignores are different from
ordinary ignores.  After reading

  http://svnbook.red-bean.com/en/1.7/svn.advanced.props.special.ignore.html

I don't understand why the above document speaks of a "config area" that
holds the global-ignores configuration, while your patch seems to treat
them as "just another property" set in the same way as existing
svn:ignore.  How does this work?


>  Documentation/git-svn.txt | 12 ++++++------
>  git-svn.perl              | 46 ++++++++++++++++++++++++++++++++--------------
>  2 files changed, 38 insertions(+), 20 deletions(-)

Can you add a test or two?

-- 
Thomas Rast
tr@thomasrast•ch

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] git-svn: Support svn:global-ignores property
  2013-11-21 12:28 ` Aleksey Vasenev
  2013-11-24  8:42   ` Thomas Rast
@ 2013-12-16 22:23   ` Eric Wong
  1 sibling, 0 replies; 4+ messages in thread
From: Eric Wong @ 2013-12-16 22:23 UTC (permalink / raw)
  To: Aleksey Vasenev; +Cc: git, Benoit Sigoure, Thomas Rast

Aleksey Vasenev <margtu-fivt@ya•ru> wrote:
> ---

What Thomas said about commit messages.

Note: I hardly use git-svn or SVN anymore and don't pay attention
to SVN changes.

Some style nitpicks:

> @@ -1304,16 +1318,20 @@ 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;
> +		my $s = &get_svn_ignore($props, 'svn:ignore');
> +		my $s_global = &get_svn_ignore($props, 'svn:global-ignores');

&sub(...) convention isn't consistent with the rest of our Perl code.
Do this instead:

		my $s = get_svn_ignore($props, 'svn:ignore');
		my $s_global = get_svn_ignore($props, 'svn:global-ignores');

> +		$s or $s_global or return;

Precedence should be more explicit:
		($s || $s_global) or return;

Likewise for cmd_show_ignore.  Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-12-16 22:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-21 10:41 [PATCH] git-svn: Support svn:global-ignores property Aleksey Vasenev
2013-11-21 12:28 ` Aleksey Vasenev
2013-11-24  8:42   ` Thomas Rast
2013-12-16 22:23   ` Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox