git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] GitSVN: Multi line support of ignore-path, include-paths and skiping of empty commits
@ 2020-09-11  8:00 Lukas Pupka-Lipinski via GitGitGadget
  2020-09-11  8:00 ` [PATCH 1/2] svn: added: Multi line support for ignore-paths Lukas via GitGitGadget
  2020-09-11  8:00 ` [PATCH 2/2] sv: added: Skip commit if all files are ignored Lukas via GitGitGadget
  0 siblings, 2 replies; 3+ messages in thread
From: Lukas Pupka-Lipinski via GitGitGadget @ 2020-09-11  8:00 UTC (permalink / raw)
  To: git

[PATCH]v3 GitSVN: Multi line support of ignore-path, include-paths and
skiping of empty commits

I used the ignore-paths option to ignore a lot of stuff I don’t need. The
ignore pattern works well, but it could and up in empty commits. So just the
message without any modifications / changes. The patch below skip a commit
if all changes are ignored by the ignore-paths option. In order to use this
feature I includes the option to read configuration for ignore-path,
include-paths in several lines. So that the user is not limited by the max.
char. per line definition. In Addition this patch includes the optimizations
which are mansion from your side.

Regarding the subrouties comments i oriented by this example: 
https://www.perlmonks.org/?node_id=29905 

Changes in v3:

 * Changed the code format (spaces etc.)
 * Wrap reg-expression by (?:<expression1>|<expression2>)
 * Removed useless variable init
 * Removed useless check.

Lukas (2):
  svn: added: Multi line support for ignore-paths
  sv: added: Skip commit if all files are ignored

 perl/Git/SVN.pm         | 21 +++++++++++++++++++++
 perl/Git/SVN/Fetcher.pm | 42 ++++++++++++++++++++++++++++++++++++-----
 perl/Git/SVN/Ra.pm      |  2 ++
 3 files changed, 60 insertions(+), 5 deletions(-)


base-commit: 274b9cc25322d9ee79aa8e6d4e86f0ffe5ced925
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-834%2Flukaspupkalipinski%2Fmaster-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-834/lukaspupkalipinski/master-v1
Pull-Request: https://github.com/git/git/pull/834
-- 
gitgitgadget

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

* [PATCH 1/2] svn: added: Multi line support for ignore-paths
  2020-09-11  8:00 [PATCH 0/2] GitSVN: Multi line support of ignore-path, include-paths and skiping of empty commits Lukas Pupka-Lipinski via GitGitGadget
@ 2020-09-11  8:00 ` Lukas via GitGitGadget
  2020-09-11  8:00 ` [PATCH 2/2] sv: added: Skip commit if all files are ignored Lukas via GitGitGadget
  1 sibling, 0 replies; 3+ messages in thread
From: Lukas via GitGitGadget @ 2020-09-11  8:00 UTC (permalink / raw)
  To: git; +Cc: Lukas

From: Lukas <Lukas>

With this change ths user is able to ignore more than a couple of folder.
The git configuration has a max char length per line, so the user is limited if he want to ignor many folders/files.
With this patch the ignore-paths expression is generated by all given lines.
Example:
ignore-paths=.*/somefolder1/
ignore-paths=base/differentfolder2/.*

Signed-off-by: Lukas Pupka-Lipinski <lukas.pupkalipinski@lpl-mind.de>
---
 perl/Git/SVN/Fetcher.pm | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/perl/Git/SVN/Fetcher.pm b/perl/Git/SVN/Fetcher.pm
