{"thread":{"id":"3053","subject":"[PATCH] show-branch: make the current branch stand out.","startedAt":"2006-01-12T00:05:59Z","lastAt":"2006-01-12T00:05:59Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"14520","messageId":"7vy81mia3c.fsf@assigned-by-dhcp.cox.net","threadId":"3053","inReplyTo":null,"subject":"[PATCH] show-branch: make the current branch stand out.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-01-12T00:05:59Z","receivedAt":"2006-01-12T00:05:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This changes the character used to mark the commits that is on the\nbranch from '+' to '*' for the current branch, to make it stand out.\nWhen you have a handful branches with relatively long diversion, it\nis easier to see which one is the current branch this way.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n * Currently in \"pu\".\n\n Documentation/git-show-branch.txt            |    6 ++-\n Documentation/howto/revert-branch-rebase.txt |   24 +++++++-------\n Documentation/tutorial.txt                   |   46 +++++++++++++-------------\n show-branch.c                                |    5 ++-\n t/t1200-tutorial.sh                          |    6 ++-\n 5 files changed, 45 insertions(+), 42 deletions(-)\n\n825abb210cb5fd776a120589a1da41f6a06db191\ndiff --git a/Documentation/git-show-branch.txt b/Documentation/git-show-branch.txt\nindex 90e2a5c..a2b8eb9 100644\n--- a/Documentation/git-show-branch.txt\n+++ b/Documentation/git-show-branch.txt\n@@ -103,7 +103,7 @@ and \"mhf\":\n \n ------------------------------------------------\n $ git show-branch master fixes mhf\n-! [master] Add 'git show-branch'.\n+* [master] Add 'git show-branch'.\n  ! [fixes] Introduce \"reset type\" flag to \"git reset\"\n   ! [mhf] Allow \"+remote:local\" refspec to cause --force when fetching.\n ---\n@@ -117,13 +117,13 @@ $ git show-branch master fixes mhf\n   + [mhf~6] Retire git-parse-remote.\n   + [mhf~7] Multi-head fetch.\n   + [mhf~8] Start adding the $GIT_DIR/remotes/ support.\n-+++ [master] Add 'git show-branch'.\n+*++ [master] Add 'git show-branch'.\n ------------------------------------------------\n \n These three branches all forked from a common commit, [master],\n whose commit message is \"Add 'git show-branch'.  \"fixes\" branch\n adds one commit 'Introduce \"reset type\"'.  \"mhf\" branch has many\n-other commits.\n+other commits.  The current branch is \"master\".\n \n \n EXAMPLE\ndiff --git a/Documentation/howto/revert-branch-rebase.txt b/Documentation/howto/revert-branch-rebase.txt\nindex 5a7e0cf..a83ce1c 100644\n--- a/Documentation/howto/revert-branch-rebase.txt\n+++ b/Documentation/howto/revert-branch-rebase.txt\n@@ -32,16 +32,16 @@ merge introduced 5 commits or so:\n \n ------------------------------------------------\n $ git show-branch --more=4 master master^2 | head\n-! [master] Merge refs/heads/portable from http://www.cs.berkeley....\n+* [master] Merge refs/heads/portable from http://www.cs.berkeley....\n  ! [master^2] Replace C99 array initializers with code.\n --\n-+  [master] Merge refs/heads/portable from http://www.cs.berkeley....\n-++ [master^2] Replace C99 array initializers with code.\n-++ [master^2~1] Replace unsetenv() and setenv() with older putenv().\n-++ [master^2~2] Include sys/time.h in daemon.c.\n-++ [master^2~3] Fix ?: statements.\n-++ [master^2~4] Replace zero-length array decls with [].\n-+  [master~1] tutorial note about git branch\n+*  [master] Merge refs/heads/portable from http://www.cs.berkeley....\n+*+ [master^2] Replace C99 array initializers with code.\n+*+ [master^2~1] Replace unsetenv() and setenv() with older putenv().\n+*+ [master^2~2] Include sys/time.h in daemon.c.\n+*+ [master^2~3] Fix ?: statements.\n+*+ [master^2~4] Replace zero-length array decls with [].\n+*  [master~1] tutorial note about git branch\n ------------------------------------------------\n \n The '--more=4' above means \"after we reach the merge base of refs,\n@@ -193,8 +193,8 @@ $ git show-branch --more=1 master pu rc\n  +  [pu~4] Document \"git cherry-pick\" and \"git revert\"\n  +  [pu~5] Remove git-apply-patch-script.\n  +  [pu~6] Redo \"revert\" using three-way merge machinery.\n-  + [rc] Merge refs/heads/master from .\n-+++ [master] Revert \"Replace zero-length array decls with [].\"\n-  + [rc~1] Merge refs/heads/master from .\n-+++ [master~1] Merge refs/heads/portable from http://www.cs.berkeley....\n+  * [rc] Merge refs/heads/master from .\n+++* [master] Revert \"Replace zero-length array decls with [].\"\n+  * [rc~1] Merge refs/heads/master from .\n+++* [master~1] Merge refs/heads/portable from http://www.cs.berkeley....\n ------------------------------------------------\ndiff --git a/Documentation/tutorial.txt b/Documentation/tutorial.txt\nindex edd91cb..43a1975 100644\n--- a/Documentation/tutorial.txt\n+++ b/Documentation/tutorial.txt\n@@ -968,8 +968,8 @@ $ git show-branch master mybranch\n * [master] Merge work in mybranch\n  ! [mybranch] Some work.\n --\n-+  [master] Merge work in mybranch\n-++ [mybranch] Some work.\n+*  [master] Merge work in mybranch\n+*+ [mybranch] Some work.\n ------------------------------------------------\n \n The first two lines indicate that it is showing the two branches\n@@ -1024,7 +1024,7 @@ $ git show-branch master mybranch\n ! [master] Merge work in mybranch\n  * [mybranch] Merge work in mybranch\n --\n-++ [master] Merge work in mybranch\n++* [master] Merge work in mybranch\n ------------------------------------------------\n \n \n@@ -1199,9 +1199,9 @@ $ git show-branch --more=3 master mybran\n ! [master] Merge work in mybranch\n  * [mybranch] Merge work in mybranch\n --\n-++ [master] Merge work in mybranch\n-++ [master^2] Some work.\n-++ [master^] Some fun.\n++* [master] Merge work in mybranch\n++* [master^2] Some work.\n++* [master^] Some fun.\n ------------\n \n Remember, before running `git merge`, our `master` head was at\n@@ -1223,8 +1223,8 @@ $ git show-branch\n  ! [mybranch] Some work.\n --\n  + [mybranch] Some work.\n-+  [master] Some fun.\n-++ [mybranch^] New day.\n+*  [master] Some fun.\n+*+ [mybranch^] New day.\n ------------\n \n Now we are ready to experiment with the merge by hand.\n@@ -1743,8 +1743,8 @@ $ git show-branch\n  +  [diff-fix] Fix rename detection.\n  +  [diff-fix~1] Better common substring algorithm.\n +   [commit-fix] Fix commit message normalization.\n-  + [master] Release candidate #1\n-+++ [diff-fix~2] Pretty-print messages.\n+  * [master] Release candidate #1\n+++* [diff-fix~2] Pretty-print messages.\n ------------\n \n Both fixes are tested well, and at this point, you want to merge\n@@ -1764,13 +1764,13 @@ $ git show-branch\n  ! [diff-fix] Fix rename detection.\n   * [master] Merge fix in commit-fix\n ---\n-  + [master] Merge fix in commit-fix\n-+ + [commit-fix] Fix commit message normalization.\n-  + [master~1] Merge fix in diff-fix\n- ++ [diff-fix] Fix rename detection.\n- ++ [diff-fix~1] Better common substring algorithm.\n-  + [master~2] Release candidate #1\n-+++ [master~3] Pretty-print messages.\n+  * [master] Merge fix in commit-fix\n++ * [commit-fix] Fix commit message normalization.\n+  * [master~1] Merge fix in diff-fix\n+ +* [diff-fix] Fix rename detection.\n+ +* [diff-fix~1] Better common substring algorithm.\n+  * [master~2] Release candidate #1\n+++* [master~3] Pretty-print messages.\n ------------\n \n However, there is no particular reason to merge in one branch\n@@ -1797,12 +1797,12 @@ $ git show-branch\n  ! [diff-fix] Fix rename detection.\n   * [master] Octopus merge of branches 'diff-fix' and 'commit-fix'\n ---\n-  + [master] Octopus merge of branches 'diff-fix' and 'commit-fix'\n-+ + [commit-fix] Fix commit message normalization.\n- ++ [diff-fix] Fix rename detection.\n- ++ [diff-fix~1] Better common substring algorithm.\n-  + [master~1] Release candidate #1\n-+++ [master~2] Pretty-print messages.\n+  * [master] Octopus merge of branches 'diff-fix' and 'commit-fix'\n++ * [commit-fix] Fix commit message normalization.\n+ +* [diff-fix] Fix rename detection.\n+ +* [diff-fix~1] Better common substring algorithm.\n+  * [master~1] Release candidate #1\n+++* [master~2] Pretty-print messages.\n ------------\n \n Note that you should not do Octopus because you can.  An octopus\ndiff --git a/show-branch.c b/show-branch.c\nindex f296a87..03324aa 100644\n--- a/show-branch.c\n+++ b/show-branch.c\n@@ -545,6 +545,7 @@ int main(int ac, char **av)\n \tint sha1_name = 0;\n \tint shown_merge_point = 0;\n \tint no_current_branch = 0;\n+\tint head_at = -1;\n \n \tgit_config(git_show_branch_config);\n \tsetup_git_directory();\n@@ -696,6 +697,8 @@ int main(int ac, char **av)\n \t\t\t}\n \t\t\t/* header lines never need name */\n \t\t\tshow_one_commit(rev[i], 1);\n+\t\t\tif (is_head)\n+\t\t\t\thead_at = i;\n \t\t}\n \t\tif (0 <= extra) {\n \t\t\tfor (i = 0; i < num_rev; i++)\n@@ -725,7 +728,7 @@ int main(int ac, char **av)\n \t\tif (1 < num_rev) {\n \t\t\tfor (i = 0; i < num_rev; i++)\n \t\t\t\tputchar((this_flag & (1u << (i + REV_SHIFT)))\n-\t\t\t\t\t? '+' : ' ');\n+\t\t\t\t\t? (i == head_at ? '*' : '+') : ' ');\n \t\t\tputchar(' ');\n \t\t}\n \t\tshow_one_commit(commit, no_name);\ndiff --git a/t/t1200-tutorial.sh b/t/t1200-tutorial.sh\nindex d7562e9..7879b49 100755\n--- a/t/t1200-tutorial.sh\n+++ b/t/t1200-tutorial.sh\n@@ -118,8 +118,8 @@ cat > show-branch.expect << EOF\n * [master] Merged \"mybranch\" changes.\n  ! [mybranch] Some work.\n --\n-+  [master] Merged \"mybranch\" changes.\n-++ [mybranch] Some work.\n+*  [master] Merged \"mybranch\" changes.\n+*+ [mybranch] Some work.\n EOF\n \n git show-branch --topo-order master mybranch > show-branch.output\n@@ -142,7 +142,7 @@ cat > show-branch2.expect << EOF\n ! [master] Merged \"mybranch\" changes.\n  * [mybranch] Merged \"mybranch\" changes.\n --\n-++ [master] Merged \"mybranch\" changes.\n++* [master] Merged \"mybranch\" changes.\n EOF\n \n git show-branch --topo-order master mybranch > show-branch2.output\n-- \n1.1.1-g8ecb\n"}]}