git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git-svn: Skip commit if all items of a commit are ignored by ignore configuration

From
LPLukas Pupka-Lipinski <lukas.pupkalipinski@lpl-mind.de>
Date
Mar 27, 2020, 08:11 UTC
Message-ID
<b20ed6ca-1283-fb6d-a00c-94557218e01c@lpl-mind.de>

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: Lukas Pupka-Lipinski
Message 1 of 3 in “git-svn: Skip commit if all items of a commit are ignored by ignore configuration”
  1. Lukas Pupka-LipinskiMar 27, 2020
  2. Lukas Pupka-LipinskiMar 27, 2020
  3. Eric WongMar 29, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.