Code

git-notify: Ignore "empty" commits
authorHolger Weiss <holger@zedat.fu-berlin.de>
Sat, 24 Oct 2009 09:44:16 +0000 (11:44 +0200)
committerHolger Weiss <holger@zedat.fu-berlin.de>
Sat, 24 Oct 2009 09:44:16 +0000 (11:44 +0200)
Omit notifications regarding commits which don't change the tree
whatsoever.

tools/git-notify

index 1b10f69050932f9e19349b25823d6bf9a70e801a..ccde4bee6e186bf06992b3308d6caf6905e9bd21 100755 (executable)
@@ -230,6 +230,12 @@ sub send_commit_notice($$)
     my %info = get_object_info($obj);
     my @notice = ();
 
+    open DIFF, "-|" or exec "git", "diff-tree", "-p", "-M", "--no-commit-id", $obj or die "cannot exec git-diff-tree";
+    my $diff = join("", <DIFF>);
+    close DIFF;
+
+    return if length($diff) == 0;
+
     push @notice,
         "Module: $repos_name",
         "Branch: $ref",
@@ -247,10 +253,6 @@ sub send_commit_notice($$)
     push @notice, join("", <STAT>);
     close STAT;
 
-    open DIFF, "-|" or exec "git", "diff-tree", "-p", "-M", "--no-commit-id", $obj or die "cannot exec git-diff-tree";
-    my $diff = join( "", <DIFF> );
-    close DIFF;
-
     if (($max_diff_size == -1) || (length($diff) < $max_diff_size))
     {
         push @notice, $diff;