Commit b3943c83 authored by Ryan Jackson's avatar Ryan Jackson
Browse files

Fix gitmail's short_refname() to support refs containing slashes

Refs can contain slashes.  For example, the short ref for
'refs/heads/foo/bar' is 'foo/bar'.  Previously, we just chopped off
everything up to and including the last slash character, which doesn't
return the correct short ref in this case.

Call git-rev-parse to shorten the ref for us.  In case it doesn't return
anything (which shouldn't happen), fall back to the full ref.
parent 54620202
......@@ -759,9 +759,14 @@ sub send_mail($$@) {
# Given a full refname, pull off the last part for pretty printing
#
sub short_refname($) {
my ($refname) = @_;
$refname =~ /([^\/]+)$/;
return $1;
my ($ref) = @_;
my $refname = `git rev-parse --abbrev-ref $ref $STDERRNULL`;
chomp $refname;
# This shouldn't be necessary, but return the full ref if
# rev-parse doesn't return anything.
$refname = $ref if (!$refname);
return $refname;
}
#
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment