summaryrefslogtreecommitdiffstats
path: root/tools/git-notify
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2010-07-02 13:28:35 (GMT)
committerHolger Weiss <holger@zedat.fu-berlin.de>2010-07-02 13:28:35 (GMT)
commit319e308521e0e460fe0b06ee093248628dda819d (patch)
treedf123d8a40351d3770dce4a02dfa15cd0a30d78f /tools/git-notify
parent5c72d075deb12239e2f1c61cf7b91e0f6ef19640 (diff)
downloadmonitoring-plugins-319e308521e0e460fe0b06ee093248628dda819d.tar.gz
git-notify: Be careful with "--no-merge"
The "-X" option (which asks git-notify to not report merge commits) was implemented by setting the "--no-merge" option on each invocation of git-rev-list(1). However, we do not only use git-rev-list(1) to get the list of new commits, but also to check whether the old branch head (or tag) is a parent of the new branch head (or tag). For this latter check, the "--no-merge" option should not be set; otherwise, git-notify would be fooled to believe that the branch has been rewritten if the old head was a merge commit.
Diffstat (limited to 'tools/git-notify')
-rwxr-xr-xtools/git-notify11
1 files changed, 6 insertions, 5 deletions
diff --git a/tools/git-notify b/tools/git-notify
index 088a580..8514296 100755
--- a/tools/git-notify
+++ b/tools/git-notify
@@ -69,6 +69,9 @@ my $gitweb_url = git_config( "notify.baseurl" );
69# abbreviate the SHA1 name within gitweb URLs (can be set with the -z option) 69# abbreviate the SHA1 name within gitweb URLs (can be set with the -z option)
70my $abbreviate_url = git_config( "notify.shorturls" ); 70my $abbreviate_url = git_config( "notify.shorturls" );
71 71
72# don't report merge commits (can be set with the -X option)
73my $ignore_merges = git_config( "notify.ignoremerges" );
74
72# enable compatibility with SourceForge's gitweb (can be set with the -S option) 75# enable compatibility with SourceForge's gitweb (can be set with the -S option)
73my $sourceforge = git_config( "notify.sourceforge" ); 76my $sourceforge = git_config( "notify.sourceforge" );
74 77
@@ -99,9 +102,6 @@ my $state_file = git_config( "notify.statefile" );
99# umask for creating the state file (can be set with -U option) 102# umask for creating the state file (can be set with -U option)
100my $mode_mask = git_config( "notify.umask" ) || 002; 103my $mode_mask = git_config( "notify.umask" ) || 002;
101 104
102# Extra options to git rev-list
103my @revlist_options;
104
105sub usage() 105sub usage()
106{ 106{
107 print "Usage: $0 [options] [--] old-sha1 new-sha1 refname\n"; 107 print "Usage: $0 [options] [--] old-sha1 new-sha1 refname\n";
@@ -145,7 +145,7 @@ sub git_rev_list(@)
145 die "Cannot open pipe: $!" if not defined $pid; 145 die "Cannot open pipe: $!" if not defined $pid;
146 if (!$pid) 146 if (!$pid)
147 { 147 {
148 exec "git", "rev-list", "--reverse", @revlist_options, @args or die "Cannot execute rev-list: $!"; 148 exec "git", "rev-list", "--reverse", @args or die "Cannot execute rev-list: $!";
149 } 149 }
150 while (<REVLIST>) 150 while (<REVLIST>)
151 { 151 {
@@ -181,6 +181,7 @@ sub get_new_commits($$)
181 181
182 @args = ( "^$old_sha1" ) unless $old_sha1 eq '0' x 40; 182 @args = ( "^$old_sha1" ) unless $old_sha1 eq '0' x 40;
183 push @args, $new_sha1, @exclude_list; 183 push @args, $new_sha1, @exclude_list;
184 unshift @args, "--no-merges" if $ignore_merges;
184 185
185 my $revlist = git_rev_list(@args); 186 my $revlist = git_rev_list(@args);
186 187
@@ -306,8 +307,8 @@ sub parse_options()
306 elsif ($arg eq '-U') { $mode_mask = shift @ARGV; } 307 elsif ($arg eq '-U') { $mode_mask = shift @ARGV; }
307 elsif ($arg eq '-u') { $gitweb_url = shift @ARGV; } 308 elsif ($arg eq '-u') { $gitweb_url = shift @ARGV; }
308 elsif ($arg eq '-i') { push @include_list, shift @ARGV; } 309 elsif ($arg eq '-i') { push @include_list, shift @ARGV; }
310 elsif ($arg eq '-X') { $ignore_merges = 1; }
309 elsif ($arg eq '-x') { push @exclude_list, shift @ARGV; } 311 elsif ($arg eq '-x') { push @exclude_list, shift @ARGV; }
310 elsif ($arg eq '-X') { push @revlist_options, "--no-merges"; }
311 elsif ($arg eq '-z') { $abbreviate_url = 1; } 312 elsif ($arg eq '-z') { $abbreviate_url = 1; }
312 elsif ($arg eq '-d') { $debug++; } 313 elsif ($arg eq '-d') { $debug++; }
313 else { usage(); } 314 else { usage(); }