From patchwork Fri Feb 25 11:44:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Donnelly X-Patchwork-Id: 12760154 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 BAFB5C433EF for ; Fri, 25 Feb 2022 11:44:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240141AbiBYLot (ORCPT ); Fri, 25 Feb 2022 06:44:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235328AbiBYLol (ORCPT ); Fri, 25 Feb 2022 06:44:41 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA4CC1E1137 for ; Fri, 25 Feb 2022 03:44:09 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id s1so4036191wrg.10 for ; Fri, 25 Feb 2022 03:44:09 -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=KL6O5PwZr8Mj/xm6ILcvwDwtlRVlLDfmiH0tqAFwuXaOi46FOKHjLz1Ko4xAKf2JlB E9uWRpmFjvLed7zFqqhr4WqaXaef0woGm+plrvdsY7o1wbMfyYuLj6EFqDaNpHHNrggO KMgve6zYIRAMxNA2gqVipptyKKQlJT9FyhPW6Iv9b3Tn51Fg9HsGYfO3/bQ5ezKUDHcW SJW2cu1NC2HkhP5/qGa4yrHhTJ3t/lYgNdMgBt1x0KlH8NOBm4Q/vQ0OykoHZ1Sug94B MAznZVlGrVaZpw85WOENvBPiDfJCtHsoAyL8LYmrzQcWFn/kebYZ1ZRu8uGVKshle0eX bQCw== 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=MSHi+QotgQEE8uq88KUoOIJu2CoiN605b9fFaItlwiCxfmlSjqKdqXvPXRhNUSsTVv LJyBURN+zMsDSB/5CnFu9OVlWhr4OYDNP9kKmjguNJ35BohN2JUbMc55iZJlC7KIBZbQ V7ja0ALIW1D7i0NqPDxgZhSKw/hvR8EHQyKeW/xflJ8uNAFOqZWyrN6aBPam4LvxolKv dYQWPoV7XgCu+qvsQGsrpTtKMFqByleHV/4TTk+lhqk0pl9gpzRvzKsztmvgGx/SSjXP iYtFm2HTHeF7JQ9VrnmymET1XGx8i3RYIfsUdHrePXPpkoJU/1esKUXYffo8ViyWSNS0 Q0Fg== X-Gm-Message-State: AOAM531s8CpIGTNelnbhRjsZGxKmSjez238SIiUkW2wZTSz8j0g2uu6o 1fAnSj2RDzveoEaOB4RB4gDvnPp780g= X-Google-Smtp-Source: ABdhPJw37Vm4WktiikbuLh/zQkRFjHOCv+j17a/jNrtxegxPmZViWI6pv9SJcMkYrVD5u2/bHSWq4A== X-Received: by 2002:adf:fcd0:0:b0:1ef:31fe:d08e with SMTP id f16-20020adffcd0000000b001ef31fed08emr3951216wrs.667.1645789448266; Fri, 25 Feb 2022 03:44:08 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id x18-20020a1c7c12000000b0037c94766961sm2117573wmc.20.2022.02.25.03.44.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Feb 2022 03:44:07 -0800 (PST) Message-Id: <1db836bb309989c4ad93ed6d32a5ef4075ac7020.1645789446.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 25 Feb 2022 11:44:03 +0000 Subject: [PATCH 1/4] git-prompt: rename `upstream` to `upstream_type` Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: 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 Fri Feb 25 11:44:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Donnelly X-Patchwork-Id: 12760156 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 83281C433F5 for ; Fri, 25 Feb 2022 11:44:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240217AbiBYLox (ORCPT ); Fri, 25 Feb 2022 06:44:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236985AbiBYLoo (ORCPT ); Fri, 25 Feb 2022 06:44:44 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE7861E14A8 for ; Fri, 25 Feb 2022 03:44:10 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id c192so1484251wma.4 for ; Fri, 25 Feb 2022 03:44:10 -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=8WuEm8Tjtk+1I6YCswRn6XBkkxWwrEwlejq3nNlQ0iA=; b=aJpe+Ht0sliOn0B0hIYBP6Xyt+4byVfVnOA0Zlo49qx2qHZyjE9CnMirZnVwJ4FyHd u8yhgJkym8s83O0GAzOTZFuAspeX/yyD3VFitL0Gbyi2tXquU/DcV62sYOc7O9Cy1dZk qbr/qkd1fW+TIvgIvX93BnINa5zDmcAAFpsSTY6iECST05nOgmvhj5EAh+YkK5IpdXkP Pb6gRtRhXzksbZpkSTIqT8w6iESXWUjqeo9jhLuukvDvE++xfBMG6a2KH4Ni7s+UkrAg BlIdEkgbhCjnJNPEfcabt9NMqdgEIwIq5HTNdkUaiiswyYU5fiDJbU8DqdFgArtXcerY sR9w== 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=8WuEm8Tjtk+1I6YCswRn6XBkkxWwrEwlejq3nNlQ0iA=; b=syfdUDiTdUkxgBGbn3H33SUW3RDMZ4u54awsp/o0hSJA+Vj+nMTT/mdsYK745/6c8p OS1Z329noEVyuhGw4Gzok8Hw/z+f4T6hbnXH3g5mdSVOOIjyT4kcL1DtIgkStunrO2P3 +OTgtv3oE77dKoQy6ewGuIUKDJN+7W/zK6Ige2HLWSckx7VdVowotIGS7KFFBS4dSS9f 95Z2AuHKRksaWSEnOwvx2Uqp1VdXqgZSsN/BnTe7shapYJlvBA1ER5IV+lnwA4SlY5Qe 18h9SP8FJRrShOZTCG7eh9M/S7ovOcdIX3uRLzrNoMjhtZ5TgVItV3vJ+DoR/IKo4VrP KiXg== X-Gm-Message-State: AOAM531xtBd3GUJTVy/J4MK4fn1yZ005GJXwCWzusFctAvUdBB9ntPXj Anf8tn3f8xwtAurJizHbUTF88hTdo8U= X-Google-Smtp-Source: ABdhPJyv0bmMegNeAasJM1VbvI+q7z2Q3u8U2cj76GrlQHnIlVSUKWvFRV0k4DvhPsbC9V1p/3x6Zw== X-Received: by 2002:a05:600c:2e47:b0:37d:62d7:24bb with SMTP id q7-20020a05600c2e4700b0037d62d724bbmr2376134wmf.71.1645789449099; Fri, 25 Feb 2022 03:44:09 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 11-20020a05600c26cb00b0037ff53511f2sm5250080wmv.31.2022.02.25.03.44.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Feb 2022 03:44:08 -0800 (PST) Message-Id: In-Reply-To: References: Date: Fri, 25 Feb 2022 11:44:04 +0000 Subject: [PATCH 2/4] git-prompt: make upstream state indicator location consistent Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: 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 state indicator (`=`, `<`, `>`, or `<>`) with other short state indicators immediately after the branch name. Group the long state indicator (e.g. `u+2-1 origin/main`) with other long state indicators after the short state indicators. 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 (e.g. `(main=)`) instead of being separated (e.g. `(main =)`). 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 Fri Feb 25 11:44:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Donnelly X-Patchwork-Id: 12760155 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 8A274C433F5 for ; Fri, 25 Feb 2022 11:44:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235981AbiBYLov (ORCPT ); Fri, 25 Feb 2022 06:44:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237293AbiBYLop (ORCPT ); Fri, 25 Feb 2022 06:44:45 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 907431E14B2 for ; Fri, 25 Feb 2022 03:44:11 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id l2-20020a7bc342000000b0037fa585de26so4823606wmj.1 for ; Fri, 25 Feb 2022 03:44:11 -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=pWOANChktqXZqyD503SAEm/0ScvOHwxy0awSpFK8YUE=; b=FJlsmP7kymDpH6NVskdzTo9ZiLorB2GthK8JbFNkDGnoZcZyea5k6Z+r2PswR6E0xx qIZIDKaQ6pJYDHqS+N5qKlKrazE+K0RdgwdEGft91JMQAKDDDz64WH5Ox4nyM2CqGWs2 VefNLiGrHBinZf+2FIPVQ8GOWBO1KJeyUzwxyNr92lTluFZylexrzoucJeG7NjTBipmi 4vlkQ3tpqq/3VZY9HBr1qQJgk3ObOb3dlqFrdL+X8xSlDG+z+iPOccaQXv+ysKbo2ljg yk0YcQ+oNJF2PHdJpqiQGmY/Gu6isx4FHHJYrmYAY8LKJ8fwrSDzn+Ywrsu3Ttxi+On+ wzYw== 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=pWOANChktqXZqyD503SAEm/0ScvOHwxy0awSpFK8YUE=; b=Yebwy+jWTCaR4jLJMrBX0M3FDsN+yllMGITt0Cjy63GtBg4e8XUWmkc3CfYvWHKTpC MPUwOdMNYtURLbfsmOAHMGfsq2WpSY4fukrCiouaXLqBd3EDEK00A321BWff1gC/Sze6 gieBowiOmvA3+zd+FPfgUuuXoV8lUtjHaXSPqqy8w1Qvcni2Kxl0tBBPCr9z7F7dIz6/ 0d8SW6bgFyI6YIhstd5ZxRLzigg0GYyVWINH7GSN/GHXblIuBj+atS5I3+2tcvbvqm8t EeOp2BlHEUn0w9LYabbxteNy6pud4FkREjcOdW3FLjYu1YOXiYj4rcFs+qId3VvTQ560 y4mA== X-Gm-Message-State: AOAM530pvv3rI+0lKne8oCOJ/iWVVF2h389TpdHraPfBclEbtIC6RTw5 C2wOYqJDyiqAHAd7NgHYnil9NJkeZuk= X-Google-Smtp-Source: ABdhPJx+XWH8He2ChBJ8OzHZ3CUMtn3BgrD74Ak0+xtx/OVI5N2tnpX7bgDTIwkOa1kyeiB19w35VA== X-Received: by 2002:a1c:4d0e:0:b0:37c:b85:5404 with SMTP id o14-20020a1c4d0e000000b0037c0b855404mr2325308wmh.184.1645789449879; Fri, 25 Feb 2022 03:44:09 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id r4-20020a05600c35c400b0037e9868e364sm5827091wmq.33.2022.02.25.03.44.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Feb 2022 03:44:09 -0800 (PST) Message-Id: <83766e33614dbb90c1162bd9f6d7fc9c11cd2f60.1645789446.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 25 Feb 2022 11:44:05 +0000 Subject: [PATCH 3/4] git-prompt: make long upstream state indicator consistent Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: 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 delimiter between short state indicators and long upstream state indicator (e.g. `(main *|u+2-1 origin/main)` instead of `(main * u+2-1 origin/main)`) . This is consistent with long state indicators for sparse and in-progress operations (e.g. merge). 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 Fri Feb 25 11:44:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Donnelly X-Patchwork-Id: 12760157 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 CBFDDC433EF for ; Fri, 25 Feb 2022 11:44:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240222AbiBYLoz (ORCPT ); Fri, 25 Feb 2022 06:44:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238245AbiBYLop (ORCPT ); Fri, 25 Feb 2022 06:44:45 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 521C01E4812 for ; Fri, 25 Feb 2022 03:44:12 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id d28so4080351wra.4 for ; Fri, 25 Feb 2022 03:44:12 -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=QKVZnIEnWNxbsJW0sK/pq+is0sZDHi1zc1zYQkn6jBENabfG66qpfpOmFH1msVR21/ zF3yuw9kOZEQe8sdRYTaqCBM3QJc6YNTmMgaEGON34gEGbtUsxE5cD6VQED1E7HnYFR/ VqVgKOEvdfi8na2SkkQ4DqzyQqbH2Sxbe89Ie+XvHrNfgDLanICxAlPFdQts1F+T1+xT 1h5/mHOx7TgnD3cV3A63fs1J/ORXid5iyvMmXuXOyCRsy8mT08egH7/ZEblxbR/I5cem +78h2GhNlB4fJkZozeND4QUG3x/i24Put64cAYeqRLxLCIrSw+bqpup6GddANrbnabbn EAaw== 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=f2pbQNOfi+0zubafB1B13/cs8M+OTwHXO/S8QTep8Gb4O3ekmIFvsabxiRNXaPXA+W dZ1NieHJgJJERP+AaUrmB7pskqZNMwEDnbduLpa0kUTRINpxiF8UmS/jgj8oawEr0wfL dXIPH5hk4t7aRRBeNRjlZV/eleUzMtaj4YkSR+0j2YjxQWLxA7e+ZTRJfT4PWjo5z/Yz sJiIM/OBylSdlUd3Bs2FQMlgLbERXa4ysgLuv2g1mZBRlp3zGUnPRbph7SYKHef12FJ0 NhR9+JXUq84G+l/IO4JnFB0q4/luTKk1BJ/y1M1JMaSnFXXduGiLvhSpp2fDX30RHaHl lP5g== X-Gm-Message-State: AOAM532jbPoTE65yycPBiQBdvxGlSwzZo+wYgTWXY2/8LlCAZK7GwKYS SMrnE6craNIx7gQnqYeRD8xQ5oR8brY= X-Google-Smtp-Source: ABdhPJwtMMdOREajHk/uMjln4Zu9YhgOf0vIVkZEMhckcbleZ4KvjYI7AWIS7UfkX42HuSYfZCwOxw== X-Received: by 2002:a5d:5589:0:b0:1ef:6505:e8a2 with SMTP id i9-20020a5d5589000000b001ef6505e8a2mr1986485wrv.477.1645789450685; Fri, 25 Feb 2022 03:44:10 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id e9-20020adff349000000b001e32675a367sm2020215wrp.28.2022.02.25.03.44.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Feb 2022 03:44:10 -0800 (PST) Message-Id: <58ff3d8affed1c0f79a4a56945d23a5a9b0073f0.1645789446.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 25 Feb 2022 11:44:06 +0000 Subject: [PATCH 4/4] git-prompt: put upstream comments together Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: 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: