3 # Copyright (c) 2006 Junio C Hamano
9 my $topic_pattern = '??*/*';
11 my @stage = qw(next pu);
12 my @mark = ('.', '?', '-', '+');
18 GetOptions
("topic=s" => \
$topic_pattern,
20 "stage=s" => \
@custom_stage,
21 "mark=s" => \
@custom_mark,
22 "merges!" => \
$merges,
26 if (@custom_stage) { @stage = @custom_stage; }
27 if (@custom_mark) { @mark = @custom_mark; }
28 my @nomerges = $merges ?
qw(--no-merges) : ();
33 open(REVS
, '-|', qw(git rev-list), @nomerges, @args)
44 my ($bottom, $top, $mask) = @_;
46 open(REVS
, '-|', qw(git rev-list --pretty=oneline), @nomerges,
51 my ($sha1, $topic) = /^([0-9a-f]{40}) (.*)$/;
52 push @revs, [$sha1, $topic, $mask];
59 my ($topic, $stage, $in_next) = @_;
60 my @not_in_topic = read_revs_short
('^master', "^$topic", "$stage");
62 # @$in_next is what is in $stage but not in $base.
63 # @not_in_topic excludes what came from $topic from @$in_next.
64 # $topic can be rebased if these two set matches, because
65 # no commits in $topic has been merged to $stage yet.
66 if (@not_in_topic != @
$in_next) {
67 # we cannot rebase it anymore
70 if (read_revs_short
('master', "^$topic")) {
71 # there is something that is in master but not in topic.
74 # topic is up to date.
80 open(CONF
, '-|', qw(git repo-config --get),
81 "branch.$topic.description")
83 my $it = join('',<CONF
>);
94 ~^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
96 ~~^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
102 open(TOPIC
, '-|', qw(git for-each-ref),
103 '--sort=-authordate',
104 '--format=%(objectname) %(authordate) %(refname)',
105 "refs/heads/$topic_pattern")
108 my @in_next = read_revs_short
('^master', $stage[0]);
112 my ($sha1, $date, $topic) = m
|^([0-9a
-f
]{40})\s
(.*?
)\srefs
/heads/(.+)$|
114 my @revs = read_revs
($base, $sha1, (1<<@stage)-1);
115 next unless (@revs || $all);
117 my %revs = map { $_->[0] => $_ } @revs; # fast index
118 for (my $i = 0; $i < @stage; $i++) {
119 for my $item (read_revs_short
("^$stage[$i]", $sha1)) {
120 if (exists $revs{$item}) {
121 $revs{$item}[2] &= ~(1 << $i);
126 print '*' . rebase_marker
($sha1, $stage[0], \
@in_next);
129 $count = " " . (scalar @revs) . " commits";
132 $count = " 1 commit";
134 print " $topic ($date)$count\n";
135 describe_topic
($topic);
136 for my $item (@revs) {
137 my $mark = $item->[2];
139 $mark = $mark[$mark];
141 wrap_print
("$mark $item->[1]");