зеркало из https://github.com/microsoft/git.git
show-branch: make the current branch and merge commits stand out.
This changes the character used to mark the commits that is on the branch from '+' to '*' for the current branch, to make it stand out. Also we show '-' for merge commits. When you have a handful branches with relatively long diversion, it is easier to see which one is the current branch this way. Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Родитель
54f9734ec8
Коммит
ebedc31952
|
@ -81,13 +81,14 @@ OUTPUT
|
|||
------
|
||||
Given N <references>, the first N lines are the one-line
|
||||
description from their commit message. The branch head that is
|
||||
pointed at by $GIT_DIR/HEAD is prefixed with an asterisk '*'
|
||||
character while other heads are prefixed with a '!' character.
|
||||
pointed at by $GIT_DIR/HEAD is prefixed with an asterisk `*`
|
||||
character while other heads are prefixed with a `!` character.
|
||||
|
||||
Following these N lines, one-line log for each commit is
|
||||
displayed, indented N places. If a commit is on the I-th
|
||||
branch, the I-th indentation character shows a '+' sign;
|
||||
otherwise it shows a space. Each commit shows a short name that
|
||||
branch, the I-th indentation character shows a `+` sign;
|
||||
otherwise it shows a space. Merge commits are denoted by
|
||||
a `-` sign. Each commit shows a short name that
|
||||
can be used as an extended SHA1 to name that commit.
|
||||
|
||||
The following example shows three branches, "master", "fixes"
|
||||
|
@ -95,7 +96,7 @@ and "mhf":
|
|||
|
||||
------------------------------------------------
|
||||
$ git show-branch master fixes mhf
|
||||
! [master] Add 'git show-branch'.
|
||||
* [master] Add 'git show-branch'.
|
||||
! [fixes] Introduce "reset type" flag to "git reset"
|
||||
! [mhf] Allow "+remote:local" refspec to cause --force when fetching.
|
||||
---
|
||||
|
@ -109,13 +110,13 @@ $ git show-branch master fixes mhf
|
|||
+ [mhf~6] Retire git-parse-remote.
|
||||
+ [mhf~7] Multi-head fetch.
|
||||
+ [mhf~8] Start adding the $GIT_DIR/remotes/ support.
|
||||
+++ [master] Add 'git show-branch'.
|
||||
*++ [master] Add 'git show-branch'.
|
||||
------------------------------------------------
|
||||
|
||||
These three branches all forked from a common commit, [master],
|
||||
whose commit message is "Add 'git show-branch'. "fixes" branch
|
||||
adds one commit 'Introduce "reset type"'. "mhf" branch has many
|
||||
other commits.
|
||||
other commits. The current branch is "master".
|
||||
|
||||
|
||||
EXAMPLE
|
||||
|
|
|
@ -32,16 +32,16 @@ merge introduced 5 commits or so:
|
|||
|
||||
------------------------------------------------
|
||||
$ git show-branch --more=4 master master^2 | head
|
||||
! [master] Merge refs/heads/portable from http://www.cs.berkeley....
|
||||
* [master] Merge refs/heads/portable from http://www.cs.berkeley....
|
||||
! [master^2] Replace C99 array initializers with code.
|
||||
--
|
||||
+ [master] Merge refs/heads/portable from http://www.cs.berkeley....
|
||||
++ [master^2] Replace C99 array initializers with code.
|
||||
++ [master^2~1] Replace unsetenv() and setenv() with older putenv().
|
||||
++ [master^2~2] Include sys/time.h in daemon.c.
|
||||
++ [master^2~3] Fix ?: statements.
|
||||
++ [master^2~4] Replace zero-length array decls with [].
|
||||
+ [master~1] tutorial note about git branch
|
||||
- [master] Merge refs/heads/portable from http://www.cs.berkeley....
|
||||
*+ [master^2] Replace C99 array initializers with code.
|
||||
*+ [master^2~1] Replace unsetenv() and setenv() with older putenv().
|
||||
*+ [master^2~2] Include sys/time.h in daemon.c.
|
||||
*+ [master^2~3] Fix ?: statements.
|
||||
*+ [master^2~4] Replace zero-length array decls with [].
|
||||
* [master~1] tutorial note about git branch
|
||||
------------------------------------------------
|
||||
|
||||
The '--more=4' above means "after we reach the merge base of refs,
|
||||
|
@ -193,8 +193,8 @@ $ git show-branch --more=1 master pu rc
|
|||
+ [pu~4] Document "git cherry-pick" and "git revert"
|
||||
+ [pu~5] Remove git-apply-patch-script.
|
||||
+ [pu~6] Redo "revert" using three-way merge machinery.
|
||||
+ [rc] Merge refs/heads/master from .
|
||||
+++ [master] Revert "Replace zero-length array decls with []."
|
||||
+ [rc~1] Merge refs/heads/master from .
|
||||
+++ [master~1] Merge refs/heads/portable from http://www.cs.berkeley....
|
||||
- [rc] Merge refs/heads/master from .
|
||||
++* [master] Revert "Replace zero-length array decls with []."
|
||||
- [rc~1] Merge refs/heads/master from .
|
||||
... [master~1] Merge refs/heads/portable from http://www.cs.berkeley....
|
||||
------------------------------------------------
|
||||
|
|
|
@ -968,8 +968,8 @@ $ git show-branch master mybranch
|
|||
* [master] Merge work in mybranch
|
||||
! [mybranch] Some work.
|
||||
--
|
||||
+ [master] Merge work in mybranch
|
||||
++ [mybranch] Some work.
|
||||
- [master] Merge work in mybranch
|
||||
*+ [mybranch] Some work.
|
||||
------------------------------------------------
|
||||
|
||||
The first two lines indicate that it is showing the two branches
|
||||
|
@ -979,7 +979,8 @@ top-of-the-tree commits, you are currently on `master` branch
|
|||
the later output lines is used to show commits contained in the
|
||||
`master` branch, and the second column for the `mybranch`
|
||||
branch. Three commits are shown along with their log messages.
|
||||
All of them have plus `+` characters in the first column, which
|
||||
All of them have non blank characters in the first column (`*`
|
||||
shows an ordinary commit on the current branch, `.` is a merge commit), which
|
||||
means they are now part of the `master` branch. Only the "Some
|
||||
work" commit has the plus `+` character in the second column,
|
||||
because `mybranch` has not been merged to incorporate these
|
||||
|
@ -1024,7 +1025,7 @@ $ git show-branch master mybranch
|
|||
! [master] Merge work in mybranch
|
||||
* [mybranch] Merge work in mybranch
|
||||
--
|
||||
++ [master] Merge work in mybranch
|
||||
-- [master] Merge work in mybranch
|
||||
------------------------------------------------
|
||||
|
||||
|
||||
|
@ -1199,9 +1200,9 @@ $ git show-branch --more=3 master mybranch
|
|||
! [master] Merge work in mybranch
|
||||
* [mybranch] Merge work in mybranch
|
||||
--
|
||||
++ [master] Merge work in mybranch
|
||||
++ [master^2] Some work.
|
||||
++ [master^] Some fun.
|
||||
-- [master] Merge work in mybranch
|
||||
+* [master^2] Some work.
|
||||
+* [master^] Some fun.
|
||||
------------
|
||||
|
||||
Remember, before running `git merge`, our `master` head was at
|
||||
|
@ -1223,8 +1224,8 @@ $ git show-branch
|
|||
! [mybranch] Some work.
|
||||
--
|
||||
+ [mybranch] Some work.
|
||||
+ [master] Some fun.
|
||||
++ [mybranch^] New day.
|
||||
* [master] Some fun.
|
||||
*+ [mybranch^] New day.
|
||||
------------
|
||||
|
||||
Now we are ready to experiment with the merge by hand.
|
||||
|
@ -1743,8 +1744,8 @@ $ git show-branch
|
|||
+ [diff-fix] Fix rename detection.
|
||||
+ [diff-fix~1] Better common substring algorithm.
|
||||
+ [commit-fix] Fix commit message normalization.
|
||||
+ [master] Release candidate #1
|
||||
+++ [diff-fix~2] Pretty-print messages.
|
||||
* [master] Release candidate #1
|
||||
++* [diff-fix~2] Pretty-print messages.
|
||||
------------
|
||||
|
||||
Both fixes are tested well, and at this point, you want to merge
|
||||
|
@ -1764,13 +1765,13 @@ $ git show-branch
|
|||
! [diff-fix] Fix rename detection.
|
||||
* [master] Merge fix in commit-fix
|
||||
---
|
||||
+ [master] Merge fix in commit-fix
|
||||
+ + [commit-fix] Fix commit message normalization.
|
||||
+ [master~1] Merge fix in diff-fix
|
||||
++ [diff-fix] Fix rename detection.
|
||||
++ [diff-fix~1] Better common substring algorithm.
|
||||
+ [master~2] Release candidate #1
|
||||
+++ [master~3] Pretty-print messages.
|
||||
- [master] Merge fix in commit-fix
|
||||
+ * [commit-fix] Fix commit message normalization.
|
||||
- [master~1] Merge fix in diff-fix
|
||||
+* [diff-fix] Fix rename detection.
|
||||
+* [diff-fix~1] Better common substring algorithm.
|
||||
* [master~2] Release candidate #1
|
||||
++* [master~3] Pretty-print messages.
|
||||
------------
|
||||
|
||||
However, there is no particular reason to merge in one branch
|
||||
|
@ -1797,12 +1798,12 @@ $ git show-branch
|
|||
! [diff-fix] Fix rename detection.
|
||||
* [master] Octopus merge of branches 'diff-fix' and 'commit-fix'
|
||||
---
|
||||
+ [master] Octopus merge of branches 'diff-fix' and 'commit-fix'
|
||||
+ + [commit-fix] Fix commit message normalization.
|
||||
++ [diff-fix] Fix rename detection.
|
||||
++ [diff-fix~1] Better common substring algorithm.
|
||||
+ [master~1] Release candidate #1
|
||||
+++ [master~2] Pretty-print messages.
|
||||
- [master] Octopus merge of branches 'diff-fix' and 'commit-fix'
|
||||
+ * [commit-fix] Fix commit message normalization.
|
||||
+* [diff-fix] Fix rename detection.
|
||||
+* [diff-fix~1] Better common substring algorithm.
|
||||
* [master~1] Release candidate #1
|
||||
++* [master~2] Pretty-print messages.
|
||||
------------
|
||||
|
||||
Note that you should not do Octopus because you can. An octopus
|
||||
|
|
|
@ -545,6 +545,7 @@ int main(int ac, char **av)
|
|||
int sha1_name = 0;
|
||||
int shown_merge_point = 0;
|
||||
int topo_order = 0;
|
||||
int head_at = -1;
|
||||
|
||||
git_config(git_show_branch_config);
|
||||
setup_git_directory();
|
||||
|
@ -675,6 +676,8 @@ int main(int ac, char **av)
|
|||
}
|
||||
/* header lines never need name */
|
||||
show_one_commit(rev[i], 1);
|
||||
if (is_head)
|
||||
head_at = i;
|
||||
}
|
||||
if (0 <= extra) {
|
||||
for (i = 0; i < num_rev; i++)
|
||||
|
@ -703,9 +706,19 @@ int main(int ac, char **av)
|
|||
shown_merge_point |= ((this_flag & all_revs) == all_revs);
|
||||
|
||||
if (1 < num_rev) {
|
||||
for (i = 0; i < num_rev; i++)
|
||||
putchar((this_flag & (1u << (i + REV_SHIFT)))
|
||||
? '+' : ' ');
|
||||
int is_merge = !!(commit->parents && commit->parents->next);
|
||||
for (i = 0; i < num_rev; i++) {
|
||||
int mark;
|
||||
if (!(this_flag & (1u << (i + REV_SHIFT))))
|
||||
mark = ' ';
|
||||
else if (is_merge)
|
||||
mark = '-';
|
||||
else if (i == head_at)
|
||||
mark = '*';
|
||||
else
|
||||
mark = '+';
|
||||
putchar(mark);
|
||||
}
|
||||
putchar(' ');
|
||||
}
|
||||
show_one_commit(commit, no_name);
|
||||
|
|
|
@ -118,8 +118,8 @@ cat > show-branch.expect << EOF
|
|||
* [master] Merged "mybranch" changes.
|
||||
! [mybranch] Some work.
|
||||
--
|
||||
+ [master] Merged "mybranch" changes.
|
||||
++ [mybranch] Some work.
|
||||
- [master] Merged "mybranch" changes.
|
||||
*+ [mybranch] Some work.
|
||||
EOF
|
||||
|
||||
git show-branch --topo-order master mybranch > show-branch.output
|
||||
|
@ -142,7 +142,7 @@ cat > show-branch2.expect << EOF
|
|||
! [master] Merged "mybranch" changes.
|
||||
* [mybranch] Merged "mybranch" changes.
|
||||
--
|
||||
++ [master] Merged "mybranch" changes.
|
||||
-- [master] Merged "mybranch" changes.
|
||||
EOF
|
||||
|
||||
git show-branch --topo-order master mybranch > show-branch2.output
|
||||
|
|
Загрузка…
Ссылка в новой задаче