From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-4.5 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id 6E11B1F4D7 for ; Wed, 1 Jun 2022 18:37:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236445AbiFASck (ORCPT ); Wed, 1 Jun 2022 14:32:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229871AbiFAScg (ORCPT ); Wed, 1 Jun 2022 14:32:36 -0400 Received: from nmsh5.e.nsc.no (nmsh5.e.nsc.no [148.123.160.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1849AE44B for ; Wed, 1 Jun 2022 11:32:34 -0700 (PDT) Received: from [192.168.1.110] (unknown [194.19.73.58]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: joak-pet) by nmsh5.e.nsc.no (smtp.online.no) with ESMTPSA id 698925217A; Wed, 1 Jun 2022 20:32:32 +0200 (CEST) Message-ID: <47ba2296-10f3-4590-dbf5-38d92ed3e29e@online.no> Date: Wed, 1 Jun 2022 20:32:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [RFC PATCH] git-prompt: make colourization consistent Content-Language: en-US To: Junio C Hamano Cc: git@vger.kernel.org References: <20220601134414.66825-1-joak-pet@online.no> From: Joakim Petersen In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Source-IP: 194.19.73.58 X-Scanned-By: MIMEDefang 2.84 on 10.123.160.199 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On 01/06/2022 20:07, Junio C Hamano wrote: > Hmph, am I correct to understand that the general flow of __git_ps1 is > > (1) various pieces of information like $h, $w, $i, $s, $r, $b, $p, > etc. are declared "local" and values computed for them, > either inside __git_ps1() itself, or by various helper > functions it calls; > > (2) When GIT_PS1_SHOWCOLORHINTS is in effect, we may call the > __git_ps1_colorize_gitstring helper (which is touched by the > above hunk), that modifies these variables with color codes. > Upon entry to this helper function, these variables prepared in > (1) have no color effects. Upon leaving, they do. > > (3) Finally, the PS1 is asseembled by concatenating these > variables, whose text was prepared in (1) and then prefixed by > color codes in (2), one of the earliest steps begins like so: > > local f="$h$w$i$s$u" > local gitstring="$c$b${f:+$z$f}${sparse}$r$p" > > In the final step of formulation, $p immediately follows $r in the > resulting $PS1, and the existing code at the end of the (2) prefixes > $c_clear before $r, and $r before such prefixing is free of coloring, > so it is curious how this patch makes difference (other than emitting > $c_clear one more time). Unless there is a use of $p that does not > immediately follow $r, that is. > > Thanks. > Your understanding is correct for the flow before the change I referenced (0ec7c23cdc6 (git-prompt: make upstream state indicator location consistent, 2022-02-27)), however, that commit changed the definition of $f and $gitstring to local f="$h$w$i$s$u$p" local gitstring="$c$b${f:+$z$f}${sparse}$r${upstream}" This makes it so $p is no longer immediately preceded by $r, but rather $u, which, like all the preceding variables, except $h, will be colourized if enabled.