Remember origin/master
is a ref that points to the head of the master branch on the remote named origin
at the last pull, so you could use a command such as
$ git log origin/master..master
You could use git-preview-push
below that comments on the output of git push --dry-run --porcelain
:
#! /usr/bin/env perl
use warnings;
use strict;
die "Usage: $0 remote refspec
" unless @ARGV == 2;
my($origin,$refspec) = @ARGV;
my @cmd = qw/ git push --dry-run --porcelain /;
no warnings 'exec';
open my $fh, "-|" => @cmd, $origin, $refspec or die "$0: exec: $!";
# <flag> <from>:<to> <summary> (<reason>)
my $update = qr/^ (.*) # flag (optional)
(S+):(S+) # from:to
(.+) # summary
(?:[ ] ((.+)))? # reason
$/x;
while (<$fh>) {
next unless my($flag,$from,$to,$summary,$reason) = /$update/;
if ($flag eq "!") {
print "$0: $refspec rejected:
", $_;
}
elsif ($flag eq "=") {
print "$0: $refspec up-to-date
";
}
if ($summary =~ /^[0-9a-f]+..[0-9a-f]+$/) {
system("git log --pretty=oneline $summary") == 0
or warn "$0: git log exited " . ($? >> 8);
}
elsif ($summary eq "[new branch]") {
print "$0: $refspec creates a new branch.
";
}
}
Example usage:
$ git preview-push /tmp/bare master
To /tmp/bare
270f8e6bec7af9b2509710eb1ae986a8e97068ec baz
4c3d1e89f5d6b0d493c9d0c7a06420d6b2eb5af7 bar
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…