Permalink
Browse files

fixes and improvements to git-ff

Better warning behavior
Fix bug in use of git-update-ref by '-r' mode
Don't fast-forward if source and target are identical
  • Loading branch information...
1 parent dfd0438 commit ea72ff7e9c892a0878a44c96bb947ba461024d72 @mjdominus committed Mar 25, 2012
Showing with 5 additions and 4 deletions.
  1. +5 −4 git-ff
View
9 git-ff
@@ -23,17 +23,14 @@ if ($remote_name) {
my $tracking = qx{git-get branch-remote '$head'};
next unless $tracking eq $remote_name;
my $remote_branch = qx{git-get branch-remote-branch '$head'};
- warn "$head -> $remote_branch" if $opt{v};
ff_ref($head, $remote_branch);
}
} else {
my ($refname, $target) = @ARGV;
$refname ||= qx{git get current-branch-name}
or error "Can't fast-forward detached HEAD";
$refname or usage();
- $refname = qx{git rev-parse --symbolic-full-name '$refname'} or exit 1;
- chomp($refname);
- $target ||= qx{git get branch-remote '$refname'}
+ $target ||= qx{git get branch-remote-branch '$refname'}
or error "Can't find upstream branch for '$refname'";
ff_ref($refname, $target, "die on failure");
}
@@ -44,7 +41,11 @@ sub ff_ref {
die "Can't fast-forward $ref to $target\n" if $die_on_failure;
return;
}
+ return if system("git", "get", "is-same-object", $ref, $target) == 0;
+ chomp($ref = qx{git rev-parse --symbolic-full-name '$ref'});
+ $ref || die "Can't find symbolic-full-name of '$ref'\n";
exit 2 unless system("git", "update-ref", "-m", "merge $target: Fast-forward", $ref, $target) == 0;
+ warn "$ref -> $target\n" if $opt{v};
}
sub error {

0 comments on commit ea72ff7

Please sign in to comment.