Skip to contentSkip to conversation

show-branch: make the current branch stand out.

PATCH New Junio C Hamano 1 participant 1 message Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 show-branch: make the current branch 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. When you have a handful branches with relatively long diversion, it is easier to see which one is the current branch this way.

---
* Currently in "pu".

 Documentation/git-show-branch.txt            |    6 ++-
 Documentation/howto/revert-branch-rebase.txt |   24 +++++++-------
 Documentation/tutorial.txt                   |   46 +++++++++++++-------------
 show-branch.c                                |    5 ++-
 t/t1200-tutorial.sh                          |    6 ++-
 5 files changed, 45 insertions(+), 42 deletions(-)

825abb210cb5fd776a120589a1da41f6a06db191

Documentation/git-show-branch.txt +3 -3
index 90e2a5c..a2b8eb9 100644
@@ -103,7 +103,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.
 ---
@@ -117,13 +117,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
Documentation/howto/revert-branch-rebase.txt +12 -12
index 5a7e0cf..a83ce1c 100644
@@ -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....
 ------------------------------------------------
Documentation/tutorial.txt +23 -23

88 lines not on this page · raw message

show-branch.c +4 -1
index f296a87..03324aa 100644
@@ -545,6 +545,7 @@ int main(int ac, char **av)
 	int sha1_name = 0;
 	int shown_merge_point = 0;
 	int no_current_branch = 0;
+	int head_at = -1;
 
 	git_config(git_show_branch_config);
 	setup_git_directory();
@@ -696,6 +697,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++)
@@ -725,7 +728,7 @@ int main(int ac, char **av)
 		if (1 < num_rev) {
 			for (i = 0; i < num_rev; i++)
 				putchar((this_flag & (1u << (i + REV_SHIFT)))
-					? '+' : ' ');
+					? (i == head_at ? '*' : '+') : ' ');
 			putchar(' ');
 		}
 		show_one_commit(commit, no_name);
t/t1200-tutorial.sh +3 -3
index d7562e9..7879b49 100755
@@ -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
Signature · 1 line
1.1.1-g8ecb