{"thread":{"id":"35373","subject":"[PATCH] git-svn: Support svn:global-ignores property","startedAt":"2013-11-21T10:41:24Z","lastAt":"2013-12-16T22:23:56Z","messageCount":4,"participants":["Aleksey Vasenev","Thomas Rast","Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"230880","messageId":"528DE354.1050804@ya.ru","threadId":"35373","inReplyTo":null,"subject":"[PATCH] git-svn: Support svn:global-ignores property","fromName":"Aleksey Vasenev","fromEmail":"margtu-fivt@ya.ru","sentAt":"2013-11-21T10:41:24Z","receivedAt":"2013-11-21T10:41:24Z","isPatch":true,"sender":{"key":"margtu-fivt@ya.ru","avatar":"https://avatars.githubusercontent.com/u/2958497?v=4"},"body":"---\n  Documentation/git-svn.txt | 12 ++++++------\n  git-svn.perl              | 46 \n++++++++++++++++++++++++++++++++--------------\n  2 files changed, 38 insertions(+), 20 deletions(-)\n\ndiff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt\nindex 30c5ee2..0c1cd46 100644\n--- a/Documentation/git-svn.txt\n+++ b/Documentation/git-svn.txt\n@@ -405,14 +405,14 @@ Any other arguments are passed directly to 'git log'\n      independently of 'git svn' functions.\n\n  'create-ignore'::\n-    Recursively finds the svn:ignore property on directories and\n-    creates matching .gitignore files. The resulting files are staged to\n-    be committed, but are not committed. Use -r/--revision to refer to a\n-    specific revision.\n+    Recursively finds svn:ignore and svn:global-ignores properties on\n+    directories and creates matching .gitignore files. The resulting\n+    files are staged to be committed, but are not committed.\n+    Use -r/--revision to refer to a specific revision.\n\n  'show-ignore'::\n-    Recursively finds and lists the svn:ignore property on\n-    directories.  The output is suitable for appending to\n+    Recursively finds and lists svn:ignore and svn:global-ignores\n+    properties on directories. The output is suitable for appending to\n      the $GIT_DIR/info/exclude file.\n\n  'mkdirs'::\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 7349ffe..a2565e1 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -1261,6 +1261,15 @@ sub cmd_rebase {\n      }\n  }\n\n+sub get_svn_ignore {\n+    my ($props, $prop) = @_;\n+    my $s = $props->{$prop} or return;\n+    $s =~ s/[\\r\\n]+/\\n/g;\n+    $s =~ s/^\\n+//;\n+    chomp $s;\n+    return $s;\n+}\n+\n  sub cmd_show_ignore {\n      my ($url, $rev, $uuid, $gs) = working_head_info('HEAD');\n      $gs ||= Git::SVN->new;\n@@ -1268,12 +1277,17 @@ sub cmd_show_ignore {\n      $gs->prop_walk($gs->path, $r, sub {\n          my ($gs, $path, $props) = @_;\n          print STDOUT \"\\n# $path\\n\";\n-        my $s = $props->{'svn:ignore'} or return;\n-        $s =~ s/[\\r\\n]+/\\n/g;\n-        $s =~ s/^\\n+//;\n-        chomp $s;\n-        $s =~ s#^#$path#gm;\n-        print STDOUT \"$s\\n\";\n+        my $s = &get_svn_ignore($props, 'svn:ignore');\n+        my $s_global = &get_svn_ignore($props, 'svn:global-ignores');\n+        $s or $s_global or return;\n+        if ($s) {\n+            $s =~ s#^#$path#gm;\n+            print STDOUT \"$s\\n\";\n+        }\n+        if ($s_global) {\n+            $s_global =~ s#^#$path**/#gm;\n+            print STDOUT \"$s_global\\n\";\n+        }\n      });\n  }\n\n@@ -1304,16 +1318,20 @@ sub cmd_create_ignore {\n          # which git won't track\n          mkpath([$path]) unless -d $path;\n          my $ignore = $path . '.gitignore';\n-        my $s = $props->{'svn:ignore'} or return;\n+        my $s = &get_svn_ignore($props, 'svn:ignore');\n+        my $s_global = &get_svn_ignore($props, 'svn:global-ignores');\n+        $s or $s_global or return;\n          open(GITIGNORE, '>', $ignore)\n            or fatal(\"Failed to open `$ignore' for writing: $!\");\n-        $s =~ s/[\\r\\n]+/\\n/g;\n-        $s =~ s/^\\n+//;\n-        chomp $s;\n-        # Prefix all patterns so that the ignore doesn't apply\n-        # to sub-directories.\n-        $s =~ s#^#/#gm;\n-        print GITIGNORE \"$s\\n\";\n+        if ($s) {\n+            # Prefix all patterns so that the ignore doesn't apply\n+            # to sub-directories.\n+            $s =~ s#^#/#gm;\n+            print GITIGNORE \"$s\\n\";\n+        }\n+        if ($s_global) {\n+            print GITIGNORE \"$s_global\\n\";\n+        }\n          close(GITIGNORE)\n            or fatal(\"Failed to close `$ignore': $!\");\n          command_noisy('add', '-f', $ignore);\n-- \n1.8.3.msysgit.0\n"},{"id":"230885","messageId":"1385036908-10392-1-git-send-email-margtu-fivt@ya.ru","threadId":"35373","inReplyTo":"528DE354.1050804@ya.ru","subject":"[PATCH] git-svn: Support svn:global-ignores property","fromName":"Aleksey Vasenev","fromEmail":"margtu-fivt@ya.ru","sentAt":"2013-11-21T12:28:28Z","receivedAt":"2013-11-21T12:28:28Z","isPatch":true,"sender":{"key":"margtu-fivt@ya.ru","avatar":"https://avatars.githubusercontent.com/u/2958497?v=4"},"body":"---\n Documentation/git-svn.txt | 12 ++++++------\n git-svn.perl              | 46 ++++++++++++++++++++++++++++++++--------------\n 2 files changed, 38 insertions(+), 20 deletions(-)\n\ndiff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt\nindex 30c5ee2..0c1cd46 100644\n--- a/Documentation/git-svn.txt\n+++ b/Documentation/git-svn.txt\n@@ -405,14 +405,14 @@ Any other arguments are passed directly to 'git log'\n \tindependently of 'git svn' functions.\n \n 'create-ignore'::\n-\tRecursively finds the svn:ignore property on directories and\n-\tcreates matching .gitignore files. The resulting files are staged to\n-\tbe committed, but are not committed. Use -r/--revision to refer to a\n-\tspecific revision.\n+\tRecursively finds svn:ignore and svn:global-ignores properties on\n+\tdirectories and creates matching .gitignore files. The resulting\n+\tfiles are staged to be committed, but are not committed.\n+\tUse -r/--revision to refer to a specific revision.\n \n 'show-ignore'::\n-\tRecursively finds and lists the svn:ignore property on\n-\tdirectories.  The output is suitable for appending to\n+\tRecursively finds and lists svn:ignore and svn:global-ignores\n+\tproperties on directories. The output is suitable for appending to\n \tthe $GIT_DIR/info/exclude file.\n \n 'mkdirs'::\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 7349ffe..a2565e1 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -1261,6 +1261,15 @@ sub cmd_rebase {\n \t}\n }\n \n+sub get_svn_ignore {\n+\tmy ($props, $prop) = @_;\n+\tmy $s = $props->{$prop} or return;\n+\t$s =~ s/[\\r\\n]+/\\n/g;\n+\t$s =~ s/^\\n+//;\n+\tchomp $s;\n+\treturn $s;\n+}\n+\n sub cmd_show_ignore {\n \tmy ($url, $rev, $uuid, $gs) = working_head_info('HEAD');\n \t$gs ||= Git::SVN->new;\n@@ -1268,12 +1277,17 @@ sub cmd_show_ignore {\n \t$gs->prop_walk($gs->path, $r, sub {\n \t\tmy ($gs, $path, $props) = @_;\n \t\tprint STDOUT \"\\n# $path\\n\";\n-\t\tmy $s = $props->{'svn:ignore'} or return;\n-\t\t$s =~ s/[\\r\\n]+/\\n/g;\n-\t\t$s =~ s/^\\n+//;\n-\t\tchomp $s;\n-\t\t$s =~ s#^#$path#gm;\n-\t\tprint STDOUT \"$s\\n\";\n+\t\tmy $s = &get_svn_ignore($props, 'svn:ignore');\n+\t\tmy $s_global = &get_svn_ignore($props, 'svn:global-ignores');\n+\t\t$s or $s_global or return;\n+\t\tif ($s) {\n+\t\t\t$s =~ s#^#$path#gm;\n+\t\t\tprint STDOUT \"$s\\n\";\n+\t\t}\n+\t\tif ($s_global) {\n+\t\t\t$s_global =~ s#^#$path**/#gm;\n+\t\t\tprint STDOUT \"$s_global\\n\";\n+\t\t}\n \t});\n }\n \n@@ -1304,16 +1318,20 @@ sub cmd_create_ignore {\n \t\t# which git won't track\n \t\tmkpath([$path]) unless -d $path;\n \t\tmy $ignore = $path . '.gitignore';\n-\t\tmy $s = $props->{'svn:ignore'} or return;\n+\t\tmy $s = &get_svn_ignore($props, 'svn:ignore');\n+\t\tmy $s_global = &get_svn_ignore($props, 'svn:global-ignores');\n+\t\t$s or $s_global or return;\n \t\topen(GITIGNORE, '>', $ignore)\n \t\t  or fatal(\"Failed to open `$ignore' for writing: $!\");\n-\t\t$s =~ s/[\\r\\n]+/\\n/g;\n-\t\t$s =~ s/^\\n+//;\n-\t\tchomp $s;\n-\t\t# Prefix all patterns so that the ignore doesn't apply\n-\t\t# to sub-directories.\n-\t\t$s =~ s#^#/#gm;\n-\t\tprint GITIGNORE \"$s\\n\";\n+\t\tif ($s) {\n+\t\t\t# Prefix all patterns so that the ignore doesn't apply\n+\t\t\t# to sub-directories.\n+\t\t\t$s =~ s#^#/#gm;\n+\t\t\tprint GITIGNORE \"$s\\n\";\n+\t\t}\n+\t\tif ($s_global) {\n+\t\t\tprint GITIGNORE \"$s_global\\n\";\n+\t\t}\n \t\tclose(GITIGNORE)\n \t\t  or fatal(\"Failed to close `$ignore': $!\");\n \t\tcommand_noisy('add', '-f', $ignore);\n-- \n1.8.3.msysgit.0\n"},{"id":"231008","messageId":"87d2lqgphv.fsf@linux-k42r.v.cablecom.net","threadId":"35373","inReplyTo":"1385036908-10392-1-git-send-email-margtu-fivt@ya.ru","subject":"Re: [PATCH] git-svn: Support svn:global-ignores property","fromName":"Thomas Rast","fromEmail":"tr@thomasrast.ch","sentAt":"2013-11-24T08:42:20Z","receivedAt":"2013-11-24T08:42:20Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Hi Aleksey\n\nThanks for your patch.  I added Eric Wong to the Cc list; all git-svn\npatches should go to him.\n\nAleksey Vasenev <margtu-fivt@ya.ru> writes:\n\n> ---\n\nCan you write a commit message?  If you need a guideline for what to\nwrite there, consider this snippet from Documentation/SubmittingPatches:\n\n  The body should provide a meaningful commit message, which:\n\n  . explains the problem the change tries to solve, iow, what is wrong\n    with the current code without the change.\n\n  . justifies the way the change solves the problem, iow, why the\n    result with the change is better.\n\n  . alternate solutions considered but discarded, if any.\n\nIn particular, I'm curious about how global-ignores are different from\nordinary ignores.  After reading\n\n  http://svnbook.red-bean.com/en/1.7/svn.advanced.props.special.ignore.html\n\nI don't understand why the above document speaks of a \"config area\" that\nholds the global-ignores configuration, while your patch seems to treat\nthem as \"just another property\" set in the same way as existing\nsvn:ignore.  How does this work?\n\n\n>  Documentation/git-svn.txt | 12 ++++++------\n>  git-svn.perl              | 46 ++++++++++++++++++++++++++++++++--------------\n>  2 files changed, 38 insertions(+), 20 deletions(-)\n\nCan you add a test or two?\n\n-- \nThomas Rast\ntr@thomasrast.ch\n"},{"id":"232086","messageId":"20131216222356.GA13115@dcvr.yhbt.net","threadId":"35373","inReplyTo":"1385036908-10392-1-git-send-email-margtu-fivt@ya.ru","subject":"Re: [PATCH] git-svn: Support svn:global-ignores property","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2013-12-16T22:23:56Z","receivedAt":"2013-12-16T22:23:56Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Aleksey Vasenev <margtu-fivt@ya.ru> wrote:\n> ---\n\nWhat Thomas said about commit messages.\n\nNote: I hardly use git-svn or SVN anymore and don't pay attention\nto SVN changes.\n\nSome style nitpicks:\n\n> @@ -1304,16 +1318,20 @@ sub cmd_create_ignore {\n>  \t\t# which git won't track\n>  \t\tmkpath([$path]) unless -d $path;\n>  \t\tmy $ignore = $path . '.gitignore';\n> -\t\tmy $s = $props->{'svn:ignore'} or return;\n> +\t\tmy $s = &get_svn_ignore($props, 'svn:ignore');\n> +\t\tmy $s_global = &get_svn_ignore($props, 'svn:global-ignores');\n\n&sub(...) convention isn't consistent with the rest of our Perl code.\nDo this instead:\n\n\t\tmy $s = get_svn_ignore($props, 'svn:ignore');\n\t\tmy $s_global = get_svn_ignore($props, 'svn:global-ignores');\n\n> +\t\t$s or $s_global or return;\n\nPrecedence should be more explicit:\n\t\t($s || $s_global) or return;\n\nLikewise for cmd_show_ignore.  Thanks.\n"}]}