summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0775c9f)
raw | patch | inline | side by side (parent: 0775c9f)
author | Holger Weiss <holger@zedat.fu-berlin.de> | |
Sat, 7 Nov 2009 01:23:32 +0000 (02:23 +0100) | ||
committer | Holger Weiss <holger@zedat.fu-berlin.de> | |
Sat, 7 Nov 2009 01:23:32 +0000 (02:23 +0100) |
The SHA1 object name part of Gitweb URLs is now only shortened if the
user requested this by specifying the new "-z" option (or by setting
"notify.shortURLs").
While at it, also shorten the additional URL which references a diff in
e-mail notifications which don't include that diff inline because its
size exceeds the maximum number of bytes specified via "-s".
Note that while the abbreviated SHA1 object names will be unique at push
time, this cannot be guaranteed for the future, so the shortened URLs
might break some day.
user requested this by specifying the new "-z" option (or by setting
"notify.shortURLs").
While at it, also shorten the additional URL which references a diff in
e-mail notifications which don't include that diff inline because its
size exceeds the maximum number of bytes specified via "-s".
Note that while the abbreviated SHA1 object names will be unique at push
time, this cannot be guaranteed for the future, so the shortened URLs
might break some day.
tools/git-notify | patch | blob | history |
diff --git a/tools/git-notify b/tools/git-notify
index 0031fcded01201721df31823e87046dda9921afd..289a5f645a0f9f69b427edab8f6a063138d2c47f 100755 (executable)
--- a/tools/git-notify
+++ b/tools/git-notify
# -i branch If at least one -i is given, report only for specified branches
# -x branch Exclude changes to the specified branch from reports
# -X Exclude merge commits
+# -z Try to abbreviate the SHA1 name within gitweb URLs (unsafe)
#
use strict;
# base URL of the gitweb repository browser (can be set with the -u option)
my $gitweb_url = git_config( "notify.baseurl" );
+# abbreviate the SHA1 name within gitweb URLs (can be set with the -z option)
+my $abbreviate_url = git_config( "notify.shorturls" );
+
# default repository name (can be changed with the -r option)
my $repos_name = git_config( "notify.repository" ) || get_repos_name();
print " -i branch If at least one -i is given, report only for specified branches\n";
print " -x branch Exclude changes to the specified branch from reports\n";
print " -X Exclude merge commits\n";
+ print " -z Try to abbreviate the SHA1 name within gitweb URLs (unsafe)\n";
exit 1;
}
elsif ($arg eq '-i') { push @include_list, shift @ARGV; }
elsif ($arg eq '-x') { push @exclude_list, shift @ARGV; }
elsif ($arg eq '-X') { push @revlist_options, "--no-merges"; }
+ elsif ($arg eq '-z') { $abbreviate_url = 1; }
elsif ($arg eq '-d') { $debug++; }
else { usage(); }
}
my ($ref,$obj) = @_;
my %info = get_object_info($obj);
my @notice = ();
- my ($url,$subject);
+ my ($url,$subject,$obj_string);
if ($gitweb_url)
{
- open REVPARSE, "-|" or exec "git", "rev-parse", "--short", $obj or die "cannot exec git-rev-parse";
- my $short_obj = <REVPARSE>;
- close REVPARSE or die $! ? "Cannot execute rev-parse: $!" : "rev-parse exited with status: $?";
-
- $short_obj = $obj if not defined $short_obj;
- chomp $short_obj;
- $url = "$gitweb_url/?a=$info{type};h=$short_obj";
+ if ($abbreviate_url)
+ {
+ open REVPARSE, "-|" or exec "git", "rev-parse", "--short", $obj or die "cannot exec git-rev-parse";
+ $obj_string = <REVPARSE>;
+ chomp $obj_string if defined $obj_string;
+ close REVPARSE or die $! ? "Cannot execute rev-parse: $!" : "rev-parse exited with status: $?";
+ }
+ $obj_string = $obj if not defined $obj_string;
+ $url = "$gitweb_url/?a=$info{type};h=$obj_string";
}
if ($info{"type"} eq "tag")
}
else
{
- push @notice, "Diff: $gitweb_url/?a=commitdiff;h=$obj" if $gitweb_url;
+ push @notice, "Diff: $gitweb_url/?a=commitdiff;h=$obj_string" if $gitweb_url;
}
$subject = $info{"author_name"};
}