{"thread":{"id":"1519","subject":"[PATCH] Add git-show-branches-script","startedAt":"2005-08-15T09:56:06Z","lastAt":"2005-08-15T09:56:06Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"7294","messageId":"7v4q9r1q2x.fsf@assigned-by-dhcp.cox.net","threadId":"1519","inReplyTo":null,"subject":"[PATCH] Add git-show-branches-script","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-08-15T09:56:06Z","receivedAt":"2005-08-15T09:56:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Often I find myself wanting to do quick branches check when I am\nnot in the windowing environment and cannot run gitk.\n\nThis stupid script shows commits leading to the heads of\ninteresting branches with indication which ones belong to which\nbranches, so that fork point is somewhat discernible without\nusing gitk.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n Documentation/git-show-branches-script.txt |   69 ++++++++++++++++++++++++++++\n Documentation/git.txt                      |    2 +\n Makefile                                   |    1 \n git-show-branches-script                   |   53 ++++++++++++++++++++++\n 4 files changed, 125 insertions(+), 0 deletions(-)\n create mode 100644 Documentation/git-show-branches-script.txt\n create mode 100755 git-show-branches-script\n\n8d67319c6e28035abdb848b9b2f31a8c5711bd49\ndiff --git a/Documentation/git-show-branches-script.txt b/Documentation/git-show-branches-script.txt\nnew file mode 100644\n--- /dev/null\n+++ b/Documentation/git-show-branches-script.txt\n@@ -0,0 +1,69 @@\n+git-show-branches-script(1)\n+===========================\n+v0.99.4, Aug 2005\n+\n+NAME\n+----\n+git-show-branches-script - Show branches and their commits.\n+\n+SYNOPSIS\n+--------\n+'git show-branches <reference>...'\n+\n+DESCRIPTION\n+-----------\n+Shows the head commits from the named <reference> (or all refs under\n+$GIT_DIR/refs/heads), and displays concise list of commit logs\n+to show their relationship semi-visually.\n+\n+OPTIONS\n+-------\n+<reference>::\n+\tName of the reference under $GIT_DIR/refs/heads/.\n+\n+\n+OUTPUT\n+------\n+Given N <references>, the first N lines are the one-line\n+description from their commit message.  The branch head that is\n+pointed at by $GIT_DIR/HEAD is prefixed with an asterisk '*'\n+character while other heads are prefixed with a '!' character.\n+\n+Following these N lines, one-line log for each commit is\n+displayed, indented N places.  If a commit is on the I-th\n+branch, the I-th indentation character shows a '+' sign;\n+otherwise it shows a space.\n+\n+The following example shows three branches, \"pu\", \"master\" and\n+\"rc\":\n+\n+\t* [pu] Add cheap local clone '-s' flag to git-clone-script\n+\t ! [master] Documentation updates.\n+\t  ! [rc] Merge master into rc\n+\t+   Add cheap local clone '-s' flag to git-clone-script\n+\t+   Alternate object pool mechanism updates.\n+\t+   Audit rev-parse users.\n+\t++  Documentation updates.\n+\t  + Merge master into rc\n+\t+++ [PATCH] plug memory leak in diff.c::diff_free_filepair()\n+\n+These three branches all forked from a common commit, \"[PATCH]\n+plug memory leak...\", and \"rc\" has one commit ahead of it.  The\n+\"master\" branch has one different commit that is also shared by\n+\"pu\" branch, and \"pu\" branch has three more commits on top of\n+\"master\" branch.\n+\n+\n+Author\n+------\n+Written by Junio C Hamano <junkio@cox.net>\n+\n+\n+Documentation\n+--------------\n+Documentation by Junio C Hamano.\n+\n+\n+GIT\n+---\n+Part of the link:git.html[git] suite\ndiff --git a/Documentation/git.txt b/Documentation/git.txt\n--- a/Documentation/git.txt\n+++ b/Documentation/git.txt\n@@ -188,6 +188,8 @@ link:git-pull-script.html[git-pull-scrip\n link:git-commit-script.html[git-commit-script]::\n \tRecord changes to the repository.\n \n+link:git-show-branches-script.html[git-show-branches-script]::\n+\tShow branches and their commits.\n \n Ancilliary Commands\n -------------------\ndiff --git a/Makefile b/Makefile\n--- a/Makefile\n+++ b/Makefile\n@@ -71,6 +71,7 @@ SCRIPTS=git git-apply-patch-script git-m\n SCRIPTS += git-count-objects-script\n # SCRIPTS += git-send-email-script\n SCRIPTS += git-revert-script\n+SCRIPTS += git-show-branches-script\n \n PROG=   git-update-cache git-diff-files git-init-db git-write-tree \\\n \tgit-read-tree git-commit-tree git-cat-file git-fsck-cache \\\ndiff --git a/git-show-branches-script b/git-show-branches-script\nnew file mode 100755\n--- /dev/null\n+++ b/git-show-branches-script\n@@ -0,0 +1,53 @@\n+#!/bin/sh\n+#\n+# Show refs and their recent commits.\n+#\n+\n+. git-sh-setup-script || die \"Not a git repository\"\n+\n+headref=`readlink $GIT_DIR/HEAD`\n+case \"$#\" in\n+0)\n+\tset x `cd $GIT_DIR/refs &&\n+\t    find heads -type f -print |\n+\t    sed -e 's|heads/||' |\n+\t    sort`\n+\tshift ;;\n+esac\n+\n+hh= in=\n+for ref\n+do\n+\tcase \"/$headref\" in\n+\t*/\"$ref\") H='*' ;;\n+\t*) H='!' ;;\n+\tesac\n+\th=`git-rev-parse --verify \"$ref^0\"` || exit\n+\tl=`git-log-script --max-count=1 --pretty=oneline \"$h\" |\n+\t\tsed -e 's/^[^ ]* //'`\n+\thh=\"$hh $h\"\n+\techo \"$in$H [$ref] $l\"\n+\tin=\"$in \"\n+done\n+set x $hh\n+shift\n+\n+git-rev-list --pretty=oneline \"$@\" |\n+while read v l\n+do\n+\tin=''\n+\tfor h\n+\tdo\n+\t\tb=`git-merge-base $h $v`\n+\t\tcase \"$b\" in\n+\t\t$v) in=\"$in+\" ;;\n+\t\t*)  in=\"$in \" ;;\n+\t\tesac\n+\tdone\n+\n+\techo \"$in $l\"\n+\tcase \"$in\" in\n+\t*' '*) ;;\n+\t*) break ;;\n+\tesac\n+done\n"}]}