From patchwork Sun Feb 27 19:57:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Donnelly X-Patchwork-Id: 12762101 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8435C433EF for ; Sun, 27 Feb 2022 19:57:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231557AbiB0T5y (ORCPT ); Sun, 27 Feb 2022 14:57:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230315AbiB0T5x (ORCPT ); Sun, 27 Feb 2022 14:57:53 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2800933E1F for ; Sun, 27 Feb 2022 11:57:16 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id b5so12386649wrr.2 for ; Sun, 27 Feb 2022 11:57:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=8r4KzvmBJBcEcejQQCQP/18C5CUaTPDCtesBQXHNvBw=; b=RBDzSUtBnHMg2alUOfgZSsk0CLsf94iQppAA2C+heUJj/FI6gAVLZL92Xue3GC/7X3 nBMHmcVgeQWrfnX2o+uBCkIYc+A8cliJmlaaCdVnBCkGA9wHTevKk+q7TN+gqIeffF0c RBXmV6dd8qDhikhQlbvqvPx4ympMR8egQokWuXDcDvO7NnU18v+iaMcUV5hrA0LtSgVQ 7zBcv2YEKeDJrskVdD+AlKOWj/Vz5YfAtFhTFmcg7kAz4q9Aq1GE4/MBjuIY8Bt7SDWj nVYLwP684/W9KFXab8upHgSOrOARL41RdFOXXL1KTPV2FlKbrCYR/zXk8sfyQXh6hyb7 OeDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=8r4KzvmBJBcEcejQQCQP/18C5CUaTPDCtesBQXHNvBw=; b=F90M+hJrxkTBnNCqMYNVvgZRvJYUgEcK5Aa6HBaNwCqFnV1zCK6jQfZg0iAbwYAdAZ gvBRp0kC8btFncbCijnzxkvGIJZv+1bJcsDpmz7t7IinsBbJ4Iu6drO3RznhVcJOdgFw ZITCNe0VqVknVy/Lo9TIpLADfvE+hr3YEmO/yCpO2DIlZP49ojbmrctnupti/mo3izk8 UH575pnG5m81LV31cd7ORssku3vJRgrq4wmR6PD6/v/VpygFbq5f4l9ynobLaU399ILl yaQwezwNZC/VtVfZDIuiw96MAPygS1gGRRwA2VvvYoRZ/C5K4//h0tVQ0OCbDXQars20 b3sA== X-Gm-Message-State: AOAM533MVelOmQUz4YiYzVBsb41+vNrn6Nfn7eOL11FvtbSY7kv/soQo YSunYSvqv4WKjXBq3qutbdOi0WgOeAk= X-Google-Smtp-Source: ABdhPJxiAuP60JaHybHocsykYPaCkQJsuWiJWv2wRUHaAnbMIGxnj2iLBP7q18Aok+9cMVtzIXkDLw== X-Received: by 2002:a05:6000:1e0c:b0:1ed:a700:65dc with SMTP id bj12-20020a0560001e0c00b001eda70065dcmr12933916wrb.485.1645991834419; Sun, 27 Feb 2022 11:57:14 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f4-20020a5d4dc4000000b001d8e67e5214sm8572955wru.48.2022.02.27.11.57.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Feb 2022 11:57:13 -0800 (PST) Message-Id: <1db836bb309989c4ad93ed6d32a5ef4075ac7020.1645991832.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sun, 27 Feb 2022 19:57:09 +0000 Subject: [PATCH v2 1/4] git-prompt: rename `upstream` to `upstream_type` Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Justin Donnelly , Justin Donnelly Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Justin Donnelly From: Justin Donnelly In `__git_ps1_show_upstream` rename the variable `upstream` to `upstream_type`. This allows `__git_ps1_show_upstream` to reference a variable named `upstream` that is declared `local` in `__git_ps1`, which calls `__git_ps1_show_upstream`. Signed-off-by: Justin Donnelly --- contrib/completion/git-prompt.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh index db7c0068fb5..3997e099aa7 100644 --- a/contrib/completion/git-prompt.sh +++ b/contrib/completion/git-prompt.sh @@ -115,7 +115,7 @@ __git_ps1_show_upstream () { local key value local svn_remote svn_url_pattern count n - local upstream=git legacy="" verbose="" name="" + local upstream_type=git legacy="" verbose="" name="" svn_remote=() # get some config options from git-config @@ -132,7 +132,7 @@ __git_ps1_show_upstream () svn-remote.*.url) svn_remote[$((${#svn_remote[@]} + 1))]="$value" svn_url_pattern="$svn_url_pattern\\|$value" - upstream=svn+git # default upstream is SVN if available, else git + upstream_type=svn+git # default upstream type is SVN if available, else git ;; esac done <<< "$output" @@ -141,16 +141,16 @@ __git_ps1_show_upstream () local option for option in ${GIT_PS1_SHOWUPSTREAM}; do case "$option" in - git|svn) upstream="$option" ;; + git|svn) upstream_type="$option" ;; verbose) verbose=1 ;; legacy) legacy=1 ;; name) name=1 ;; esac done - # Find our upstream - case "$upstream" in - git) upstream="@{upstream}" ;; + # Find our upstream type + case "$upstream_type" in + git) upstream_type="@{upstream}" ;; svn*) # get the upstream from the "git-svn-id: ..." in a commit message # (git-svn uses essentially the same procedure internally) @@ -167,12 +167,12 @@ __git_ps1_show_upstream () if [[ -z "$svn_upstream" ]]; then # default branch name for checkouts with no layout: - upstream=${GIT_SVN_ID:-git-svn} + upstream_type=${GIT_SVN_ID:-git-svn} else - upstream=${svn_upstream#/} + upstream_type=${svn_upstream#/} fi - elif [[ "svn+git" = "$upstream" ]]; then - upstream="@{upstream}" + elif [[ "svn+git" = "$upstream_type" ]]; then + upstream_type="@{upstream}" fi ;; esac @@ -180,11 +180,11 @@ __git_ps1_show_upstream () # Find how many commits we are ahead/behind our upstream if [[ -z "$legacy" ]]; then count="$(git rev-list --count --left-right \ - "$upstream"...HEAD 2>/dev/null)" + "$upstream_type"...HEAD 2>/dev/null)" else # produce equivalent output to --count for older versions of git local commits - if commits="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null)" + if commits="$(git rev-list --left-right "$upstream_type"...HEAD 2>/dev/null)" then local commit behind=0 ahead=0 for commit in $commits @@ -229,7 +229,7 @@ __git_ps1_show_upstream () esac if [[ -n "$count" && -n "$name" ]]; then __git_ps1_upstream_name=$(git rev-parse \ - --abbrev-ref "$upstream" 2>/dev/null) + --abbrev-ref "$upstream_type" 2>/dev/null) if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then p="$p \${__git_ps1_upstream_name}" else From patchwork Sun Feb 27 19:57:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Donnelly X-Patchwork-Id: 12762103 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3659AC433FE for ; Sun, 27 Feb 2022 19:57:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231583AbiB0T55 (ORCPT ); Sun, 27 Feb 2022 14:57:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231542AbiB0T5y (ORCPT ); Sun, 27 Feb 2022 14:57:54 -0500 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE4EF33E29 for ; Sun, 27 Feb 2022 11:57:16 -0800 (PST) Received: by mail-wm1-x332.google.com with SMTP id i20so4589737wmc.3 for ; Sun, 27 Feb 2022 11:57:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=HWs1rPDv/cLW73s5386uGZiZZlTu1GFX5tT6NSOjMqw=; b=OC9r11R4MDDujAKC0jEqSIO8gR1rqgEz4+x9TKgUz/o/oj93AD/y6xCcUcvpswiT4U I6y6wv+lcDEh6JF284odxAsR5okkDz5wxNASAYQeeJUy+f8hxQQ/FuHCFg2to7EgCj+7 BuQ8zwEnIz6lq/e8bJtWgU5YPd7Mbq92MdV9z1EpaV9eeIZNOJH/vqnMtLQuap2sIzox RtJ2d0ZQqq9z1AOGJZmd098D9n48ac0sbizVXjzvhqj0fibhygSGYXwQfz6tT5UZOI83 ppoTpYC+AxrgjPhHelQw1d+9lelNV3Of6jcM9Igv9/XNQV08bbVKGEgM2cGWYU3Q0tBg 4Tzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=HWs1rPDv/cLW73s5386uGZiZZlTu1GFX5tT6NSOjMqw=; b=nprjnrUIU9hlp5MDDXoWmprGuw2/344kVPqQZHw8KNXQysTq35h2/MtlkuiaW5m9VK 6PyceQZYGx0nJ31sATKIblaVA4898q7Ge5rwo5ovxas7NkWRE8LIhakR5m6pk75x0DKV r/6dg/lbG6OU/6xt1ZSlFkAuwIfHPqAMaDeJvtyPqOk4UGnTFH+cXSekpYM0BLz9K0Lu kq94mCK2WEF5E8DanRqC4yULr7hABQ/ce1E8LMUMQpC8JaWxMsSZnpqtR729xrACRILB h4Yk3Cs7oY/XnkvQgom6uXpVKHG7msZbRJ1KodSR2PwcMFkrSykQ1iFS9AJaiHowpgf6 Q0xQ== X-Gm-Message-State: AOAM532HSRXwvaXLVlP2m9XdtLf/INejgbzihGTS43lTLYLwoHkKPa8X TNYkZGIMgPhq9XOwdqkMCVRF58hBzVw= X-Google-Smtp-Source: ABdhPJxDysmyd2mpIyi/7hf0IhLs6Z1D3PLcAoUT8xR+Ufu1nZ3DsUxd5FYb4Y6MJIjxbzgT25+dQQ== X-Received: by 2002:a05:600c:4f55:b0:381:2322:6b2 with SMTP id m21-20020a05600c4f5500b00381232206b2mr10732608wmq.169.1645991835116; Sun, 27 Feb 2022 11:57:15 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id g17-20020a5d4891000000b001e74e998bf9sm8441392wrq.33.2022.02.27.11.57.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Feb 2022 11:57:14 -0800 (PST) Message-Id: <4bf120b1bf89dfd10b2a1a9297169904223a6d9b.1645991832.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sun, 27 Feb 2022 19:57:10 +0000 Subject: [PATCH v2 2/4] git-prompt: make upstream state indicator location consistent Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Justin Donnelly , Justin Donnelly Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Justin Donnelly From: Justin Donnelly Make upstream state indicator location more consistent with similar state indicators (e.g. sparse). Group the short upstream state indicator (`=`, `<`, `>`, or `<>`) with other short state indicators immediately after the branch name. Previously short and long upstream state indicators appeared after all other state indicators. Use a separator (`SP` or `GIT_PS1_STATESEPARATOR`) between branch name and short upstream state indicator. Previously the short upstream state indicator would sometimes appear directly adjacent to the branch name instead of being separated. For comparison, `__git_ps1` examples without upstream state indicator: (main) (main %) (main *%) (main|SPARSE) (main %|SPARSE) (main *%|SPARSE) (main|SPARSE|REBASE 1/2) (main %|SPARSE|REBASE 1/2) Note that if there are short state indicators, they appear together after the branch name and separated from it by `SP` or `GIT_PS1_STATESEPARATOR`. Before/after examples with short upstream state indicator: | Before | After | | ---------------- | ---------------- | | (main=) | (main =) | | (main|SPARSE=) | (main =|SPARSE) | | (main %|SPARSE=) | (main %=|SPARSE) | Signed-off-by: Justin Donnelly --- contrib/completion/git-prompt.sh | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh index 3997e099aa7..613389a53bc 100644 --- a/contrib/completion/git-prompt.sh +++ b/contrib/completion/git-prompt.sh @@ -109,7 +109,7 @@ __git_printf_supports_v= printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1 -# stores the divergence from upstream in $p +# stores the divergence from upstream in $p (for short status) or $upstream (for verbose status) # used by GIT_PS1_SHOWUPSTREAM __git_ps1_show_upstream () { @@ -214,26 +214,26 @@ __git_ps1_show_upstream () *) # diverged from upstream p="<>" ;; esac - else + else # verbose, set upstream instead of p case "$count" in "") # no upstream - p="" ;; + upstream="" ;; "0 0") # equal to upstream - p=" u=" ;; + upstream=" u=" ;; "0 "*) # ahead of upstream - p=" u+${count#0 }" ;; + upstream=" u+${count#0 }" ;; *" 0") # behind upstream - p=" u-${count% 0}" ;; + upstream=" u-${count% 0}" ;; *) # diverged from upstream - p=" u+${count#* }-${count% *}" ;; + upstream=" u+${count#* }-${count% *}" ;; esac if [[ -n "$count" && -n "$name" ]]; then __git_ps1_upstream_name=$(git rev-parse \ --abbrev-ref "$upstream_type" 2>/dev/null) if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then - p="$p \${__git_ps1_upstream_name}" + upstream="$upstream \${__git_ps1_upstream_name}" else - p="$p ${__git_ps1_upstream_name}" + upstream="$upstream ${__git_ps1_upstream_name}" # not needed anymore; keep user's # environment clean unset __git_ps1_upstream_name @@ -512,7 +512,8 @@ __git_ps1 () local u="" local h="" local c="" - local p="" + local p="" # short version of upstream state indicator + local upstream="" # verbose version of upstream state indicator if [ "true" = "$inside_gitdir" ]; then if [ "true" = "$bare_repo" ]; then @@ -568,8 +569,8 @@ __git_ps1 () b="\${__git_ps1_branch_name}" fi - local f="$h$w$i$s$u" - local gitstring="$c$b${f:+$z$f}${sparse}$r$p" + local f="$h$w$i$s$u$p" + local gitstring="$c$b${f:+$z$f}${sparse}$r${upstream}" if [ $pcmode = yes ]; then if [ "${__git_printf_supports_v-}" != yes ]; then From patchwork Sun Feb 27 19:57:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Donnelly X-Patchwork-Id: 12762104 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6641FC433F5 for ; Sun, 27 Feb 2022 19:57:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231593AbiB0T6B (ORCPT ); Sun, 27 Feb 2022 14:58:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231553AbiB0T5y (ORCPT ); Sun, 27 Feb 2022 14:57:54 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72F80344DB for ; Sun, 27 Feb 2022 11:57:17 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id n14so12319530wrq.7 for ; Sun, 27 Feb 2022 11:57:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=hkVVepIKXC6Z+YdGZUVKyaIwVP4fPHJi0RCeD6PLltU=; b=X1+99fV0x5KHAy3a1owIVd2Jx4JAJbWeANCI6/HeKLeQWtmC94dXWKXno85gtCj8a1 aL3sWmNOy25Z6VPGaz5gtRvuXoUkQgkr5ecklBZReAHZ9GGIT9vkgh+Bqs7uqHAGBhlr L5mVTLC8Sy5TQbG6IrbW/b5m+0QazgkpUQwAFlGliqSsmtrPlCy5QHPpEuKHzha48qaf HoYWaryDw7skUCnVXN+laOhM79TNxmPDTJSALNOEcG9Qcs2wgR0unQz12kOJvLozSPL1 HpJ+f8UnD2lR1BA1kXZ9QDTwcNtkVMoDsGgG5fX1AAXr1SKLPKH07rubcyWYaMb1nWVE jEVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=hkVVepIKXC6Z+YdGZUVKyaIwVP4fPHJi0RCeD6PLltU=; b=BzbqePAq+HSD4AW3upvefMEmrfAi3Z4mBLYbuApPzOaHf0U2TUXYi0ndfLWWcttVFm jpR5itvjmpN5GamX7bCo7UD77bAgo+Ap3O1pnIvox4oU4un286JaFV6D1Bt/xEV37TYJ dK/yA9pRQGBSJnPOI7nUKCHiwfvwvvD+pCsqcO+NN2lUyyGfyy6AJ1mfilNWhXiepvGi oelGUfhTF9rtKG7z8VnEmskmZq9eEKygjnwIwZGSUxIic5tmiU4Pzu9Z2dU4RjDx8FTt 4T7iR/THiWgP41pLUErUnk0kob3wjnImxBvrBpIWaG+YZRuvQn+KTFyo8URErQbf4usG QCTw== X-Gm-Message-State: AOAM531AMqr113i/7pYgTDOczEkOGAViqqBCBYnlzOwJ8jYm3yPWaocl tFBkW/luE7ENwi34bluwcI8O+tpHMQI= X-Google-Smtp-Source: ABdhPJzT47p2+Kz6ZdIsfWBlXz5AphClhakZzd2hdgbc7vXVHmxG3sqKS6kEWAzeizAGAb4PgR/WwQ== X-Received: by 2002:adf:ea86:0:b0:1ef:9141:112c with SMTP id s6-20020adfea86000000b001ef9141112cmr4780608wrm.490.1645991835854; Sun, 27 Feb 2022 11:57:15 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id j12-20020a05600c190c00b00380ead5bc65sm10952246wmq.29.2022.02.27.11.57.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Feb 2022 11:57:15 -0800 (PST) Message-Id: <0af083413b81eb393373b6fe02c5dd4c04d90bdd.1645991832.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sun, 27 Feb 2022 19:57:11 +0000 Subject: [PATCH v2 3/4] git-prompt: make long upstream state indicator consistent Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Justin Donnelly , Justin Donnelly Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Justin Donnelly From: Justin Donnelly Use a pipe as a separator before long upstream state indicator. This is consistent with long state indicators for sparse and in-progress operations (e.g. merge). For comparison, `__git_ps1` examples without upstream state indicator: (main) (main %) (main *%) (main|SPARSE) (main %|SPARSE) (main *%|SPARSE) (main|SPARSE|REBASE 1/2) (main %|SPARSE|REBASE 1/2) Note that if there are long state indicators, they appear after short state indicators if there are any, or after the branch name if there are no short state indicators. Each long state indicator begins with a pipe (`|`) as a separator. Before/after examples with long upstream state indicator: | Before | After | | ------------------------------- | ------------------------------- | | (main u=) | (main|u=) | | (main u= origin/main) | (main|u= origin/main) | | (main u+1) | (main|u+1) | | (main u+1 origin/main) | (main|u+1 origin/main) | | (main % u=) | (main %|u=) | | (main % u= origin/main) | (main %|u= origin/main) | | (main % u+1) | (main %|u+1) | | (main % u+1 origin/main) | (main %|u+1 origin/main) | | (main|SPARSE u=) | (main|SPARSE|u=) | | (main|SPARSE u= origin/main) | (main|SPARSE|u= origin/main) | | (main|SPARSE u+1) | (main|SPARSE|u+1) | | (main|SPARSE u+1 origin/main) | (main|SPARSE|u+1 origin/main) | | (main %|SPARSE u=) | (main %|SPARSE|u=) | | (main %|SPARSE u= origin/main) | (main %|SPARSE|u= origin/main) | | (main %|SPARSE u+1) | (main %|SPARSE|u+1) | | (main %|SPARSE u+1 origin/main) | (main %|SPARSE|u+1 origin/main) | Signed-off-by: Justin Donnelly --- contrib/completion/git-prompt.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh index 613389a53bc..2772f990888 100644 --- a/contrib/completion/git-prompt.sh +++ b/contrib/completion/git-prompt.sh @@ -109,7 +109,7 @@ __git_printf_supports_v= printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1 -# stores the divergence from upstream in $p (for short status) or $upstream (for verbose status) +# stores the divergence from upstream in $p # used by GIT_PS1_SHOWUPSTREAM __git_ps1_show_upstream () { @@ -219,13 +219,13 @@ __git_ps1_show_upstream () "") # no upstream upstream="" ;; "0 0") # equal to upstream - upstream=" u=" ;; + upstream="|u=" ;; "0 "*) # ahead of upstream - upstream=" u+${count#0 }" ;; + upstream="|u+${count#0 }" ;; *" 0") # behind upstream - upstream=" u-${count% 0}" ;; + upstream="|u-${count% 0}" ;; *) # diverged from upstream - upstream=" u+${count#* }-${count% *}" ;; + upstream="|u+${count#* }-${count% *}" ;; esac if [[ -n "$count" && -n "$name" ]]; then __git_ps1_upstream_name=$(git rev-parse \ From patchwork Sun Feb 27 19:57:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Donnelly X-Patchwork-Id: 12762105 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A98F4C433F5 for ; Sun, 27 Feb 2022 19:57:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231609AbiB0T6D (ORCPT ); Sun, 27 Feb 2022 14:58:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231562AbiB0T5z (ORCPT ); Sun, 27 Feb 2022 14:57:55 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 347EE33A1B for ; Sun, 27 Feb 2022 11:57:18 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id n14so12319556wrq.7 for ; Sun, 27 Feb 2022 11:57:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=6766akpyO/bv1XaJriTIe1tvYGqjphFS3cL/dXlqmDw=; b=hcZDVMAiYFQ9L2wQokcpc71iK/yLltclv/AkV7TxCDqT77XMh/Ut9BOX+ZCr+c4iKy FetOtaKgNRpv3TN47P7pAlJwJXiarTcrbulvmuEFRZ+cchlf5MOadRO1KUvCMxPZOiuW 7GtE08NsIFM7GxyRvP/zAsQoyguYJBcqm4y4J6CjcWK/adeMnZvJXaY6a0vyKNDg5XYx WYkQ7Ppc5VSVhpAoVZW3m+xJueANWlrf+JKrboR0liUI/wDuei0xxyPr6e4X+1c2BA9s x+tGtYULPk1IseMx0D2eaoX+RHF4+67iJ14oQXJxr2b4F63khSV+Udd6mU9XpaAXylBs ISfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=6766akpyO/bv1XaJriTIe1tvYGqjphFS3cL/dXlqmDw=; b=AV/nxeB2gOt9H2s7/2pS4BVuItXeljZLbnxxLZQWizr8HA58KYdIPcW4chLs9SyzxE 3tqidtEKt/EWypKTB57XdbZWXm736WmkkfKd6lU3Ckd1DyHwJLGnroDpL1IysL8Ef8u9 lAGowc1cZa4Crp4mE095+ZS/9Er043Fe/VeORYeFQUb9z0yDtr8TB0tc7w/qtKIKyA8D kOvUk4KvVIiTld9XdjxB1ysY7k9mHlcJqa0kgNK2+8pKYPh86mB7wVZFhQKgpwAv2jWu vgc7KR7RkPsBvwR8GDTIgUq1I1zpTNxZjdS8H7sr+SJOq/wB7lt3k6hM+qrOzo/+v/oL OIfg== X-Gm-Message-State: AOAM5309DzZB8LotZn7iZFpbF8BPYztxqPevFHp/iAwbBLy8xTPWGlqB Wrg4lhvncb90fSXdpWUaApBTm/98Nak= X-Google-Smtp-Source: ABdhPJzTJxH6+XBOG8LI9yMLCrqbDp7jYccaYn0snVl+AW6wpr1faFGZxTNNWUW0kQOfi7fL0p/GtQ== X-Received: by 2002:adf:a4c6:0:b0:1ed:a13c:9634 with SMTP id h6-20020adfa4c6000000b001eda13c9634mr13550727wrb.414.1645991836607; Sun, 27 Feb 2022 11:57:16 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id j12-20020a05600c190c00b00380ead5bc65sm10952270wmq.29.2022.02.27.11.57.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Feb 2022 11:57:16 -0800 (PST) Message-Id: <06e51dc50937dc08c11e30b096c231a3d785f24c.1645991832.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sun, 27 Feb 2022 19:57:12 +0000 Subject: [PATCH v2 4/4] git-prompt: put upstream comments together Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Justin Donnelly , Justin Donnelly Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Justin Donnelly From: Justin Donnelly Commit 6d158cba28 (bash completion: Support "divergence from upstream" messages in __git_ps1, 2010-06-17) introduced support for indicating divergence from upstream in the PS1 prompt. The comments at the top of git-prompt.sh that were introduced with that commit are several paragraphs long. Over the years, other comments have been inserted in between the paragraphs relating to divergence from upstream. This commit puts the comments relating to divergence from upstream back together. Signed-off-by: Justin Donnelly --- contrib/completion/git-prompt.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh index 2772f990888..87b2b916c03 100644 --- a/contrib/completion/git-prompt.sh +++ b/contrib/completion/git-prompt.sh @@ -66,6 +66,11 @@ # git always compare HEAD to @{upstream} # svn always compare HEAD to your SVN upstream # +# By default, __git_ps1 will compare HEAD to your SVN upstream if it can +# find one, or @{upstream} otherwise. Once you have set +# GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by +# setting the bash.showUpstream config variable. +# # You can change the separator between the branch name and the above # state symbols by setting GIT_PS1_STATESEPARATOR. The default separator # is SP. @@ -79,11 +84,6 @@ # single '?' character by setting GIT_PS1_COMPRESSSPARSESTATE, or omitted # by setting GIT_PS1_OMITSPARSESTATE. # -# By default, __git_ps1 will compare HEAD to your SVN upstream if it can -# find one, or @{upstream} otherwise. Once you have set -# GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by -# setting the bash.showUpstream config variable. -# # If you would like to see more information about the identity of # commits checked out as a detached HEAD, set GIT_PS1_DESCRIBE_STYLE # to one of these values: