зеркало из https://github.com/microsoft/git.git
Prettyprint octopus merge message.
Including the current branch in the list of heads being merged was not a good idea, so drop it. And shorten the message by grouping branches and tags together to form a single line. Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Родитель
f8ff0c0641
Коммит
c8b48ba476
2
Makefile
2
Makefile
|
@ -87,7 +87,7 @@ SCRIPT_SH = \
|
|||
|
||||
SCRIPT_PERL = \
|
||||
git-archimport.perl git-cvsimport.perl git-relink.perl \
|
||||
git-rename.perl git-shortlog.perl
|
||||
git-rename.perl git-shortlog.perl git-fmt-merge-msg.perl
|
||||
|
||||
SCRIPT_PYTHON = \
|
||||
git-merge-recursive.py
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (c) 2005 Junio C Hamano
|
||||
#
|
||||
# Read .git/FETCH_HEAD and make a human readable merge message
|
||||
# by grouping branches and tags together to form a single line.
|
||||
|
||||
use strict;
|
||||
|
||||
my @src;
|
||||
my %src;
|
||||
sub andjoin {
|
||||
my ($label, $labels, $stuff) = @_;
|
||||
my $l = scalar @$stuff;
|
||||
my $m = '';
|
||||
if ($l == 0) {
|
||||
return ();
|
||||
}
|
||||
if ($l == 1) {
|
||||
$m = "$label$stuff->[0]";
|
||||
}
|
||||
else {
|
||||
$m = ("$labels" .
|
||||
join (', ', @{$stuff}[0..$l-2]) .
|
||||
" and $stuff->[-1]");
|
||||
}
|
||||
return ($m);
|
||||
}
|
||||
|
||||
while (<>) {
|
||||
my ($bname, $tname, $gname, $src);
|
||||
chomp;
|
||||
s/^[0-9a-f]* //;
|
||||
if (s/ of (.*)$//) {
|
||||
$src = $1;
|
||||
} else {
|
||||
# Pulling HEAD
|
||||
$src = $_;
|
||||
$_ = 'HEAD';
|
||||
}
|
||||
if (! exists $src{$src}) {
|
||||
push @src, $src;
|
||||
$src{$src} = {
|
||||
BRANCH => [],
|
||||
TAG => [],
|
||||
GENERIC => [],
|
||||
# &1 == has HEAD.
|
||||
# &2 == has others.
|
||||
HEAD_STATUS => 0,
|
||||
};
|
||||
}
|
||||
if (/^branch (.*)$/) {
|
||||
push @{$src{$src}{BRANCH}}, $1;
|
||||
$src{$src}{HEAD_STATUS} |= 2;
|
||||
}
|
||||
elsif (/^tag (.*)$/) {
|
||||
push @{$src{$src}{TAG}}, $1;
|
||||
$src{$src}{HEAD_STATUS} |= 2;
|
||||
}
|
||||
elsif (/^HEAD$/) {
|
||||
$src{$src}{HEAD_STATUS} |= 1;
|
||||
}
|
||||
else {
|
||||
push @{$src{$src}{GENERIC}}, $_;
|
||||
$src{$src}{HEAD_STATUS} |= 2;
|
||||
}
|
||||
}
|
||||
|
||||
my @msg;
|
||||
for my $src (@src) {
|
||||
if ($src{$src}{HEAD_STATUS} == 1) {
|
||||
# Only HEAD is fetched, nothing else.
|
||||
push @msg, $src;
|
||||
next;
|
||||
}
|
||||
my @this;
|
||||
if ($src{$src}{HEAD_STATUS} == 3) {
|
||||
# HEAD is fetched among others.
|
||||
push @this, andjoin('', '', ['HEAD']);
|
||||
}
|
||||
push @this, andjoin("branch ", "branches ",
|
||||
$src{$src}{BRANCH});
|
||||
push @this, andjoin("tag ", "tags ",
|
||||
$src{$src}{TAG});
|
||||
push @this, andjoin("commit ", "commits ",
|
||||
$src{$src}{GENERIC});
|
||||
my $this = join(', ', @this);
|
||||
if ($src ne '.') {
|
||||
$this .= " from $src";
|
||||
}
|
||||
push @msg, $this;
|
||||
}
|
||||
print "Merge ", join("; ", @msg), "\n";
|
|
@ -27,7 +27,7 @@ test "$(git-diff-index --cached "$head")" = "" ||
|
|||
# MRC is the current "merge reference commit"
|
||||
# MRT is the current "merge result tree"
|
||||
|
||||
MRC=$head MSG= PARENT="-p $head"
|
||||
MRC=$head PARENT="-p $head"
|
||||
MRT=$(git-write-tree)
|
||||
CNT=1 ;# counting our head
|
||||
NON_FF_MERGE=0
|
||||
|
@ -44,8 +44,6 @@ do
|
|||
|
||||
CNT=`expr $CNT + 1`
|
||||
PARENT="$PARENT -p $SHA1"
|
||||
MSG="$MSG
|
||||
$REPO"
|
||||
|
||||
if test "$common,$NON_FF_MERGE" = "$MRC,0"
|
||||
then
|
||||
|
@ -84,20 +82,9 @@ case "$CNT" in
|
|||
1)
|
||||
echo "No changes."
|
||||
exit 0 ;;
|
||||
2)
|
||||
echo "Not an Octopus; making an ordinary commit."
|
||||
MSG="Merge "`expr "$MSG" : '. \(.*\)'` ; # remove LF and TAB
|
||||
;;
|
||||
*)
|
||||
# In an octopus, the original head is just one of the equals,
|
||||
# so we should list it as such.
|
||||
HEAD_LINK=`readlink "$GIT_DIR/HEAD"`
|
||||
MSG="Octopus merge of the following:
|
||||
|
||||
$HEAD_LINK from .$MSG"
|
||||
;;
|
||||
esac
|
||||
result_commit=$(echo "$MSG" | git-commit-tree $MRT $PARENT)
|
||||
result_commit=$(git-fmt-merge-msg <"$GIT_DIR/FETCH_HEAD" |
|
||||
git-commit-tree $MRT $PARENT)
|
||||
echo "Committed merge $result_commit"
|
||||
echo $result_commit >"$GIT_DIR"/HEAD
|
||||
git-diff-tree -p $head $result_commit | git-apply --stat
|
||||
|
|
|
@ -25,10 +25,6 @@ then
|
|||
fi
|
||||
|
||||
merge_head=$(sed -e 's/ .*//' "$GIT_DIR"/FETCH_HEAD | tr '\012' ' ')
|
||||
merge_name=$(
|
||||
perl -e 'print join("; ", map { chomp; s/^[0-9a-f]* //; $_ } <>)' \
|
||||
"$GIT_DIR"/FETCH_HEAD
|
||||
)
|
||||
|
||||
case "$merge_head" in
|
||||
'')
|
||||
|
@ -41,6 +37,5 @@ case "$merge_head" in
|
|||
;;
|
||||
esac
|
||||
|
||||
git-resolve \
|
||||
"$(cat "$GIT_DIR"/HEAD)" \
|
||||
$merge_head "Merge $merge_name"
|
||||
merge_name=$(git-fmt-merge-msg <"$GIT_DIR/FETCH_HEAD")
|
||||
git-resolve "$(cat "$GIT_DIR"/HEAD)" $merge_head "$merge_name"
|
||||
|
|
Загрузка…
Ссылка в новой задаче