{"thread":{"id":"54226","subject":"[PATCH 0/2] GitSVN: Multi line support of ignore-path, include-paths and skiping of empty commits","startedAt":"2020-09-11T08:00:24Z","lastAt":"2020-09-11T08:00:37Z","messageCount":3,"participants":["Lukas Pupka-Lipinski via GitGitGadget","Lukas via GitGitGadget"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"405395","messageId":"pull.834.git.git.1599811217.gitgitgadget@gmail.com","threadId":"54226","inReplyTo":null,"subject":"[PATCH 0/2] GitSVN: Multi line support of ignore-path, include-paths and skiping of empty commits","fromName":"Lukas Pupka-Lipinski via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-11T08:00:15Z","receivedAt":"2020-09-11T08:00:24Z","isPatch":true,"sender":{"key":"lukas.pupkalipinski@lpl-mind.de","avatar":null},"body":"[PATCH]v3 GitSVN: Multi line support of ignore-path, include-paths and\nskiping of empty commits\n\nI used the ignore-paths option to ignore a lot of stuff I don’t need. The\nignore pattern works well, but it could and up in empty commits. So just the\nmessage without any modifications / changes. The patch below skip a commit\nif all changes are ignored by the ignore-paths option. In order to use this\nfeature I includes the option to read configuration for ignore-path,\ninclude-paths in several lines. So that the user is not limited by the max.\nchar. per line definition. In Addition this patch includes the optimizations\nwhich are mansion from your side.\n\nRegarding the subrouties comments i oriented by this example: \nhttps://www.perlmonks.org/?node_id=29905 \n\nChanges in v3:\n\n * Changed the code format (spaces etc.)\n * Wrap reg-expression by (?:<expression1>|<expression2>)\n * Removed useless variable init\n * Removed useless check.\n\nLukas (2):\n  svn: added: Multi line support for ignore-paths\n  sv: added: Skip commit if all files are ignored\n\n perl/Git/SVN.pm         | 21 +++++++++++++++++++++\n perl/Git/SVN/Fetcher.pm | 42 ++++++++++++++++++++++++++++++++++++-----\n perl/Git/SVN/Ra.pm      |  2 ++\n 3 files changed, 60 insertions(+), 5 deletions(-)\n\n\nbase-commit: 274b9cc25322d9ee79aa8e6d4e86f0ffe5ced925\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-834%2Flukaspupkalipinski%2Fmaster-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-834/lukaspupkalipinski/master-v1\nPull-Request: https://github.com/git/git/pull/834\n-- \ngitgitgadget\n"},{"id":"405396","messageId":"97232523112b433a4273ff5b4c132ca4fe3cf07c.1599811217.git.gitgitgadget@gmail.com","threadId":"54226","inReplyTo":"pull.834.git.git.1599811217.gitgitgadget@gmail.com","subject":"[PATCH 1/2] svn: added: Multi line support for ignore-paths","fromName":"Lukas via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-11T08:00:16Z","receivedAt":"2020-09-11T08:00:28Z","isPatch":true,"sender":{"key":"name:Lukas","avatar":null},"body":"From: Lukas <Lukas>\n\nWith this change ths user is able to ignore more than a couple of folder.\nThe git configuration has a max char length per line, so the user is limited if he want to ignor many folders/files.\nWith this patch the ignore-paths expression is generated by all given lines.\nExample:\nignore-paths=.*/somefolder1/\nignore-paths=base/differentfolder2/.*\n\nSigned-off-by: Lukas Pupka-Lipinski <lukas.pupkalipinski@lpl-mind.de>\n---\n perl/Git/SVN/Fetcher.pm | 12 +++++++-----\n 1 file changed, 7 insertions(+), 5 deletions(-)\n\ndiff --git a/perl/Git/SVN/Fetcher.pm b/perl/Git/SVN/Fetcher.pm\nindex 64e900a0e9..96b14538b0 100644\n--- a/perl/Git/SVN/Fetcher.pm\n+++ b/perl/Git/SVN/Fetcher.pm\n@@ -31,15 +31,17 @@ sub new {\n \t# override options set in an [svn-remote \"...\"] section\n \t$repo_id = $git_svn->{repo_id};\n \tmy $k = \"svn-remote.$repo_id.ignore-paths\";\n-\tmy $v = eval { command_oneline('config', '--get', $k) };\n-\t$self->{ignore_regex} = $v;\n+\tmy @config = eval { command( 'config', '--get-all', $k ) };\n+\tchomp(@config);\t# Replace all \\n\\r on the end\n+\t$self->{ignore_regex} = '(?:'.join('|', @config).')';\n \n \t$k = \"svn-remote.$repo_id.include-paths\";\n-\t$v = eval { command_oneline('config', '--get', $k) };\n-\t$self->{include_regex} = $v;\n+\t@config = eval { command( 'config', '--get-all', $k ) };\n+\tchomp(@config);\t# Replace all \\n\\r on the end\n+\t$self->{include_regex} = '(?:'.join('|', @config).')';\n \n \t$k = \"svn-remote.$repo_id.preserve-empty-dirs\";\n-\t$v = eval { command_oneline('config', '--get', '--bool', $k) };\n+\tmy $v = eval { command_oneline('config', '--get', '--bool', $k) };\n \tif ($v && $v eq 'true') {\n \t\t$_preserve_empty_dirs = 1;\n \t\t$k = \"svn-remote.$repo_id.placeholder-filename\";\n-- \ngitgitgadget\n\n"},{"id":"405397","messageId":"282e524547a4998c131a8162b72a33f6129e637b.1599811217.git.gitgitgadget@gmail.com","threadId":"54226","inReplyTo":"pull.834.git.git.1599811217.gitgitgadget@gmail.com","subject":"[PATCH 2/2] sv: added: Skip commit if all files are ignored","fromName":"Lukas via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-09-11T08:00:17Z","receivedAt":"2020-09-11T08:00:37Z","isPatch":true,"sender":{"key":"name:Lukas","avatar":null},"body":"From: Lukas <Lukas>\n\nI used the ignore-paths option to ignore a lot of stuff I don’t need.\nThe ignore pattern works well, but it could and up in empty commits.\nSo just the message without any modifications / changes.\nThe patch below skip a commit if all changes are ignored by the ignore-paths option.\nIn order to use this feature I includes the option to read configuration for ignore-path, include-paths in several lines.\nSo that the user is not limited by the max. char. per line definition.\n\nSigned-off-by: Lukas Pupka-Lipinski <lukas.pupkalipinski@lpl-mind.de>\n---\n perl/Git/SVN.pm         | 21 +++++++++++++++++++++\n perl/Git/SVN/Fetcher.pm | 30 ++++++++++++++++++++++++++++++\n perl/Git/SVN/Ra.pm      |  2 ++\n 3 files changed, 53 insertions(+)\n\ndiff --git a/perl/Git/SVN.pm b/perl/Git/SVN.pm\nindex 4b28b87784..fa87687306 100644\n--- a/perl/Git/SVN.pm\n+++ b/perl/Git/SVN.pm\n@@ -1188,6 +1188,22 @@ sub find_parent_branch {\n \treturn undef;\n }\n \n+############################################################\n+\n+=item do_fetch()\n+\n+Fetch an Commit and returns a log entry\n+\n+Input:  $path - array of strings (Paths) in a commit\n+\t\t$rev - Revision number\n+\n+Output: $log_entry if successfull\n+\t\tnull if skipped\n+\t\t(die) on fetch error\n+\n+=cut\n+\n+############################################################\n sub do_fetch {\n \tmy ($self, $paths, $rev) = @_;\n \tmy $ed;\n@@ -1212,6 +1228,11 @@ sub do_fetch {\n \t\t}\n \t\t$ed = Git::SVN::Fetcher->new($self);\n \t}\n+\tmy $skip = $ed->is_empty_commit($paths);\n+\tif ($skip){\n+\t\tprint \"skip commit $rev\\n\";\n+\t\treturn;\n+\t}\n \tunless ($self->ra->gs_do_update($last_rev, $rev, $self, $ed)) {\n \t\tdie \"SVN connection failed somewhere...\\n\";\n \t}\ndiff --git a/perl/Git/SVN/Fetcher.pm b/perl/Git/SVN/Fetcher.pm\nindex 96b14538b0..c31343b6e6 100644\n--- a/perl/Git/SVN/Fetcher.pm\n+++ b/perl/Git/SVN/Fetcher.pm\n@@ -139,6 +139,36 @@ sub is_path_ignored {\n \treturn 0;\n }\n \n+############################################################\n+\n+=item is_empty_commit()\n+\n+Return 1 if all given $paths are ignored, so that this commit end up in an empty commit\n+\n+Input:  $path - array of strings (Paths) in a commit\n+\n+Output: { 1 if true, 0 if false }\n+\n+=cut\n+\n+############################################################\n+sub is_empty_commit {\n+\tmy ( $self, $paths ) = @_;\n+\tmy $path;\n+\tmy $ignored;\n+\tunless ( defined( $self->{include_regex} ) ) {\n+\t\treturn 0;\n+\t}\n+\n+\tforeach $path ( keys %$paths ) {\n+\t\t$ignored = $self->is_path_ignored($path);\n+\t\tif ( !$ignored ) {\n+\t\t\treturn 0;\n+\t\t}\n+\t}\n+\treturn 1;\n+}\n+\n sub set_path_strip {\n \tmy ($self, $path) = @_;\n \t$self->{path_strip} = qr/^\\Q$path\\E(\\/|$)/ if length $path;\ndiff --git a/perl/Git/SVN/Ra.pm b/perl/Git/SVN/Ra.pm\nindex 56ad9870bc..63be69dc12 100644\n--- a/perl/Git/SVN/Ra.pm\n+++ b/perl/Git/SVN/Ra.pm\n@@ -475,6 +475,8 @@ sub gs_fetch_loop_common {\n \t\t\t\tmy $log_entry = $gs->do_fetch($paths, $r);\n \t\t\t\tif ($log_entry) {\n \t\t\t\t\t$gs->do_git_commit($log_entry);\n+\t\t\t\t}else{\n+\t\t\t\t\tnext;\n \t\t\t\t}\n \t\t\t\t$Git::SVN::INDEX_FILES{$gs->{index}} = 1;\n \t\t\t}\n-- \ngitgitgadget\n"}]}