index 64e900a0e9..96b14538b0 100644
--- a/perl/Git/SVN/Fetcher.pm
+++ b/perl/Git/SVN/Fetcher.pm
@@ -31,15 +31,17 @@ sub new {
 	# override options set in an [svn-remote "..."] section
 	$repo_id = $git_svn->{repo_id};
 	my $k = "svn-remote.$repo_id.ignore-paths";
-	my $v = eval { command_oneline('config', '--get', $k) };
-	$self->{ignore_regex} = $v;
+	my @config = eval { command( 'config', '--get-all', $k ) };
+	chomp(@config);	# Replace all \n\r on the end
+	$self->{ignore_regex} = '(?:'.join('|', @config).')';
 
 	$k = "svn-remote.$repo_id.include-paths";
-	$v = eval { command_oneline('config', '--get', $k) };
-	$self->{include_regex} = $v;
+	@config = eval { command( 'config', '--get-all', $k ) };
+	chomp(@config);	# Replace all \n\r on the end
+	$self->{include_regex} = '(?:'.join('|', @config).')';
 
 	$k = "svn-remote.$repo_id.preserve-empty-dirs";
-	$v = eval { command_oneline('config', '--get', '--bool', $k) };
+	my $v = eval { command_oneline('config', '--get', '--bool', $k) };
 	if ($v && $v eq 'true') {
 		$_preserve_empty_dirs = 1;
 		$k = "svn-remote.$repo_id.placeholder-filename";
-- 
gitgitgadget


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

* [PATCH 2/2] sv: added: Skip commit if all files are ignored
  2020-09-11  8:00 [PATCH 0/2] GitSVN: Multi line support of ignore-path, include-paths and skiping of empty commits Lukas Pupka-Lipinski via GitGitGadget
  2020-09-11  8:00 ` [PATCH 1/2] svn: added: Multi line support for ignore-paths Lukas via GitGitGadget
@ 2020-09-11  8:00 ` Lukas via GitGitGadget
  1 sibling, 0 replies; 3+ messages in thread
From: Lukas via GitGitGadget @ 2020-09-11  8:00 UTC (permalink / raw)
  To: git; +Cc: Lukas

From: Lukas <Lukas>

I used the ignore-paths option to ignore a lot of stuff I don’t need.
The ignore pattern works well, but it could and up in empty commits.
So just the message without any modifications / changes.
The patch below skip a commit if all changes are ignored by the ignore-paths option.
In order to use this feature I includes the option to read configuration for ignore-path, include-paths in several lines.
So that the user is not limited by the max. char. per line definition.

Signed-off-by: Lukas Pupka-Lipinski <lukas.pupkalipinski@lpl-mind.de>
---
 perl/Git/SVN.pm         | 21 +++++++++++++++++++++
 perl/Git/SVN/Fetcher.pm | 30 ++++++++++++++++++++++++++++++
 perl/Git/SVN/Ra.pm      |  2 ++
 3 files changed, 53 insertions(+)

diff --git a/perl/Git/SVN.pm b/perl/Git/SVN.pm
index 4b28b87784..fa87687306 100644
--- a/perl/Git/SVN.pm
+++ b/perl/Git/SVN.pm
@@ -1188,6 +1188,22 @@ sub find_parent_branch {
 	return undef;
 }
 
+############################################################
+
+=item do_fetch()
+
+Fetch an Commit and returns a log entry
+
+Input:  $path - array of strings (Paths) in a commit
+		$rev - Revision number
+
+Output: $log_entry if successfull
+		null if skipped
+		(die) on fetch error
+
+=cut
+
+############################################################
 sub do_fetch {
 	my ($self, $paths, $rev) = @_;
 	my $ed;
@@ -1212,6 +1228,11 @@ sub do_fetch {
 		}
 		$ed = Git::SVN::Fetcher->new($self);
 	}
+	my $skip = $ed->is_empty_commit($paths);
+	if ($skip){
+		print "skip commit $rev\n";
+		return;
+	}
 	unless ($self->ra->gs_do_update($last_rev, $rev, $self, $ed)) {
 		die "SVN connection failed somewhere...\n";
 	}
diff --git a/perl/Git/SVN/Fetcher.pm b/perl/Git/SVN/Fetcher.pm
index 96b14538b0..c31343b6e6 100644
--- a/perl/Git/SVN/Fetcher.pm
+++ b/perl/Git/SVN/Fetcher.pm
@@ -139,6 +139,36 @@ sub is_path_ignored {
 	return 0;
 }
 
+############################################################
+
+=item is_empty_commit()
+
+Return 1 if all given $paths are ignored, so that this commit end up in an empty commit
+
+Input:  $path - array of strings (Paths) in a commit
+
+Output: { 1 if true, 0 if false }
+
+=cut
+
+############################################################
+sub is_empty_commit {
+	my ( $self, $paths ) = @_;
+	my $path;
+	my $ignored;
+	unless ( defined( $self->{include_regex} ) ) {
+		return 0;
+	}
+
+	foreach $path ( keys %$paths ) {
+		$ignored = $self->is_path_ignored($path);
+		if ( !$ignored ) {
+			return 0;
+		}
+	}
+	return 1;
+}
+
 sub set_path_strip {
 	my ($self, $path) = @_;
 	$self->{path_strip} = qr/^\Q$path\E(\/|$)/ if length $path;
diff --git a/perl/Git/SVN/Ra.pm b/perl/Git/SVN/Ra.pm
index 56ad9870bc..63be69dc12 100644
--- a/perl/Git/SVN/Ra.pm
+++ b/perl/Git/SVN/Ra.pm
@@ -475,6 +475,8 @@ sub gs_fetch_loop_common {
 				my $log_entry = $gs->do_fetch($paths, $r);
 				if ($log_entry) {
 					$gs->do_git_commit($log_entry);
+				}else{
+					next;
 				}
 				$Git::SVN::INDEX_FILES{$gs->{index}} = 1;
 			}
-- 
gitgitgadget

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

end of thread, other threads:[~2020-09-11  8:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-11  8:00 [PATCH 0/2] GitSVN: Multi line support of ignore-path, include-paths and skiping of empty commits Lukas Pupka-Lipinski via GitGitGadget
2020-09-11  8:00 ` [PATCH 1/2] svn: added: Multi line support for ignore-paths Lukas via GitGitGadget
2020-09-11  8:00 ` [PATCH 2/2] sv: added: Skip commit if all files are ignored Lukas via GitGitGadget

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