{"thread":{"id":"35097","subject":"[PATCH] git-prompt.sh: show the upstream abbrev name","startedAt":"2013-10-10T13:32:13Z","lastAt":"2013-10-15T12:21:11Z","messageCount":5,"participants":["Julien Carsique","SZEDER Gábor"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"228693","messageId":"1381411933-20600-1-git-send-email-jcarsique@nuxeo.com","threadId":"35097","inReplyTo":null,"subject":"[PATCH] git-prompt.sh: show the upstream abbrev name","fromName":"Julien Carsique","fromEmail":"julien.carsique@gmail.com","sentAt":"2013-10-10T13:32:13Z","receivedAt":"2013-10-10T13:32:13Z","isPatch":true,"sender":{"key":"julien.carsique@gmail.com","avatar":"https://avatars.githubusercontent.com/u/81140?v=4"},"body":"From: Julien Carsique <julien.carsique@gmail.com>\n\nWhen working with multiple remotes, it is common to switch the upstream\nfrom a remote to another. Doing so, the prompt may not be the expected\none. Providing an option to display tracking information sounds useful.\n\nAdd a \"name\" option to GIT_PS1_SHOWUPSTREAM which will show the upstream\nabbrev name. This option is ignored if \"verbose\" is false.\n\nSigned-off-by: Julien Carsique <julien.carsique@gmail.com>\n---\n contrib/completion/git-prompt.sh | 7 ++++++-\n 1 file changed, 6 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex d6c61b2..452f7ee 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -60,6 +60,7 @@\n # of values:\n #\n #     verbose       show number of commits ahead/behind (+/-) upstream\n+#     name          if verbose, then also show the upstream abbrev name\n #     legacy        don't use the '--count' option available in recent\n #                   versions of git-rev-list\n #     git           always compare HEAD to @{upstream}\n@@ -94,7 +95,7 @@ __git_ps1_show_upstream ()\n {\n \tlocal key value\n \tlocal svn_remote svn_url_pattern count n\n-\tlocal upstream=git legacy=\"\" verbose=\"\"\n+\tlocal upstream=git legacy=\"\" verbose=\"\" name=\"\"\n \n \tsvn_remote=()\n \t# get some config options from git-config\n@@ -122,6 +123,7 @@ __git_ps1_show_upstream ()\n \t\tgit|svn) upstream=\"$option\" ;;\n \t\tverbose) verbose=1 ;;\n \t\tlegacy)  legacy=1  ;;\n+\t\tname)   name=1 ;;\n \t\tesac\n \tdone\n \n@@ -204,6 +206,9 @@ __git_ps1_show_upstream ()\n \t\t*)\t    # diverged from upstream\n \t\t\tp=\" u+${count#*\t}-${count%\t*}\" ;;\n \t\tesac\n+\t\tif [[ -n \"$count\" && -n \"$name\" ]]; then\n+\t\t\tp+=\" $(git rev-parse --abbrev-ref \"$upstream\" 2>/dev/null)\"\n+\t\tfi\n \tfi\n \n }\n-- \n1.8.1.2\n"},{"id":"228694","messageId":"20131010135813.GF19704@goldbirke","threadId":"35097","inReplyTo":"1381411933-20600-1-git-send-email-jcarsique@nuxeo.com","subject":"Re: [PATCH] git-prompt.sh: show the upstream abbrev name","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2013-10-10T13:58:13Z","receivedAt":"2013-10-10T13:58:13Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Hi,\n\nOn Thu, Oct 10, 2013 at 03:32:13PM +0200, Julien Carsique wrote:\n> @@ -204,6 +206,9 @@ __git_ps1_show_upstream ()\n>  \t\t*)\t    # diverged from upstream\n>  \t\t\tp=\" u+${count#*\t}-${count%\t*}\" ;;\n>  \t\tesac\n> +\t\tif [[ -n \"$count\" && -n \"$name\" ]]; then\n> +\t\t\tp+=\" $(git rev-parse --abbrev-ref \"$upstream\" 2>/dev/null)\"\n\nThe '+=' operator is not supported in all Bash versions we care about.\nPlease write this as p=\"$p $(...)\".\n\nThanks,\nGábor\n"},{"id":"228697","messageId":"1381416039-16576-1-git-send-email-jcarsique@nuxeo.com","threadId":"35097","inReplyTo":"20131010135813.GF19704@goldbirke","subject":"[PATCH] git-prompt.sh: show the upstream abbrev name","fromName":"Julien Carsique","fromEmail":"julien.carsique@gmail.com","sentAt":"2013-10-10T14:40:39Z","receivedAt":"2013-10-10T14:40:39Z","isPatch":true,"sender":{"key":"julien.carsique@gmail.com","avatar":"https://avatars.githubusercontent.com/u/81140?v=4"},"body":"From: Julien Carsique <julien.carsique@gmail.com>\n\nWhen working with multiple remotes, it is common to switch the upstream\nfrom a remote to another. Doing so, the prompt may not be the expected\none. Providing an option to display tracking information sounds useful.\n\nAdd a \"name\" option to GIT_PS1_SHOWUPSTREAM which will show the upstream\nabbrev name. This option is ignored if \"verbose\" is false.\n\nSigned-off-by: Julien Carsique <julien.carsique@gmail.com>\nReviewed-by: SZEDER Gábor <szeder@ira.uka.de>\n---\n contrib/completion/git-prompt.sh | 7 ++++++-\n 1 file changed, 6 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex d6c61b2..84cd3a8 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -60,6 +60,7 @@\n # of values:\n #\n #     verbose       show number of commits ahead/behind (+/-) upstream\n+#     name          if verbose, then also show the upstream abbrev name\n #     legacy        don't use the '--count' option available in recent\n #                   versions of git-rev-list\n #     git           always compare HEAD to @{upstream}\n@@ -94,7 +95,7 @@ __git_ps1_show_upstream ()\n {\n \tlocal key value\n \tlocal svn_remote svn_url_pattern count n\n-\tlocal upstream=git legacy=\"\" verbose=\"\"\n+\tlocal upstream=git legacy=\"\" verbose=\"\" name=\"\"\n \n \tsvn_remote=()\n \t# get some config options from git-config\n@@ -122,6 +123,7 @@ __git_ps1_show_upstream ()\n \t\tgit|svn) upstream=\"$option\" ;;\n \t\tverbose) verbose=1 ;;\n \t\tlegacy)  legacy=1  ;;\n+\t\tname)   name=1 ;;\n \t\tesac\n \tdone\n \n@@ -204,6 +206,9 @@ __git_ps1_show_upstream ()\n \t\t*)\t    # diverged from upstream\n \t\t\tp=\" u+${count#*\t}-${count%\t*}\" ;;\n \t\tesac\n+\t\tif [[ -n \"$count\" && -n \"$name\" ]]; then\n+\t\t\tp=\"$p $(git rev-parse --abbrev-ref \"$upstream\" 2>/dev/null)\"\n+\t\tfi\n \tfi\n \n }\n-- \n1.8.1.2\n"},{"id":"228698","messageId":"5256BD0A.30706@gmail.com","threadId":"35097","inReplyTo":"20131010135813.GF19704@goldbirke","subject":"Re: [PATCH] git-prompt.sh: show the upstream abbrev name","fromName":"Julien Carsique","fromEmail":"julien.carsique@gmail.com","sentAt":"2013-10-10T14:43:22Z","receivedAt":"2013-10-10T14:43:22Z","isPatch":true,"sender":{"key":"julien.carsique@gmail.com","avatar":"https://avatars.githubusercontent.com/u/81140?v=4"},"body":"On 10/10/2013 15:58, SZEDER Gábor wrote:\n> Hi,\n>\n> On Thu, Oct 10, 2013 at 03:32:13PM +0200, Julien Carsique wrote:\n>> @@ -204,6 +206,9 @@ __git_ps1_show_upstream ()\n>>  \t\t*)\t    # diverged from upstream\n>>  \t\t\tp=\" u+${count#*\t}-${count%\t*}\" ;;\n>>  \t\tesac\n>> +\t\tif [[ -n \"$count\" && -n \"$name\" ]]; then\n>> +\t\t\tp+=\" $(git rev-parse --abbrev-ref \"$upstream\" 2>/dev/null)\"\n> The '+=' operator is not supported in all Bash versions we care about.\n> Please write this as p=\"$p $(...)\".\n>\n> Thanks,\n> Gábor\n>\n\nHi,\n\nIt's fixed.\n\nNote '+=' was already used line 114:\n\n            svn_url_pattern+=\"\\\\|$value\"\n\n\nThank you for the review,\n"},{"id":"229004","messageId":"20131015122111.GT19704@goldbirke","threadId":"35097","inReplyTo":"5256BD0A.30706@gmail.com","subject":"Re: [PATCH] git-prompt.sh: show the upstream abbrev name","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2013-10-15T12:21:11Z","receivedAt":"2013-10-15T12:21:11Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Thu, Oct 10, 2013 at 04:43:22PM +0200, Julien Carsique wrote:\n> It's fixed.\n\nThanks, the updated patch looks good to me.\n\n> Note '+=' was already used line 114:\n> \n>             svn_url_pattern+=\"\\\\|$value\"\n\nI guess noone has tried to use the upstream status indicator with an\nSVN upstream and an ancient Bash version yet, thanks for pointing it\nout.\n\n-- >8 --\nSubject: [PATCH] bash prompt: don't use '+=' operator in show upstream code path\n\nThe '+=' operator is not supported by old Bash versions (3.0) we still\ncare about.\n\nSigned-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\n contrib/completion/git-prompt.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex 202e2e520f..7b732d2aeb 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -111,7 +111,7 @@ __git_ps1_show_upstream ()\n \t\t\t;;\n \t\tsvn-remote.*.url)\n \t\t\tsvn_remote[$((${#svn_remote[@]} + 1))]=\"$value\"\n-\t\t\tsvn_url_pattern+=\"\\\\|$value\"\n+\t\t\tsvn_url_pattern=\"$svn_url_pattern\\\\|$value\"\n \t\t\tupstream=svn+git # default upstream is SVN if available, else git\n \t\t\t;;\n \t\tesac\n-- \n1.8.4.1.495.gd8d272e\n"}]}