From patchwork Tue Nov 10 23:42:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 11895821 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A08EC4742C for ; Tue, 10 Nov 2020 23:42:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BC9D1207E8 for ; Tue, 10 Nov 2020 23:42:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lDM/8jom" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732485AbgKJXm2 (ORCPT ); Tue, 10 Nov 2020 18:42:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732437AbgKJXmY (ORCPT ); Tue, 10 Nov 2020 18:42:24 -0500 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 453BEC0613D1 for ; Tue, 10 Nov 2020 15:42:23 -0800 (PST) Received: by mail-wm1-x342.google.com with SMTP id p22so126608wmg.3 for ; Tue, 10 Nov 2020 15:42:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=js8oUsMHl21kgw69PYKoHcc81MiST6F1XqDnN0kNdcM=; b=lDM/8jomBtkqjzTE2BgdOvmoNuJp+RpnGPznk/wwx6aOmNsasx1fJ5+nu5vsFz6zpd BVYfVZmj7Z4I7IE4a7cOcHf/VP2FmPlH0zBW1aDHaRWu8lpA85TRMeyQZfTudnn0ovNZ zGDvDh8YWiyFEfaBGtnK1MtQdjBquLSlLErAk2WsqyE+mFGW+euGm/kavIF6uAhPv0qu 9z9kFZwE/LWcEZACNrp3u28Y5VYzCniLEzovTrZjIwdcFkj5nlylUoGHT4ioo/gYrwH5 BVXu5M/rkZFEQwmtE0Rv6TWFp2m5M4gSMK3ryTtmTcOQ2IoGvo1ZD3fy0QtPu2tKCVvv vTBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=js8oUsMHl21kgw69PYKoHcc81MiST6F1XqDnN0kNdcM=; b=LeoX3Rbe8fBVL6NdeQbkl6BCOKLh9I58MNVD0/NuRG6o7NvJxf1NYelS+E0Sb7+kJA 8FFCM4Swq1w73pPJrYwU7cTxICe8Iek/hIkKVhvU69P9PlTMu1zibLfpfHWmRrsNA5El wJxZ/b6dgJwfOn3EUy1+VHTQwbptwumav+CeA4IAnfoH+6wnOpNDm8NiZd9lXLkkx6ZT EytNGr3pJuWivzQyg5Gwf8HrZnRDlzlhYdnhYnCkrbJ41MTBopVq65X6gexwKSnz0Ppp Fw+d25RPmhU4/dXySoei1yJKm/ufn9uLwYmeU1zXLqsZ+J5/CDvV2iywP7AlV0Fijn9j B+mA== X-Gm-Message-State: AOAM530TVzQHBie502ZNF5Cr3YofZfkGFyZmkYO6r2GNkVxzlEfUhRdO dHtr6Jl+wts9NUusYSRMu9gznXl6Wcs= X-Google-Smtp-Source: ABdhPJyEfIUlyVVl2nHqjKG/is6CabCWsG4PGeqU1rZY0FVcmcyEy9sj7GoHWdbhAoaAaniS3x9eZQ== X-Received: by 2002:a1c:a555:: with SMTP id o82mr578977wme.188.1605051741433; Tue, 10 Nov 2020 15:42:21 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n67sm389494wmf.25.2020.11.10.15.42.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 15:42:21 -0800 (PST) Message-Id: <6152122c04aacf8c3e3f1aae7b73995da6b9e354.1605051739.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 10 Nov 2020 23:42:11 +0000 Subject: [PATCH 1/9] add -i (built-in): do show an error message for incorrect inputs Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin There is a neat feature in `git add -i` where it allows users to select items via unique prefixes. In the built-in version of `git add -i`, we specifically sort the items (unless they are already sorted) and then perform a binary search to figure out whether the input constitutes a unique prefix. Unfortunately, by mistake this code misidentifies matches even if the input string is not actually a prefix of any item. For example, in the initial menu, where there is a `status` and an `update` command, the input `tadaa` was mistaken as a prefix of `update`. Let's fix this by looking a bit closer whether the input is actually a prefix of the item at the found insert index. Signed-off-by: Johannes Schindelin --- add-interactive.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/add-interactive.c b/add-interactive.c index 555c4abf32..8ca503d803 100644 --- a/add-interactive.c +++ b/add-interactive.c @@ -194,7 +194,8 @@ static ssize_t find_unique(const char *string, struct prefix_item_list *list) else if (index + 1 < list->sorted.nr && starts_with(list->sorted.items[index + 1].string, string)) return -1; - else if (index < list->sorted.nr) + else if (index < list->sorted.nr && + starts_with(list->sorted.items[index].string, string)) item = list->sorted.items[index].util; else return -1; From patchwork Tue Nov 10 23:42:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 11895815 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF8A3C388F7 for ; Tue, 10 Nov 2020 23:42:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 92009216C4 for ; Tue, 10 Nov 2020 23:42:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KLc7gbJP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732499AbgKJXm2 (ORCPT ); Tue, 10 Nov 2020 18:42:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732438AbgKJXmY (ORCPT ); Tue, 10 Nov 2020 18:42:24 -0500 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EEF0C0613D3 for ; Tue, 10 Nov 2020 15:42:23 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id h2so161320wmm.0 for ; Tue, 10 Nov 2020 15:42:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=dpll76Bt0FuWoTL59TONqXQ0KGL2T+WUdIsjig1jOUg=; b=KLc7gbJPz1iwSFaQz0SnxVxEGIKelSPwISD3+qao2twqNXEVK4jHbm+lzeHVz9LUAJ QFhnUrry3D+ABl29EqrdzRlf+C6diM29K6kpt/sgWg/760Ty7CpVjDtFj5eHeeJjGOTV Qe9WCeHzdxc3fbbVUD7NAM8qU3lluSQEkAzbWAox8QluCHJMxOLq7AgImb09E9buNC35 qWV362pD0sfkzF3f4ux7XnKuDRsfXzuZ+MUQMygMm5Uu6ImghAVxS9h5sMEnNXikLago OKr8jXeWnbVZLK2+6HxaJ4qPrAuONKUCjhP9hCZPsf+6hE3hqDJS2RXrNnkTSEHe8olt ZtYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=dpll76Bt0FuWoTL59TONqXQ0KGL2T+WUdIsjig1jOUg=; b=cOCX3k/oUHVndYzn9sCzkMriwQFfxRjfoJOS/E/DRIunbRz7Dx9RmPUdXKmSP3O+fM eNUdaLrKiph3lLMTMXXZnW/8XS3L4i79569JtZ/x+B1YHtZjw+49YZtP5c43px1QJMry edc78mJwKhDLZXxgIn9t07DaAhC2YzU214vmJ5/nwByJHbsahixwfGIJYJyWEi09P++t YhTC1am/aFgJQWIiqVBVAobZ6FrE1rBALl/oQJ8+09n2mwYsI/MDEVEAWG+6Q+kONeEN iY7CzWNH0kmvptC+hQcYITMiqHIa2YXlEAVhIczIkAE92um0ev7HV1vtQ5nMBZIsbgf/ 60ng== X-Gm-Message-State: AOAM533x0eybDdfQxL6sCCuCCFMYr/NUJsZhPLwdIxBsbYv0WCWpO7LX 4wU2JyvuQZ7o88pQL4LL7TY8SZFWamw= X-Google-Smtp-Source: ABdhPJx0otzfnT/lE4/Wr8qMXHrRHuYEGfD7T68bs0mbN8EHCRhFHW9zia0r0NIxORYw+YeHZgWQEg== X-Received: by 2002:a1c:4ca:: with SMTP id 193mr554264wme.137.1605051742212; Tue, 10 Nov 2020 15:42:22 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f17sm374149wmf.41.2020.11.10.15.42.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 15:42:21 -0800 (PST) Message-Id: <068813912b9e5133f9d9bbacb239f7954788bf53.1605051739.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 10 Nov 2020 23:42:12 +0000 Subject: [PATCH 2/9] add -i (built-in): send error messages to stderr Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin The Perl version of that command already does that since a301973641f (add -p: print errors in separate color, 2009-02-05). The built-in version's development started by reimplementing the initial version from 5cde71d64af (git-add --interactive, 2006-12-10) for simplicity, though, which still printed error messages to stdout. Let's fix that by imitating the Perl version's behavior in the built-in version of that command. Signed-off-by: Johannes Schindelin --- add-interactive.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add-interactive.c b/add-interactive.c index 8ca503d803..0f24992ca4 100644 --- a/add-interactive.c +++ b/add-interactive.c @@ -365,7 +365,7 @@ static ssize_t list_and_choose(struct add_i_state *s, if (from < 0 || from >= items->items.nr || (singleton && from + 1 != to)) { - color_fprintf_ln(stdout, s->error_color, + color_fprintf_ln(stderr, s->error_color, _("Huh (%s)?"), p); break; } else if (singleton) { From patchwork Tue Nov 10 23:42:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 11895827 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A438BC56202 for ; Tue, 10 Nov 2020 23:42:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 56B7620809 for ; Tue, 10 Nov 2020 23:42:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tiDWf3zh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732471AbgKJXm1 (ORCPT ); Tue, 10 Nov 2020 18:42:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732451AbgKJXm0 (ORCPT ); Tue, 10 Nov 2020 18:42:26 -0500 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FB98C0613D6 for ; Tue, 10 Nov 2020 15:42:24 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id s13so125509wmh.4 for ; Tue, 10 Nov 2020 15:42:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=li8clFkTL0WoFiio26Z5SCHvNIyzRnyAytG439CeyhM=; b=tiDWf3zhKNw1s9hkgk2oB04VSQZi7gAG116OKH5/Si1aYmV09BthYSNen6Wz0OxiVy zxfF4/B/yK/sPUiN2vuyEOhgNFVUx54T3F/Qi4BIwh1kKmvcQAHv8pzFjVIMJM+ZuN3S OKfxrXL0fAVU7DXRFohvvZFoiyrMC9rn7VhQ/gSfIxBqI/XeR3RqrIc6f1BJvmVaKZ1F sBMrXuOdLIeNf27+EhNIsZyYJR9nX0lLyqbCrQEXqCJ5XoapfuOrfkwXY2aXMqFeGn9x tMmaV/Z5h+/uew2+HyOnsCO4axcWpp5mwEnbLCgZJI+pu6PlaQgcG5JCbM/hKhglL6JH DjYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=li8clFkTL0WoFiio26Z5SCHvNIyzRnyAytG439CeyhM=; b=GHmW5n9HPWs+oZFvlYmSJcF0Qxrj/65Q+gsUBT5J1hhs+2kgryH5ZGxCfwOpVwTv4z cvawlWNVdByuUfaYOiUTUSy9EYAarYpP5ocXu9YgpZ4gjmlw///CFc/0xjVIJjhKB28u AbR5vFx64UQOyiAfOJfrKv8t4IMFVL8jo/ikGRQ2u04xKfX7ZyzPMD7MkyHEvT2QNQd+ jMeYyfDkHoSMcDZc9NOiGl66IVdCHYId7y/FbovVHJVcofu2dzQXivLoS29D3Vo1xbkL zqKVX8OEnf1Cf+CE8ArPIPnul4VkacPKY81jS72nlyzYbzl7M9kcTy8+RxMQyzuj+VNg b/yA== X-Gm-Message-State: AOAM5305CzTK1TPtUB/Z6wXBQGKQ+19+P/y2M8cSf7kAXC2jMHQRrMVF 0l7LVmjweVQrChYbtuFCCWUPFTM5e74= X-Google-Smtp-Source: ABdhPJwv9diUEjsLb/gSS4Y89IzpYjl/2fXkd7CqE+ojrSaeR/N0EEcM7GvFruc5Os1zTUYi1CBvUw== X-Received: by 2002:a1c:5605:: with SMTP id k5mr519118wmb.99.1605051742934; Tue, 10 Nov 2020 15:42:22 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id q7sm274287wrg.95.2020.11.10.15.42.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 15:42:22 -0800 (PST) Message-Id: <9a1ba71977e9dda4c2656dc2847106dd8b79a433.1605051739.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 10 Nov 2020 23:42:13 +0000 Subject: [PATCH 3/9] add -i: use `reset_color` consistently Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin We already maintain a list of colors in the `add_i_state`, therefore we should use them. Signed-off-by: Johannes Schindelin --- add-patch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/add-patch.c b/add-patch.c index be4cf6e9e5..33a24f58fe 100644 --- a/add-patch.c +++ b/add-patch.c @@ -667,7 +667,7 @@ static void render_hunk(struct add_p_state *s, struct hunk *hunk, if (len) strbuf_add(out, p, len); else if (colored) - strbuf_addf(out, "%s\n", GIT_COLOR_RESET); + strbuf_addf(out, "%s\n", s->s.reset_color); else strbuf_addch(out, '\n'); } @@ -1060,7 +1060,7 @@ static void recolor_hunk(struct add_p_state *s, struct hunk *hunk) s->s.file_new_color : s->s.context_color); strbuf_add(&s->colored, plain + current, eol - current); - strbuf_addstr(&s->colored, GIT_COLOR_RESET); + strbuf_addstr(&s->colored, s->s.reset_color); if (next > eol) strbuf_add(&s->colored, plain + eol, next - eol); current = next; From patchwork Tue Nov 10 23:42:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 11895829 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1160C4742C for ; Tue, 10 Nov 2020 23:42:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 674AC20809 for ; Tue, 10 Nov 2020 23:42:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="miyBd1qJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732453AbgKJXm0 (ORCPT ); Tue, 10 Nov 2020 18:42:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732446AbgKJXmZ (ORCPT ); Tue, 10 Nov 2020 18:42:25 -0500 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29D65C0613D4 for ; Tue, 10 Nov 2020 15:42:25 -0800 (PST) Received: by mail-wm1-x342.google.com with SMTP id c9so108837wml.5 for ; Tue, 10 Nov 2020 15:42:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=wqcvrpnp66411xzdRYT+v8cQp9rgUou7SRfzShsgUY0=; b=miyBd1qJmblZJzo/RwWTtlIUQsc6AasydfuZ5MkAkqKmrt3F21rYIjufx9EhqBAHSA DHjBx2NzBEexEQGYJ11FRdYVhpMgATySqVfYMfTE7MisVpsALQCNAuvjmuRIJ4Ks67GL GGNJhbxPjEU1UNG/JZbL5rODB1edgNEfQtNUoLWl6fadxEgHG4t/Px7rRKKc4mbjZ5gd NkF5AixM9+QjrjbBbNIZ7A0NN+nzhlkOhq7WtB+/L1KtdVAqBqUfCZkQ1HU/IhabZ8IO 8PKxX5qIjupDEG3hQMcjxniiziIVgeEx48OIOQenjriPZv6dN4IJsBcVnwjpY2hBFivd +EXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=wqcvrpnp66411xzdRYT+v8cQp9rgUou7SRfzShsgUY0=; b=DsrtSzS6fMcJSB+7fKV9xeh8VtIGzDDopcdEfy6SEEp1Cn9Dzs3FSPMr7zbQDXgmzz DPDC4IFZgCplRG+L1H0Ab5qHgOAtSokE7gQyHXjjsLJpWyjEISaMbncTKiMvO8smuBhF 2lxBpUbOUb0IjnuQoah95ZRdV+DFr2iJD7PIgJfg0sp3ta821hFsnVgqSDecmy2HMEMw 0q35YDHsxbz5uFJ1EflhWGeJAKyvkCqsx/NrAO4H165dMKda5hobJ0z29Sk3Rba2fjfU h2PPi6PRy3rDyCELLUDB7pB/G8rdgFEev4pUEx+NFx7C37rbnt5BCJhRoOsNAWmTo00K Ik/g== X-Gm-Message-State: AOAM5328tvyej0SQ7Kuo021Z6sffqwsPnZwT0AT/HYjGGdXj0SV7ZRjJ n+UuARaRvVn/IWcWD1H+uLxBRhjeA/g= X-Google-Smtp-Source: ABdhPJzNCTKSUrweylb5c58wlcYOGiurWiOOsuWhtMYS08O6Q0tUzjF2wKGlx/ZbsrEgccFrIcHT9Q== X-Received: by 2002:a1c:1982:: with SMTP id 124mr581906wmz.74.1605051743713; Tue, 10 Nov 2020 15:42:23 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id w186sm375710wmb.26.2020.11.10.15.42.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 15:42:23 -0800 (PST) Message-Id: In-Reply-To: References: Date: Tue, 10 Nov 2020 23:42:14 +0000 Subject: [PATCH 4/9] add -i (built-in): prevent the `reset` "color" from being configured Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin The Perl version of that command sneakily uses `git config --get-color` to figure out the ANSI sequence to reset the color, but passes the empty string and therefore cannot actually match any config entry. This was missed when re-implementing the command as a built-in command. Let's fix this, preventing the `reset` sequence from being overridden via the config. Signed-off-by: Johannes Schindelin --- add-interactive.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/add-interactive.c b/add-interactive.c index 0f24992ca4..f3a1d7456e 100644 --- a/add-interactive.c +++ b/add-interactive.c @@ -44,7 +44,6 @@ void init_add_i_state(struct add_i_state *s, struct repository *r) init_color(r, s, "help", s->help_color, GIT_COLOR_BOLD_RED); init_color(r, s, "prompt", s->prompt_color, GIT_COLOR_BOLD_BLUE); init_color(r, s, "error", s->error_color, GIT_COLOR_BOLD_RED); - init_color(r, s, "reset", s->reset_color, GIT_COLOR_RESET); init_color(r, s, "fraginfo", s->fraginfo_color, diff_get_color(s->use_color, DIFF_FRAGINFO)); init_color(r, s, "context", s->context_color, @@ -54,6 +53,9 @@ void init_add_i_state(struct add_i_state *s, struct repository *r) init_color(r, s, "new", s->file_new_color, diff_get_color(s->use_color, DIFF_FILE_NEW)); + strlcpy(s->reset_color, + s->use_color ? GIT_COLOR_RESET : "", COLOR_MAXLEN); + FREE_AND_NULL(s->interactive_diff_filter); git_config_get_string("interactive.difffilter", &s->interactive_diff_filter); From patchwork Tue Nov 10 23:42:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 11895819 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 455DDC388F7 for ; Tue, 10 Nov 2020 23:42:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EE27D20867 for ; Tue, 10 Nov 2020 23:42:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FnPaO0VA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732511AbgKJXm3 (ORCPT ); Tue, 10 Nov 2020 18:42:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732451AbgKJXm1 (ORCPT ); Tue, 10 Nov 2020 18:42:27 -0500 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D473AC0617A6 for ; Tue, 10 Nov 2020 15:42:25 -0800 (PST) Received: by mail-wr1-x444.google.com with SMTP id 23so352109wrc.8 for ; Tue, 10 Nov 2020 15:42:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=IfewZDe6pyLTRvzVboxTA78Zdq0TjQvvkV3C3VOSFME=; b=FnPaO0VA1ze0cSxhxZpHjA2/syGfyo8Qu/Z6K/KIZPcOTdFIEdt5bEvS6/Bv+iicxM GVtyYi59quGCTOJdd8TxF+R2R+ocJdFTLPYlYjnPMMKwDOi29/wUV678EjbWuuayuvb+ sXSSt+9P40Y635mvW8Io0ztwQLs0aj5oXBV2mcuEUT6rJxqcMSNZUQRWlETkFfIff6GJ GoiAW75wQB96EULL59LpANd3qu75adlBUZLMOFGkoBBPU6LQdC5O0r9cturPF9eaIWwv 4Jlu2vuxPamt5MQrXXNF+Hg4p5tEbWBPwXSttnHlbc6lxUgzkguU+Pq+Pp/i5w6Sdr5O AyUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=IfewZDe6pyLTRvzVboxTA78Zdq0TjQvvkV3C3VOSFME=; b=gAvQFkrMqNoZ2gBCM08+sTvNnZ515fsHqSfcbref/cFK5n/SDvw8XsMmkGYBJ7rKbj B/KQRG3T5pQaPwQkuPyMpKUVg912WgUVb00YbtfG8xFgifawFRRR98phfxMXmK8jYjvC 2YWXKI2QyJPwgWBBcBSgRo/jVGsYTWXuosiNqYfEyaHRtiNTeM88RJs7EmVxwXL19ebq rLZsMlKpJHYAuDRzNfCkz564L+tj//MFRysBimxljmac5F684fBtjIIqB3BkBtbfIrgj hf7vpMwbSG7ucmEdQQ7AMQ42QLxMkrpsqi/8SGaMDrPYhT/TmOcDdP1O5I+lduFGAKcz iG9g== X-Gm-Message-State: AOAM531zkYj6l8kadz78/vXGAsAsYnhno8FVgY8cTfw4q9Lkhcb5vV1v 7zvAA3zqR2cEoieXX0nGdW10+YGfe7Y= X-Google-Smtp-Source: ABdhPJwkurV+98EaQHZlLcmFMn0M7U4tknBUpA5xq2xKh/RYvYtVcazLs5MC5PA3LFqG83Rmmy3+jg== X-Received: by 2002:adf:db8e:: with SMTP id u14mr25424836wri.233.1605051744438; Tue, 10 Nov 2020 15:42:24 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id s9sm281947wrf.90.2020.11.10.15.42.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 15:42:24 -0800 (PST) Message-Id: <85b0d27d76e31033d691b69b271db6ad033f9e29.1605051739.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 10 Nov 2020 23:42:15 +0000 Subject: [PATCH 5/9] add -i (built-in): use correct names to load color.diff.* config Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin The builtin version of add-interactive mistakenly loads diff colors from color.interactive.* instead of color.diff.*. It also accidentally spells `frag` as `fraginfo`. Let's fix that. Note also that we don't respect the historical `diff.color.*`. The perl version never did, and those have been deprecated since 2007. Reported-by: Philippe Blain Co-authored-by: Jeff King Signed-off-by: Johannes Schindelin --- add-interactive.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/add-interactive.c b/add-interactive.c index f3a1d7456e..9126684348 100644 --- a/add-interactive.c +++ b/add-interactive.c @@ -12,10 +12,10 @@ #include "prompt.h" static void init_color(struct repository *r, struct add_i_state *s, - const char *slot_name, char *dst, + const char *section_and_slot, char *dst, const char *default_color) { - char *key = xstrfmt("color.interactive.%s", slot_name); + char *key = xstrfmt("color.%s", section_and_slot); const char *value; if (!s->use_color) @@ -40,17 +40,20 @@ void init_add_i_state(struct add_i_state *s, struct repository *r) git_config_colorbool("color.interactive", value); s->use_color = want_color(s->use_color); - init_color(r, s, "header", s->header_color, GIT_COLOR_BOLD); - init_color(r, s, "help", s->help_color, GIT_COLOR_BOLD_RED); - init_color(r, s, "prompt", s->prompt_color, GIT_COLOR_BOLD_BLUE); - init_color(r, s, "error", s->error_color, GIT_COLOR_BOLD_RED); - init_color(r, s, "fraginfo", s->fraginfo_color, + init_color(r, s, "interactive.header", s->header_color, GIT_COLOR_BOLD); + init_color(r, s, "interactive.help", s->help_color, GIT_COLOR_BOLD_RED); + init_color(r, s, "interactive.prompt", s->prompt_color, + GIT_COLOR_BOLD_BLUE); + init_color(r, s, "interactive.error", s->error_color, + GIT_COLOR_BOLD_RED); + + init_color(r, s, "diff.frag", s->fraginfo_color, diff_get_color(s->use_color, DIFF_FRAGINFO)); - init_color(r, s, "context", s->context_color, + init_color(r, s, "diff.context", s->context_color, diff_get_color(s->use_color, DIFF_CONTEXT)); - init_color(r, s, "old", s->file_old_color, + init_color(r, s, "diff.old", s->file_old_color, diff_get_color(s->use_color, DIFF_FILE_OLD)); - init_color(r, s, "new", s->file_new_color, + init_color(r, s, "diff.new", s->file_new_color, diff_get_color(s->use_color, DIFF_FILE_NEW)); strlcpy(s->reset_color, From patchwork Tue Nov 10 23:42:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 11895831 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFAA0C56202 for ; Tue, 10 Nov 2020 23:42:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 753FC21D93 for ; Tue, 10 Nov 2020 23:42:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FWlM2qJN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732548AbgKJXme (ORCPT ); Tue, 10 Nov 2020 18:42:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732496AbgKJXm2 (ORCPT ); Tue, 10 Nov 2020 18:42:28 -0500 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 987DDC0613D1 for ; Tue, 10 Nov 2020 15:42:26 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id d142so118599wmd.4 for ; Tue, 10 Nov 2020 15:42:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=A5bDKyCl0obBVU+z1Kv+8waCmoKQ+uehMreT3MevQVI=; b=FWlM2qJNqpSclYKREGHOXCF8eiUkVxoAqba9EYxNcxlLYKOmN4+y51Pqc+zbwItJU2 hPmV83wVhx+pEzDaK+Ya+ICXJtijDqM6LjI62fx6JoOTQhEbRWO5fxlJoKkwIHSuybaY 52Yg1c2MmZ4G+/+lyB0NCjZHV74w2hAf5jNeAjQ+sp0/vnH66yxXlu04wV3/54ivctnF 8tMn7/4wn8y8DKsdNSMz2+TWhiZCgaSxtdKI7VpJf4WYPjRU8XebEgMFEwq0qtDeTK7G +sjVx3oSL9/SMPdLCW+BoR9h/R4BPoGmEbNJ1geDKSvOClkeDYUn9dRx4GEq1asQRw/p ZmtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=A5bDKyCl0obBVU+z1Kv+8waCmoKQ+uehMreT3MevQVI=; b=M2muNYVyZSyc5TTafwOnyp+trmgHJ43vuAaMXA+9Bb8rNgDhNwNZi3hbaOFkva4Sek g/fI0uv6tC3Huef4YdOsW0+keEY4E/y+SCQaNBNxrg2mTbQnoodmPxbq6JJlghwBAO5h QSsm1ZojFRlj3WUOr4FEWEDZZJjgoO2x3nlnD4GI1uqHONDXD/zrw0C7FsslaOsKqh/T eGjfRtrwKKzUbUsIZ28VzUyxb/CGpr4dDfvcLj1L0dhtuWbDMn+Pp7MmkJL6zcqA9S8c ZtRr+kiKNuWcafVXnniXtXGf21lp2VXIb6ihudBPzbWt9asEwN//vdFYtQfXkh6ksJmb dxFQ== X-Gm-Message-State: AOAM533bBxyveLMF2sbHoxHOK6Ad++tO3JPaC0huyGlJwSDgLqggYxfs QUwZBjwOKUDmjBLIOxI0b62p6RbDH44= X-Google-Smtp-Source: ABdhPJwvoAHMEHY34EEpH3NMSV39ik0Q7kRhlMR37ogalssDSvBxZx7IGOZzP4MoFFErfAcJrmGTKQ== X-Received: by 2002:a05:600c:d2:: with SMTP id u18mr591646wmm.102.1605051745264; Tue, 10 Nov 2020 15:42:25 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id u203sm381802wme.32.2020.11.10.15.42.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 15:42:24 -0800 (PST) Message-Id: <059344bfaf40da90dbe951a58f826b1ed21b5e12.1605051739.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 10 Nov 2020 23:42:16 +0000 Subject: [PATCH 6/9] add -p (built-in): do not color the progress indicator separately Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin The Perl version of this command colors the progress indicator and the prompt message in one go, let's do the same in the built-in version. Signed-off-by: Johannes Schindelin --- add-patch.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/add-patch.c b/add-patch.c index 33a24f58fe..6f4c187238 100644 --- a/add-patch.c +++ b/add-patch.c @@ -1456,15 +1456,15 @@ static int patch_update_file(struct add_p_state *s, else prompt_mode_type = PROMPT_HUNK; - color_fprintf(stdout, s->s.prompt_color, - "(%"PRIuMAX"/%"PRIuMAX") ", + printf("%s(%"PRIuMAX"/%"PRIuMAX") ", s->s.prompt_color, (uintmax_t)hunk_index + 1, (uintmax_t)(file_diff->hunk_nr ? file_diff->hunk_nr : 1)); - color_fprintf(stdout, s->s.prompt_color, - _(s->mode->prompt_mode[prompt_mode_type]), - s->buf.buf); + printf(_(s->mode->prompt_mode[prompt_mode_type]), + s->buf.buf); + if (*s->s.reset_color) + fputs(s->s.reset_color, stdout); fflush(stdout); if (read_single_character(s) == EOF) break; From patchwork Tue Nov 10 23:42:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 11895817 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE1A0C56202 for ; Tue, 10 Nov 2020 23:42:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 51CE020809 for ; Tue, 10 Nov 2020 23:42:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="L12i0waw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732513AbgKJXma (ORCPT ); Tue, 10 Nov 2020 18:42:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732473AbgKJXm1 (ORCPT ); Tue, 10 Nov 2020 18:42:27 -0500 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42376C0613D3 for ; Tue, 10 Nov 2020 15:42:27 -0800 (PST) Received: by mail-wm1-x342.google.com with SMTP id d142so118636wmd.4 for ; Tue, 10 Nov 2020 15:42:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=9tX+jisZnF8QKIRir0GzdfsvhwQEBVAh2/i2Bt96TTA=; b=L12i0wawcAP7jVzyUx8GwcfSMgiGxCx6/62C8jNQ2zAPnBIeL+g/psOzdei7qekpeE jQVKdXnI9rq7Qf7P0sZbD46RhwvwYSJMiM3ceNsW8gNUdnKmt1qkq3PJNmchL7i5HL4G FdrcnspWRUW0XrH2TqnYnVr1R+nHiT0P/4vrdd+Gfyf0vBwRRArxsVYxDp+nP/IBk+wV OZy/gikq5U/Nf+6BjtddLqtg+0MIUjoOQpMQduEddR3+gJASHwfOaVG1Err4DaQ4Anpj tuJ4OmtuuEgbKbhnok/HvYdwXmvl9xxvmzk0Kd5yfeSxCXORTuqsGg+dD08DCJsIefTK PN5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=9tX+jisZnF8QKIRir0GzdfsvhwQEBVAh2/i2Bt96TTA=; b=nsrdGagVkwQ8gXlIB/cMcuEXKrDY5NpkHCiGB3qBdHi9t8ofTjuJCoAsT29i4/D/st dmz5M6qc7gC/JSN7m5IYPdEDHXpowcgmdYYV++OcdFnCYBDTU8IjvrfHo70CBFdPSqwG tq8jDOj1JxSA43E7mJv3bMUZ7ao/bm5Zqp1Fun+gldSb4zfib83BCF2EdJPtehJOY+uY nHfg7YYzqReVFmrLiiVsjS0ox5zmBKYZ6qWq0sglfWhGQ8RDayVLUOXE0SLXjlSnUuz8 K3eaEPZSo0YSrVn4fWiInSXRO0s8mz8Ck4WhwePUfNMOP5+g7FjnsFe9F7RYwk5c5Cul LJAg== X-Gm-Message-State: AOAM531ijIuCvD5zQImm/i1JbpXVPNdwL1X0I/myodLZziU3ZE7XxjXZ qn0dYD5gfADa6qf2egkkRZmNxw/Dkf0= X-Google-Smtp-Source: ABdhPJy66Tm/06cpmR04wIQjTcHHpRdUoV5Ho+poRRhgTr6VTOWrd3GtGJlR8HPg6vKIITrK04osnA== X-Received: by 2002:a1c:9e12:: with SMTP id h18mr563687wme.11.1605051745934; Tue, 10 Nov 2020 15:42:25 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f8sm266683wrt.88.2020.11.10.15.42.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 15:42:25 -0800 (PST) Message-Id: <8df87e639562a93072b86b38da179059be05c231.1605051739.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 10 Nov 2020 23:42:17 +0000 Subject: [PATCH 7/9] add -i (built-in): use the same indentation as the Perl version Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin When copying the spaces used to indent non-flat lists in `git add -i`, one space was appended by mistake. This makes the output of the built-in version of `git add -i` inconsistent with the Perl version. Let's adjust the built-in version to produce the same output as the Perl version. Signed-off-by: Johannes Schindelin --- add-interactive.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add-interactive.c b/add-interactive.c index 9126684348..c298a8b80f 100644 --- a/add-interactive.c +++ b/add-interactive.c @@ -1137,7 +1137,7 @@ int run_add_i(struct repository *r, const struct pathspec *ps) print_file_item_data.color = data.color; print_file_item_data.reset = data.reset; - strbuf_addstr(&header, " "); + strbuf_addstr(&header, " "); strbuf_addf(&header, print_file_item_data.modified_fmt, _("staged"), _("unstaged"), _("path")); opts.list_opts.header = header.buf; From patchwork Tue Nov 10 23:42:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 11895823 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBFF1C4742C for ; Tue, 10 Nov 2020 23:42:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9963220809 for ; Tue, 10 Nov 2020 23:42:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pn98k/Zx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732517AbgKJXmb (ORCPT ); Tue, 10 Nov 2020 18:42:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732493AbgKJXm2 (ORCPT ); Tue, 10 Nov 2020 18:42:28 -0500 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14EE4C0613D3 for ; Tue, 10 Nov 2020 15:42:28 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id c16so143824wmd.2 for ; Tue, 10 Nov 2020 15:42:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=xkBYrD8bcxEnHBhLHEAXw4mp/SsWUlfPpyOGpP9cIBM=; b=pn98k/ZxpeunF2WRkW2AFqYBRVQ7He2gAWi3Uvx7lJV9o/wP7dB313i9U+py/hCuSB WM9bxXFbUnQhcU4AAG6Y48aa21L28ih4e6DB0F0BtZBuSyaBwFliyeJylhOZ18mTK+xa 4r/BB1dfsqICRFPmCE3K2qlFa8aN/q20ubuYBM4SCOzvi+xdY6Bl56fqhsPVN3hmDmT7 R/W8v4u7p/01LZJOdtn6vHHbdCVyD5/tu4HaEKR+xmzzDoK01GrWZCsOeJHG0Fwi5gqC 95K3BHHmepw3dyrasfwmMc4Ag3L4TZET3BRkkTO5yK66TJyUURBAaE0FDc8scoQhRlxh gbyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=xkBYrD8bcxEnHBhLHEAXw4mp/SsWUlfPpyOGpP9cIBM=; b=fWyeo35akiRBNyBNNJGY2lI0KdYsPXbaQeJh6WOLbUAapBHjb44UdIbwUEwMUCkUpb RsmGdjvK+RfYm1xGvtkxWSIk9fzugx6MbmPOzz/lKRp+r5O9kvmbI9fwy6E0+kbmob+F aYUHPdhCGSwHlv94EifiRgyymbjI29Lf/uF4lGljo9H6hyOtSbxKVJrXLxAXOMVpflJr zm5w62JuOY4Rq7heoOyEehjphdByHLXCxEJAv7E0QzsVl8ABs1sIAKatTtvfzWThyR2O FvLxzNk0XQs8mxm7RO2FN5rHbyUGxvS8Xj+/C3pdiaJSk9Ge6VB8Q5S0gZaOJKhA4cxd aSEg== X-Gm-Message-State: AOAM530C/ozbwrH2oUTFDmybbMCojgAz46Q1tOduSP3ULP8ld008ikJm XrZiO9pwwPV+WV7jhXkEDbsuRJDoHFw= X-Google-Smtp-Source: ABdhPJx3Y0w0KEZjAsNZl9Jcj6M+VMilB2eJpLSOGkPowdwRkhj1SsQS60WLETOI2PHHHEa1rybwUg== X-Received: by 2002:a7b:c00b:: with SMTP id c11mr583152wmb.122.1605051746740; Tue, 10 Nov 2020 15:42:26 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id s8sm296452wrn.33.2020.11.10.15.42.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 15:42:26 -0800 (PST) Message-Id: <42113e20dd7f2a80bbe09c01f1aedfcdfdbf6ae2.1605051739.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 10 Nov 2020 23:42:18 +0000 Subject: [PATCH 8/9] add -i (Perl version): include indentation in the colored header Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin The header is formatted by padding each column heading with spaces up to the length of 12 characters. These padding spaces are naturally included when coloring the entire header. However, the preceding five spaces indentation for non-flat lists were _not_ included in the Perl version, but _were_ included in the built-in version. Let's adjust the former to align with the latter's behavior. Signed-off-by: Johannes Schindelin --- git-add--interactive.perl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/git-add--interactive.perl b/git-add--interactive.perl index e713fe3d02..adbac2bc6d 100755 --- a/git-add--interactive.perl +++ b/git-add--interactive.perl @@ -483,10 +483,8 @@ sub list_and_choose { my $last_lf = 0; if ($opts->{HEADER}) { - if (!$opts->{LIST_FLAT}) { - print " "; - } - print colored $header_color, "$opts->{HEADER}\n"; + my $indent = $opts->{LIST_FLAT} ? "" : " "; + print colored $header_color, "$indent$opts->{HEADER}\n"; } for ($i = 0; $i < @stuff; $i++) { my $chosen = $chosen[$i] ? '*' : ' '; From patchwork Tue Nov 10 23:42:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 11895825 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 144B0C55ABD for ; Tue, 10 Nov 2020 23:42:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AD44920809 for ; Tue, 10 Nov 2020 23:42:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pv9tMqvv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732519AbgKJXmc (ORCPT ); Tue, 10 Nov 2020 18:42:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732505AbgKJXm3 (ORCPT ); Tue, 10 Nov 2020 18:42:29 -0500 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA350C0613D1 for ; Tue, 10 Nov 2020 15:42:28 -0800 (PST) Received: by mail-wr1-x443.google.com with SMTP id 33so358805wrl.7 for ; Tue, 10 Nov 2020 15:42:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=7fuDlDpWYpiI76IwISm/Zm85PJpd+Kjy9VbDOwFHfjw=; b=pv9tMqvvYBTheMtTXfr9bbw2rbmKoKDWn9B/sju8BQBnciHaWUuqRpNxegnhyF4HaE B2q/n6PG6Yl7Z2360bAgsRAnC3L+iDwZAfolMAUHHutRdvJotofIU8Pon3rY6LwsGf1C CiUuTUmTeqifgV+pwHPgXb8t4OIpQe3bVRjCSTlp2gvLazR1AbyoJEbg4DsRciXBZW6E GABP8gLvFHy9V6Z/kBswM6C4nbCcdUPiwnVsXcFG/yAISK1LN/X3/IwqQEBgIezJspKA Xx8j/o29NXLFL6F5lXdSeckJbIiFDfO6TaeX6U6mL0m91qjbcbufaFgNYmQBZr2UI8dG fD3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=7fuDlDpWYpiI76IwISm/Zm85PJpd+Kjy9VbDOwFHfjw=; b=A8n4NwwQW+qvSr95fa4GBlHgKLeZ4BojjRQzAD5NfktbkBHVCcgh9UwXfcqnAXKtO3 kPDTYNFrZQipwSxO5uU7lg0IFiX/Bk1X7zXo414Y5pMS50hk8Pdr3miuV/OLyLud+Ri6 yhsGsCEWScZriC1eVWhkaTwll6i0VJ/5Ql/BLKTuWm+vycR5q3BG7Yyr0/nvfvxwxFqx gs2r+iaNl/Dp4kKZkJKc62h4d8wYQR8eCD7Im1PwUnFdPsQDXuXm31V+TT4LZRaXLzAi DjC9j1yqKHarQJArhAaUerdXZBGvzh8QTxie9T1Ov5cyKYZP9KmPxPD2PyJEsvNcnhTb ZOLg== X-Gm-Message-State: AOAM530mI1cQKEDIN83K8qINrd68birQxcE7OUoBPySJe149rAWhQTNJ 2iyXgU4OTSypL5UKYp0mjIK40G0PiZo= X-Google-Smtp-Source: ABdhPJwohdFOSZ2k3outAamzHzvpvTiRh0uYZd8n4ViznX0k8du1rS18tBCqeHJ0RXe6vqlM3W5gcA== X-Received: by 2002:a5d:51c5:: with SMTP id n5mr5452774wrv.83.1605051747437; Tue, 10 Nov 2020 15:42:27 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id g131sm380370wma.35.2020.11.10.15.42.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 15:42:27 -0800 (PST) Message-Id: <38355ec98f04783367d74e38cda3ce5d6632c7ac.1605051739.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 10 Nov 2020 23:42:19 +0000 Subject: [PATCH 9/9] add -i: verify in the tests that colors can be overridden Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin Now that the Perl version produces the same output as the built-in version (mostly fixing bugs in the latter), let's add a regression test to verify that it stays this way. Note that we only `grep` for the colored error message instead of verifying that the entire `stderr` consists of just this one line: when running the test script via `dash`, using the `-x` option to trace the commands, the sub-shell in `force_color` causes those commands to be traced into `err.raw` because we set, but do not export `BASH_XTRACEFD`). Signed-off-by: Johannes Schindelin --- t/t3701-add-interactive.sh | 53 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index ca04fac417..28549a41a2 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -589,6 +589,59 @@ test_expect_success 'diffs can be colorized' ' grep "$(printf "\\033")" output ' +test_expect_success 'colors can be overridden' ' + test_config color.interactive.header red && + test_config color.interactive.help green && + test_config color.interactive.prompt yellow && + test_config color.interactive.error blue && + test_config color.diff.frag magenta && + test_config color.diff.context cyan && + test_config color.diff.old bold && + test_config color.diff.new "bold red" && + + git reset --hard && + test_when_finished "git rm -f color-test" && + test_write_lines context old more-context >color-test && + git add color-test && + test_write_lines context new more-context >color-test && + + echo trigger an error message >input && + force_color git add -i 2>err.raw err && + grep "Huh (trigger)?" err && + + test_write_lines patch color-test "" y quit >input && + force_color git add -i >actual.raw actual.decoded && + sed "/index [0-9a-f]*\\.\\.[0-9a-f]* 100644/d" actual && + cat >expect <<-\EOF && + staged unstaged path + 1: +3/-0 +1/-1 color-test + + *** Commands *** + 1: status 2: update 3: revert 4: add untracked + 5: patch 6: diff 7: quit 8: help + What now> staged unstaged path + 1: +3/-0 +1/-1 color-test + Patch update>> staged unstaged path + * 1: +3/-0 +1/-1 color-test + Patch update>> diff --git a/color-test b/color-test + --- a/color-test + +++ b/color-test + @@ -1,3 +1,3 @@ + context + -old + +new + more-context + (1/1) Stage this hunk [y,n,q,a,d,e,?]? + *** Commands *** + 1: status 2: update 3: revert 4: add untracked + 5: patch 6: diff 7: quit 8: help + What now> Bye. + EOF + test_cmp expect actual +' + test_expect_success 'colorized diffs respect diff.wsErrorHighlight' ' git reset --hard &&