From: Lukas Pupka-Lipinski <lukas.pupkalipinski@lpl-mind.de>
To: git@vger.kernel.org
Cc: git@vger.kernel.org, normalperson@yhbt.net
Subject: git-svn: Skip commit if all items of a commit are ignored by ignore configuration
Date: Fri, 27 Mar 2020 09:11:41 +0100 [thread overview]
Message-ID: <b20ed6ca-1283-fb6d-a00c-94557218e01c@lpl-mind.de> (raw)
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.
Signed-off-by: Lukas Pupka-Lipinski <lukas.pupkalipinski@lpl-mind.de>
---
perl/Git/SVN/Ra.pm | 32 +++++++++++++++++++++++++++++---
1 file changed, 29 insertions(+), 3 deletions(-)
diff --git a/perl/Git/SVN/Ra.pm b/perl/Git/SVN/Ra.pm
index 56ad9870bc..a5a6c0b774 100644
--- a/perl/Git/SVN/Ra.pm
+++ b/perl/Git/SVN/Ra.pm
@@ -457,13 +457,22 @@ sub gs_fetch_loop_common {
$find_trailing_edge = 0;
}
$SVN::Error::handler = $err_handler;
-
+
my %exists = map { $_->path => $_ } @$gsv;
foreach my $r (sort {$a <=> $b} keys %revs) {
my ($paths, $logged) = @{delete $revs{$r}};
-
foreach my $gs ($self->match_globs(\%exists, $paths,
$globs, $r)) {
+
+
+ my $fetcher=Git::SVN::Fetcher->new($gs);
+
+ my $skip=$self->is_empty_commit($paths,$fetcher);
+ if ($skip){
+ print "skip commit $r\n";
+ next;
+ }
+ $fetcher->close_edit();
if ($gs->rev_map_max >= $r) {
next;
}
@@ -506,6 +517,21 @@ sub gs_fetch_loop_common {
Git::SVN::gc();
}
+sub is_empty_commit{
+ my ($self, $paths,$fetcher) = @_;
+ my $path="";
+ foreach $path (keys %$paths){
+ unless (defined $path && -d $path ){
+ my $ignored=$fetcher->is_path_ignored($path);
+ if (!$ignored){
+ return 0;
+ }
+ }
+ }
+ return 1;
+}
+
+
sub get_dir_globbed {
my ($self, $left, $depth, $r) = @_;
--
2.25.1.windows.1
next reply other threads:[~2020-03-27 8:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-27 8:11 Lukas Pupka-Lipinski [this message]
2020-03-27 8:13 ` git-svn: Skip commit if all items of a commit are ignored by ignore configuration Lukas Pupka-Lipinski
2020-03-29 23:24 ` Eric Wong
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b20ed6ca-1283-fb6d-a00c-94557218e01c@lpl-mind.de \
--to=lukas.pupkalipinski@lpl-mind.de \
--cc=git@vger.kernel.org \
--cc=normalperson@yhbt.net \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).