From patchwork Thu Sep 1 15:42:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12962844 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 BB5E3ECAAD3 for ; Thu, 1 Sep 2022 15:42:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234553AbiIAPm2 (ORCPT ); Thu, 1 Sep 2022 11:42:28 -0400 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 S234049AbiIAPm0 (ORCPT ); Thu, 1 Sep 2022 11:42:26 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD8636F549 for ; Thu, 1 Sep 2022 08:42:24 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id ay12so9240594wmb.1 for ; Thu, 01 Sep 2022 08:42:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date; bh=B5OloREVnRuTJApLBPJqTGxixZTGgP2/aSJTQDVnViQ=; b=ihvOvHqFG566TYLqdJystxVyCC1hkWwdaoOsqtm4vN/VYzg4GhTlYNIjjBRBaONcpF ip1WmqrnhpDjE2oOqLQj34DTLShtetsjT12OhmGeM60VzMraXmg8FLXMI+xcC25JPact 2L6zGoOU6n4hanM0rnozbecNfPZ4yATGaYU8eHhrFbuXC0TTWxfjVXGtxl9kHvTRd15G SXUy9oPbHVLn0td5wOy1kThD4NYTVZgqRGU+AtHn7a0mMjdR7Co75c/tvMCfjmIA4MVn FYHLUIGO/DamNLl50/nbPXfbGrn3RKlT5ANIUBQtUe+rEJk4XtQnCz2WqhJ3hFD742cG 7Cgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date; bh=B5OloREVnRuTJApLBPJqTGxixZTGgP2/aSJTQDVnViQ=; b=OwK6sDefUn6wZKmwFMIrI8X1W4pH+mLrNXQ0tIMdXF7j6ruZRopuHR4xZyjGR23L0P LWJK1y2CKxe5/4u5w3tjGvakJX06LXnWIYiOhfizxbbjU6z+BpfATw325eI7ZIXt0O9S /vMfDTsx8EqSHODNK5soFSc1cP9bz2vmCWqsFzdIUQyOow4tW86OSlJ8yzXS0JuCzwhs fIYLPWkzREo34NmYNzVFIAy5xSC9e9/rwL9HEYmd3y2A9ITyxRMtfeIQ0404mOvp+wUN dtrTuYqfmZ+UuVOXAeVpEQd+9zv5n9U05pvfLWfAjv4ELMnSrDL0jtYOJxIr38O017I7 GT0Q== X-Gm-Message-State: ACgBeo2WpBoXxEtGr6hJJoQ4Tykk+hG0mIEjpyJhGmF7VA8nSu4qfNZS UPx9s0igzegSc2CTzo0T1wA8pDwKeY8= X-Google-Smtp-Source: AA6agR7zqghXxmmgsy7bLPEkVc841Pp8ujKLmy7uD2NRn5FvQ9zom4rZeo7aYPneKSwDPHoAz9y7Uw== X-Received: by 2002:a1c:f016:0:b0:3a8:3d3b:6b8a with SMTP id a22-20020a1cf016000000b003a83d3b6b8amr5661588wmb.168.1662046943155; Thu, 01 Sep 2022 08:42:23 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id j15-20020a5d464f000000b0022526db2363sm14813238wrs.30.2022.09.01.08.42.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 08:42:22 -0700 (PDT) Message-Id: <25187c3a3c2bb440ab0af34011db41361d4e2496.1662046939.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 01 Sep 2022 15:42:17 +0000 Subject: [PATCH v5 1/3] add -p: detect more mismatches between plain vs colored diffs Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Philippe Blain , Phillip Wood , Jeff King , Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin When parsing the colored version of a diff, the interactive `add` command really relies on the colored version having the same number of lines as the plain (uncolored) version. That is an invariant. We already have code to verify correctly when the colored diff has less lines than the plain diff. Modulo an off-by-one bug: If the last diff line has no matching colored one, the code pretends to succeed, still. To make matters worse, when we adjusted the test in 1e4ffc765db (t3701: adjust difffilter test, 2020-01-14), we did not catch this because `add -p` fails for a _different_ reason: it does not find any colored hunk header that contains a parseable line range. If we change the test case so that the line range _can_ be parsed, the bug is exposed. Let's address all of the above by - fixing the off-by-one, - adjusting the test case to allow `add -p` to parse the line range - making the test case more stringent by verifying that the expected error message is shown Also adjust a misleading code comment about the now-fixed code. Signed-off-by: Johannes Schindelin --- add-patch.c | 5 ++++- t/t3701-add-interactive.sh | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/add-patch.c b/add-patch.c index 509ca04456b..34f3807ff32 100644 --- a/add-patch.c +++ b/add-patch.c @@ -592,7 +592,10 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps) if (colored_eol) colored_p = colored_eol + 1; else if (p != pend) - /* colored shorter than non-colored? */ + /* non-colored has more lines? */ + goto mismatched_output; + else if (colored_p == colored_pend) + /* last line has no matching colored one? */ goto mismatched_output; else colored_p = colored_pend; diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index 3b7df9bed5a..8a594700f7b 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -761,9 +761,10 @@ test_expect_success 'detect bogus diffFilter output' ' git reset --hard && echo content >test && - test_config interactive.diffFilter "sed 1d" && + test_config interactive.diffFilter "sed 6d" && printf y >y && - force_color test_must_fail git add -p output 2>&1 && + grep "mismatched output" output ' test_expect_success 'handle very large filtered diff' ' From patchwork Thu Sep 1 15:42:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12962846 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 6FF09ECAAD3 for ; Thu, 1 Sep 2022 15:42:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233858AbiIAPmn (ORCPT ); Thu, 1 Sep 2022 11:42:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234561AbiIAPm3 (ORCPT ); Thu, 1 Sep 2022 11:42:29 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6923170E4B for ; Thu, 1 Sep 2022 08:42:26 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id s7so7995531wro.2 for ; Thu, 01 Sep 2022 08:42:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date; bh=kERYURGKCOIx2bAphXD91jz01qm2ikXkG3Gimn803TE=; b=RNfRI778RdFYV/dcPloNe/8HPdySNtpq0kKd28YA+vcckMr1fqmGBHypW2+zLDacEg lvIIIVmod8BvqxgkkTZKGZS+6MGwLPtDR1rCCz0EG+KSTvRrgVyu+FEv8GlxwgB/siVg RrOkq2vHNcivFpfd0uBU0MpkP0m7bWqN2OVRYs3tjBvK5ZRxiqgjNVMyPlU5g2FPjfei exruET+UmxbuzNvZTtyeJgRjySegpyuQNO8RyNqVqK6ruWgdC6q9tNFkUhmwpO4WCgbS t/N7UxNR44WDpXUtckxgfhzlbRyLYaf0sQke9U/H0raAT6HB6x5+moX3Q7kmBXvfsS4C 7YjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date; bh=kERYURGKCOIx2bAphXD91jz01qm2ikXkG3Gimn803TE=; b=BNd+JklqzcNFzqTltQ+nWfStrIGPvpYybhSBBJ2glHYFGquvZZio4JVAJU12Gx02rg GmOQbJRTLqHQc57OMliHiZjZcuX2KSgWQUcommuoh78Gg4tklATW07z6tUFoqVyJ12ZE CBOMyq2+XyOtT9YLpFOLR1095kiSWt00WCpG/lFT09XrnZqAkQMfFwaBodRFvLjiOnto 7BaZcs2Ft3n7PfWwQS8p1s9J0JDC8AtF1h1uqpHByfl5CRC5gP3naur+4KHdBbyDOMsl GtoDLKMkOzKzQB7DQZR0cgqQOkvOKNT/XHV+JbvUTkWM5MMse1CPcxaPP3sfiyA6ZSQ+ 3MnA== X-Gm-Message-State: ACgBeo3zm2F1ndUon+fAURcMqB62Yzers4d6hF9cwN/mF9hDFGJLvqBo MoX+db4z1tbO7O45+mZR46n7/7aJpvw= X-Google-Smtp-Source: AA6agR6k9rdv2znEhYYGCtZbZybATZHuaIZBederf6QGOEMjaLTrQynMLCSdXdluSQUdKNUOW7o1iw== X-Received: by 2002:a05:6000:887:b0:21e:24a0:f302 with SMTP id ca7-20020a056000088700b0021e24a0f302mr14502603wrb.466.1662046944394; Thu, 01 Sep 2022 08:42:24 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id c124-20020a1c3582000000b003a2f6367049sm5620651wma.48.2022.09.01.08.42.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 08:42:23 -0700 (PDT) Message-Id: <93d0e3b4d2a3dec5588c6e41d69313385356aa8f.1662046939.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 01 Sep 2022 15:42:18 +0000 Subject: [PATCH v5 2/3] add -p: gracefully handle unparseable hunk headers in colored diffs Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Philippe Blain , Phillip Wood , Jeff King , Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin In https://lore.kernel.org/git/ecf6f5be-22ca-299f-a8f1-bda38e5ca246@gmail.com, Phillipe Blain reported that the built-in `git add -p` command fails when asked to use [`diff-so-fancy`][diff-so-fancy] to colorize the diff. The reason is that this tool produces colored diffs with a hunk header that does not contain any parseable `@@ ... @@` line range information, and therefore we cannot detect any part in that header that comes after the line range. As proposed by Phillip Wood, let's take that for a clear indicator that we should show the hunk headers verbatim. This is what the Perl version of the interactive `add` command did, too. [diff-so-fancy]: https://github.com/so-fancy/diff-so-fancy Reported-by: Philippe Blain Helped-by: Phillip Wood Signed-off-by: Johannes Schindelin --- add-patch.c | 25 +++++++++++++++++-------- t/t3701-add-interactive.sh | 10 ++++++++++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/add-patch.c b/add-patch.c index 34f3807ff32..a6bd150de51 100644 --- a/add-patch.c +++ b/add-patch.c @@ -238,6 +238,7 @@ struct hunk_header { * include the newline. */ size_t extra_start, extra_end, colored_extra_start, colored_extra_end; + unsigned suppress_colored_line_range:1; }; struct hunk { @@ -358,15 +359,14 @@ static int parse_hunk_header(struct add_p_state *s, struct hunk *hunk) if (!eol) eol = s->colored.buf + s->colored.len; p = memmem(line, eol - line, "@@ -", 4); - if (!p) - return error(_("could not parse colored hunk header '%.*s'"), - (int)(eol - line), line); - p = memmem(p + 4, eol - p - 4, " @@", 3); - if (!p) - return error(_("could not parse colored hunk header '%.*s'"), - (int)(eol - line), line); + if (p && (p = memmem(p + 4, eol - p - 4, " @@", 3))) { + header->colored_extra_start = p + 3 - s->colored.buf; + } else { + /* could not parse colored hunk header, leave as-is */ + header->colored_extra_start = hunk->colored_start; + header->suppress_colored_line_range = 1; + } hunk->colored_start = eol - s->colored.buf + (*eol == '\n'); - header->colored_extra_start = p + 3 - s->colored.buf; header->colored_extra_end = hunk->colored_start; return 0; @@ -659,6 +659,15 @@ static void render_hunk(struct add_p_state *s, struct hunk *hunk, if (!colored) { p = s->plain.buf + header->extra_start; len = header->extra_end - header->extra_start; + } else if (header->suppress_colored_line_range) { + strbuf_add(out, + s->colored.buf + header->colored_extra_start, + header->colored_extra_end - + header->colored_extra_start); + + strbuf_add(out, s->colored.buf + hunk->colored_start, + hunk->colored_end - hunk->colored_start); + return; } else { strbuf_addstr(out, s->s.fraginfo_color); p = s->colored.buf + header->colored_extra_start; diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index 8a594700f7b..a94e7c53c8a 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -767,6 +767,16 @@ test_expect_success 'detect bogus diffFilter output' ' grep "mismatched output" output ' +test_expect_success 'handle iffy colored hunk headers' ' + git reset --hard && + + echo content >test && + printf n >n && + force_color git -c interactive.diffFilter="sed s/.*@@.*/XX/" \ + add -p >output 2>&1 X-Patchwork-Id: 12962845 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 2D00EECAAD3 for ; Thu, 1 Sep 2022 15:42:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234609AbiIAPmk (ORCPT ); Thu, 1 Sep 2022 11:42:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234559AbiIAPm3 (ORCPT ); Thu, 1 Sep 2022 11:42:29 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D03874DDB for ; Thu, 1 Sep 2022 08:42:26 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id ay12so9240653wmb.1 for ; Thu, 01 Sep 2022 08:42:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date; bh=nf4twPT1TqiD8Fzhj1tZS8GKn6mD7SFi6fZUL/RXV7o=; b=Cz1xG+CO8Rg23sa24Ejrs43DV790ayBLkxCdnLC7sqjneLZuSPaNyCMhCvLhy5LyAL oYUOjmnwwgYU9qhy32NqdwIV4yXfgq68unZpG1KkjU6+3dYPZ2FGlHKlo8G1Ewi4PWSx GzzxwyEvCFmewTIEmVqZao74xl2HkRuQwJoePtCOmW2ifh+CupThWpHy+TfEylzSEHaF Domjfkgijg90R03qroQ3CR00LiILYv67+sQFBfe0Dp2nCMHACBDo/2iZ94yaXbucupB5 ju57FpQipZ6L7Y/90RztTpAbm+p82Qx00sN3hPjox5xlqchO8eKOtAGIsgqhozXokqn5 WtWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date; bh=nf4twPT1TqiD8Fzhj1tZS8GKn6mD7SFi6fZUL/RXV7o=; b=fImlgT/GlHOUuRln20GdHL8DNamt0pnPq+fh2DOQzG7XwEJP0FppPXExw0wkYCFoe8 TuUTvV77E8TgrAUftMiA99I4JBiSFft8OhDWu3PDCOVsz/6SIDseLIM0AJJO4xUK2FBW 6d/gLQkeUWysuNa+eekNkmca3sfbGWK82LmQh6AkiUpFXIf4hFyki9r/7PzMhhB6hrXS Gl5UtWxFq/VxCEdZvp1XeuDZS7FB1e6JUZEGPYkGxbRU76ApUExHrucEEi4u0boRP8rZ uKIjdqyKK8r8RxXCnteDE43ykKJz5jh7NwZQSznoUETgVYpvxs5bjXPik4H39tRUyC+d VE/g== X-Gm-Message-State: ACgBeo1dXg09hsjXyXDrzg4Ihf4o1S8gyrzRM/JeFZpE5ctxB5fFT1Y+ Nx3CY8+iwQIA17KR2FEIN2Sr2RMdu24= X-Google-Smtp-Source: AA6agR7HS845lYuB1cHDb8gT9cmhUm7AD4mkTVeCITUHzMhZa85C1X9qFDzTalPO9+B+m9p9G0cwXA== X-Received: by 2002:a05:600c:19d3:b0:3a8:3b06:655a with SMTP id u19-20020a05600c19d300b003a83b06655amr5567071wmq.182.1662046945660; Thu, 01 Sep 2022 08:42:25 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id r5-20020a05600c35c500b003a5e9337967sm5772760wmq.13.2022.09.01.08.42.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 08:42:25 -0700 (PDT) Message-Id: <47943b603b1f2330b36a3050fe7463bca6eeddef.1662046939.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 01 Sep 2022 15:42:19 +0000 Subject: [PATCH v5 3/3] add -p: ignore dirty submodules Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Philippe Blain , Phillip Wood , Jeff King , Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin Thanks to alwyas running `diff-index` and `diff-files` with the `--numstat` option (the latter with `--ignore-submodules=dirty`) before even generating any real diff to parse, the Perl version of `git add -p` simply ignored dirty submodules and does not even offer them up for staging. However, the built-in variant did not use that flag because it tries to run only one `diff` command, skipping the unneeded `diff-index`/`diff-files` invocation of the Perl variant and therefore only faithfully recapitulates what the Perl code does once it _does_ generate and parse the real diff. This causes a problem when running the built-in `add -p` with `diff-so-fancy` because that diff colorizer always inserts an empty line before the diff header to ensure that it produces 4 lines as expected by `git add -p` (the equivalent of the non-colorized `diff`, `index`, `---` and `+++` lines). But `git diff-files` does not produce any `index` line for dirty submodules. The underlying problem is not even the discrepancy in lines, but that `git add -p` presents diffs for dirty submodules: there is nothing that _can_ be staged for those. Let's fix that bug, and teach the built-in `add -p` to ignore dirty submodules, too. This _incidentally_ also fixes the `diff-so-fancy` problem ;-) Signed-off-by: Johannes Schindelin --- add-patch.c | 3 ++- t/t3701-add-interactive.sh | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/add-patch.c b/add-patch.c index a6bd150de51..a6596532867 100644 --- a/add-patch.c +++ b/add-patch.c @@ -419,7 +419,8 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps) } color_arg_index = args.nr; /* Use `--no-color` explicitly, just in case `diff.color = always`. */ - strvec_pushl(&args, "--no-color", "-p", "--", NULL); + strvec_pushl(&args, "--no-color", "--ignore-submodules=dirty", "-p", + "--", NULL); for (i = 0; i < ps->nr; i++) strvec_push(&args, ps->items[i].original); diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index a94e7c53c8a..5a7a0ea7e83 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -955,6 +955,18 @@ test_expect_success 'status ignores dirty submodules (except HEAD)' ' ! grep dirty-otherwise output ' +test_expect_success 'handle submodules' ' + echo 123 >>for-submodules/dirty-otherwise/initial.t && + + force_color git -C for-submodules add -p dirty-otherwise >output 2>&1 && + grep "No changes" output && + + force_color git -C for-submodules add -p dirty-head >output 2>&1 actual && + rev="$(git -C for-submodules/dirty-head rev-parse HEAD)" && + grep "$rev" actual +' + test_expect_success 'set up pathological context' ' git reset --hard && test_write_lines a a a a a a a a a a a >a &&