Skip to content

Commit

Permalink
Let --date-order and --topo-order actually order output when --all is…
Browse files Browse the repository at this point in the history
… used
  • Loading branch information
SethRobertson committed Sep 22, 2010
1 parent 22e0742 commit a2c75e3
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 14 deletions.
6 changes: 2 additions & 4 deletions README
Expand Up @@ -37,13 +37,11 @@ DESCRIPTION
Instead of selecting the merge path which resulted in the earliest
commit to a named branch, select the merge path which resulted in the
fewest merges. If multiple merge paths have the same distance, use
earliest merge to break ties. Please note that if --all is chosen, no
ordering will be applied.
earliest merge to break ties.

--date-order
The default ordering where the merge path which resulted in the earliest
commit to a named branch is displayed. Please note that if --all is
chosen, no ordering will be applied.
commit to a named branch is displayed.

--quiet
If the commit was not made on a branch, do not print the path from the
Expand Down
48 changes: 38 additions & 10 deletions git-what-branch
Expand Up @@ -278,15 +278,10 @@ foreach my $f (@ARGV)
}
else
{
print "* $TARGET first merged onto $br using the following path:\n";
my $last = describep($TARGET);
foreach my $mp (@{$brtree{$br}->{'path'}})
{
my $newm = describep($mp);
print " $last merged up at $newm (@{[scalar(localtime($commits{$mp}->{'committime'}))]})\n";
$last = $newm;
push(@{$brtree{$br}->{'committimes'}},$commits{$mp}->{'committime'});
}
print " $last is on $br\n";
}
}
else
Expand Down Expand Up @@ -345,6 +340,41 @@ foreach my $f (@ARGV)
print "Could not find $f connected anywhere\n" unless defined($min{'tstamp'});
}
}
else
{
if (!$OPTIONS{'quiet'})
{

sub myorder
{
if ($OPTIONS{'topo-order'})
{
my $ret = $brtree{$a}->{'cnt'} <=> $brtree{$b}->{'cnt'};
$ret = $brtree{$a}->{'tstamp'} <=> $brtree{$b}->{'tstamp'} if (!$ret);
$ret;
}
else
{
$brtree{$a}->{'tstamp'} <=> $brtree{$b}->{'tstamp'};
}
}


foreach my $br (sort myorder (keys %brtree))
{
print "* $TARGET first merged onto $br using the following path:\n";
my $last = describep($TARGET);
foreach my $mp (@{$brtree{$br}->{'path'}})
{
my $newm = describep($mp);
my $ctime = shift(@{$brtree{$br}->{'committimes'}});
print " $last merged up at $newm (@{[scalar(localtime($ctime))]})\n";
$last = $newm;
}
print " $last is on $br\n";
}
}
}
}
print "----------------------------------------\n" if ($MULTI);
}
Expand Down Expand Up @@ -401,14 +431,12 @@ named branches that it was committed onto are printed.
Instead of selecting the merge path which resulted in the earliest
commit to a named branch, select the merge path which resulted in the
fewest merges. If multiple merge paths have the same distance, use
earliest merge to break ties. Please note that if --all is chosen, no
ordering will be applied.
earliest merge to break ties.
=head2 --date-order
The default ordering where the merge path which resulted in the
earliest commit to a named branch is displayed. Please note that if
--all is chosen, no ordering will be applied.
earliest commit to a named branch is displayed.
=head2 --quiet
Expand Down

0 comments on commit a2c75e3

Please sign in to comment.