{"thread":{"id":"28487","subject":"[PATCH] allow display of the name of the remote the current branch","startedAt":"2011-09-24T23:30:24Z","lastAt":"2011-09-24T23:30:24Z","messageCount":1,"participants":["Tom Lazar"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"176147","messageId":"A8D2EC99-E9CB-4AC4-9D37-69093F47FC88@tomster.org","threadId":"28487","inReplyTo":null,"subject":"[PATCH] allow display of the name of the remote the current branch","fromName":"Tom Lazar","fromEmail":"tom@tomster.org","sentAt":"2011-09-24T23:30:24Z","receivedAt":"2011-09-24T23:30:24Z","isPatch":true,"sender":{"key":"tom@tomster.org","avatar":null},"body":"---\n contrib/completion/git-completion.bash |   17 +++++++++++++++--\n 1 files changed, 15 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 8648a36..dd34d01 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -60,6 +60,11 @@\n #       per-repository basis by setting the bash.showUpstream config\n #       variable.\n #\n+#\t\tIf you would like to see the name of the remote that the current branch\n+#   \tis tracking, set GIT_PS1_SHOWBRANCHREMOTE to a nonempty value. If the\n+#\t\tcurrent branch is tracking a remote branch, the name of that remote is\n+#\t\tdisplayed before the branch name, separated by a colon.\n+#\n #\n # To submit patches:\n #\n@@ -217,7 +222,6 @@ __git_ps1_show_upstream ()\n \t\t\tp=\" u+${count#*\t}-${count%\t*}\" ;;\n \t\tesac\n \tfi\n-\n }\n \n \n@@ -278,6 +282,8 @@ __git_ps1 ()\n \t\tlocal u=\"\"\n \t\tlocal c=\"\"\n \t\tlocal p=\"\"\n+\t\tlocal remote=\"\"\n+\t\tlocal branch=\"\"\n \n \t\tif [ \"true\" = \"$(git rev-parse --is-inside-git-dir 2>/dev/null)\" ]; then\n \t\t\tif [ \"true\" = \"$(git rev-parse --is-bare-repository 2>/dev/null)\" ]; then\n@@ -309,10 +315,17 @@ __git_ps1 ()\n \t\t\tif [ -n \"${GIT_PS1_SHOWUPSTREAM-}\" ]; then\n \t\t\t\t__git_ps1_show_upstream\n \t\t\tfi\n+\t\t\tbranch=${b##refs/heads/}\n+            if [ -n \"${GIT_PS1_SHOWBRANCHREMOTE-}\" ]; then\n+                remote=`git config --get branch.$branch.remote`\n+                if [[ $remote ]]; then\n+                \tremote=$remote:\n+                fi\n+            fi\n \t\tfi\n \n \t\tlocal f=\"$w$i$s$u\"\n-\t\tprintf \"${1:- (%s)}\" \"$c${b##refs/heads/}${f:+ $f}$r$p\"\n+\t\tprintf \"${1:- (%s)}\" \"$c$remote$branch${f:+ $f}$r$p\"\n \tfi\n }\n \n-- \n1.7.5.4\n"}]}