From patchwork Wed Aug 31 20:31:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12961405 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 68809ECAAD8 for ; Wed, 31 Aug 2022 20:31:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231136AbiHaUbZ (ORCPT ); Wed, 31 Aug 2022 16:31:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230168AbiHaUbY (ORCPT ); Wed, 31 Aug 2022 16:31:24 -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 1D584DEA59 for ; Wed, 31 Aug 2022 13:31:23 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id b16so12109810wru.7 for ; Wed, 31 Aug 2022 13:31:23 -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; bh=B5OloREVnRuTJApLBPJqTGxixZTGgP2/aSJTQDVnViQ=; b=U1lEsD6QgkOvWzbH/iPuDFjpj5invsGA3gM+aq9jpJ90FNWXctlX93rPXjbXcH+fT2 BpsMqx2vbeGZjln9E3Od+CuTEpnT/Opf+3/30ef/mF48S8kyKuAhWUK3nVYy/Y4hYNLJ o87mbXofQf5t14M3nHYX7SsYv+PaTv1ifTWpNUtDCGDWIumJR4up2S6jggWy6aZGZT59 /Pe2B6JFNWk9ymvA1msxWTor8vyKxYPeLTK9M424at6tCMBm7vCMk9w5CcQRqoBd708M jUPIotrbMP8Mb9tkOaCpNuqZ8mU5ci/V8Po2tRAKpuJ68lsXnpV6nNYYraJaVaHCyK1G Jwaw== 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; bh=B5OloREVnRuTJApLBPJqTGxixZTGgP2/aSJTQDVnViQ=; b=Hv3IQDiiglSMfr3kYy4BlZVropXI6aAQ/g+vekN66AP9ff1wmJQGkQhkuEphDZBtE7 bPZBOwNPDaSNkzYmJpfZSIXb+e0Kqo7Fm1lO0mera5psDUueK6QhTlysxrQ/aFc6EmCS oKKGVCwE2Up+SfoQ9d+UPnb/gUSqV2UyZawx2zrSBxibnIOF+oRlm/G3/d7ilkV11c4z RUEwYw4ozgLGektMjxFhi7zzqxFPYnQKF3sQQ2GKlcioL+Pf5519Em6wOBjcJMNZxwG0 t9P54bldaAPr4+zzalPkPGHUB7HhS64g3yiDsVmHd6QYOkdoojpY+IpwPHNGWkBnNnP0 1A2w== X-Gm-Message-State: ACgBeo3+ghPK+Uhj5sKTbjNGbjKtNo2evcDGl85HPgFe77DDsq1JeQzf YkapDutq/SblaPta5BJa4ygDtEIzepI= X-Google-Smtp-Source: AA6agR6H1/LCBay8czWkPuYbr+TZWzVSBzk/NwbThvfu0m9CotmO9CTkMgOhdiprEdtNnAoUkyvCuA== X-Received: by 2002:a05:6000:616:b0:226:d80b:76ab with SMTP id bn22-20020a056000061600b00226d80b76abmr10007341wrb.547.1661977881353; Wed, 31 Aug 2022 13:31:21 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id r14-20020a0560001b8e00b0021d80f53324sm12883331wru.7.2022.08.31.13.31.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 13:31:20 -0700 (PDT) Message-Id: <25187c3a3c2bb440ab0af34011db41361d4e2496.1661977877.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 31 Aug 2022 20:31:15 +0000 Subject: [PATCH v4 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 Wed Aug 31 20:31:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12961403 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 435E6ECAAD1 for ; Wed, 31 Aug 2022 20:31:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231308AbiHaUb3 (ORCPT ); Wed, 31 Aug 2022 16:31:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230266AbiHaUbZ (ORCPT ); Wed, 31 Aug 2022 16:31:25 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2572EDEA61 for ; Wed, 31 Aug 2022 13:31:24 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id n17-20020a05600c501100b003a84bf9b68bso238517wmr.3 for ; Wed, 31 Aug 2022 13:31: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; bh=vw2YPkIK4ICW8vAPm9dPPgG8VwTheHZP63gf3yELzns=; b=lBQOvDLiIHXOBmWhK+UczH2eruKMxa2Nr12MciGc6hMFR9+ziZISpLvlzgX6jLlmNe SDPAOblf726pJdshZRJyHR5CgsYM0L+qmoFjW1OkOGh+2CWeGCqbWN/mOnJntMGV1wSQ Z2bOzMJ7tWr8PfnJcOPnqTMPwTEe1C0g924TSCkxM3z/yQ4DvT6U8X1J5JoV5HW3K+n6 Y5DjjIez18/jGzJsngy1lyOA+x5L8thS84J912da93jlmA0x/0fUWGVEgeHg++cc9z12 bKe2s10pc/zvzpnYXbCcAqVtGvesSe64g2THMUlcPfp5soM8d6p42bkk2wy5apg43KbI izsA== 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; bh=vw2YPkIK4ICW8vAPm9dPPgG8VwTheHZP63gf3yELzns=; b=7d3pSzRoECjeFtubtFTjFeCtwQ3kp8dGboftPsvJdL2kv65b0ASED5sCeBZJNRJOjS mUmXyKFVI4PW9ez1YD2q6hWwcbuXrWJbQQSyOhScRrxw9PCNMg81i8TlzCWocZrEtxLs 03m7DLj8yevsTxuSIr+NlPb+pl4U0ZGUUsY0z6cXaxE3vPQ9F/3SviLu1Bv67UFJsisc HNv9n8XNeOnCzjPGjAGJ1wL7auv5FwB7DT9UE72+ZQawomKJyxYNxouh343hrPAeZoGa Gb1r2bUJ91yl9Q+JH/xW7C6zNAA3L8Mi8EZyrqEq+qaWKLKfUWjQ0PWWgt4T8t0vvJS2 l2EA== X-Gm-Message-State: ACgBeo31bFT5v0V98JiOWLcje3FNshSIWCcysbHTcA5dEnEwIgwld3x3 LILuHn61M5DO+0YFT47E+wDvXUjcmMw= X-Google-Smtp-Source: AA6agR61GnFqLg8s0trsCQg9wq6+7eN0atJfdhU6vjOV1cvqa26lpHxI89Jy5qUPk/8vTtUOuLnhWw== X-Received: by 2002:a05:600c:3ac6:b0:3a5:c03f:510d with SMTP id d6-20020a05600c3ac600b003a5c03f510dmr3039698wms.120.1661977882453; Wed, 31 Aug 2022 13:31:22 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f6-20020a7bc8c6000000b003a35ec4bf4fsm3050390wml.20.2022.08.31.13.31.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 13:31:21 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Wed, 31 Aug 2022 20:31:16 +0000 Subject: [PATCH v4 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. This commit is best viewed with `--color-moved --ignore-space-change`. [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 | 42 ++++++++++++++++++++------------------ t/t3701-add-interactive.sh | 10 +++++++++ 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/add-patch.c b/add-patch.c index 34f3807ff32..3699ca1fcaf 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; @@ -666,18 +666,20 @@ static void render_hunk(struct add_p_state *s, struct hunk *hunk, - header->colored_extra_start; } - if (s->mode->is_reverse) - old_offset -= delta; - else - new_offset += delta; - - strbuf_addf(out, "@@ -%lu", old_offset); - if (header->old_count != 1) - strbuf_addf(out, ",%lu", header->old_count); - strbuf_addf(out, " +%lu", new_offset); - if (header->new_count != 1) - strbuf_addf(out, ",%lu", header->new_count); - strbuf_addstr(out, " @@"); + if (!colored || !header->suppress_colored_line_range) { + if (s->mode->is_reverse) + old_offset -= delta; + else + new_offset += delta; + + strbuf_addf(out, "@@ -%lu", old_offset); + if (header->old_count != 1) + strbuf_addf(out, ",%lu", header->old_count); + strbuf_addf(out, " +%lu", new_offset); + if (header->new_count != 1) + strbuf_addf(out, ",%lu", header->new_count); + strbuf_addstr(out, " @@"); + } if (len) strbuf_add(out, p, len); diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index 8a594700f7b..47ed6698943 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: 12961404 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 58AB2ECAAD4 for ; Wed, 31 Aug 2022 20:31:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231515AbiHaUbd (ORCPT ); Wed, 31 Aug 2022 16:31:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231233AbiHaUb1 (ORCPT ); Wed, 31 Aug 2022 16:31:27 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF23ADEA61 for ; Wed, 31 Aug 2022 13:31:25 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id n17so19734144wrm.4 for ; Wed, 31 Aug 2022 13:31:25 -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; bh=+hBrOL8Dca+RUgK/6ufJERYm9VBDUOLT2dFYPIEr2Fk=; b=Ncz06QkoDYEATMPZ7mGbdEytv3adTXhj3mSUlptMpkM8QeieJVAPp6CO9lkCRLQC1b +GYaKWYw/uXU/SnKA42RxhhGIn5VvwEADNN9Mq5eZOxb8P+l6fofZcfCD8B2eAIo+Faz TH7SOxQHQkYxBmc2B+UB8Sl2JKPPDo29d0NVIHtL9+bdFE93dWHxSu3cn5afYOrJoy1+ VnO0Vkd24UOcdo7NjGSWyLP8kTO14SOcMqGS8EOJYUE7jgUDuU35nZD+TOoAdksQZ79U L1IAJEfoIiTT24A4WGAWteF9tR5cRj39ic+62sSOGz+RJKNT59vP/Vb9tVscxHDMc3fa QuEw== 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; bh=+hBrOL8Dca+RUgK/6ufJERYm9VBDUOLT2dFYPIEr2Fk=; b=T+Mh6/7JfBuwcAHgLUFqZrBslZlCarN4qBwCaerH4Q9xLuNM9ImGrEZLg+rVLJkvK2 dIG/FjzrKIYXf0LSmE1uA1Yyhiu3yNanKNk0rOMqf2BOWCF6AiT326quN+BOiOp2ym7F UOri+OxWPVupGsuecC/RuRi+RNZjlKuusWNdxTV9Azk71FAPbSKSofu2PKyxsYlppp0m th62sxIi4Ib3zayoYohhsJj8NpL5PXmd0oQ8KGLQIdfh2PAHw0lTAUjfPms6CbWYsP9n MHiYrFDo07B3Q3TZytyK8IOrnxD0aF8QZiwaDDqmCIldkI1PQB0LwUwo4iUYbI8PwEFR sjnA== X-Gm-Message-State: ACgBeo1wpAsZdrTwjX+SYehCyHQb+1UNjdFwq5DsOJRZn05oXvcdMm5d XqQTSR6i2B+B0plJoMDb8eBCJcDBceQ= X-Google-Smtp-Source: AA6agR6ngS5npnOJA2wVmcmZmwPTCUIWkqUyhltztu7+C0Kp56RZryhMhuyWd7PgRDxjp2NZjwbnBw== X-Received: by 2002:a05:6000:78d:b0:226:d5c1:5ebd with SMTP id bu13-20020a056000078d00b00226d5c15ebdmr10417764wrb.565.1661977884040; Wed, 31 Aug 2022 13:31:24 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id az26-20020adfe19a000000b0022529d3e911sm13717397wrb.109.2022.08.31.13.31.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 13:31:23 -0700 (PDT) Message-Id: <116f0cf5cabee3590957731740b33e800b762f34.1661977877.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 31 Aug 2022 20:31:17 +0000 Subject: [PATCH v4 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 3699ca1fcaf..c7eebe9de89 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 47ed6698943..2d710645719 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 &&