From patchwork Sun Aug 25 10:17:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Rub=C3=A9n_Justo?= X-Patchwork-Id: 13776730 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 72665179A3 for ; Sun, 25 Aug 2024 10:17:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724581062; cv=none; b=lIiSYgs39GbNQPlfbjhmoxReMQGmf5XCM+P92av8VF2wX47NEeY5r7hdN06V30fYhWCTBaMGC/a+n7X5C+EYjmRGfOHQMI5YBugHaiv0mRI4XjOK2nVNxOt0vdYRPvcMvkXXpidi2EUYMoP4bY8aEVG68gbzD8QHfRB8xqcr4lM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724581062; c=relaxed/simple; bh=TdOKBhwtAYai1j0b69Z1h+8e744KVWP5Jl1659ci+9I=; h=Message-ID:Date:MIME-Version:Subject:From:To:References: In-Reply-To:Content-Type; b=CuwCnF07mnuvcByHopITW//4GOr719UBRqRpI5colf0LdYOhfibvXJkTDn3kfMCEWdHUCzXR9RtvlbfLNXFIECJP/qQvjebUOJol0Wmgfwk8AC0pGWYUV8CMzvw6wK1emnCqGRq9zyEvW4Q3cpC2c8vtqr0+XWL8dkZ5K7yk3Mo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MaCKoyiY; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MaCKoyiY" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-428119da952so29437795e9.0 for ; Sun, 25 Aug 2024 03:17:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724581059; x=1725185859; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :to:from:subject:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=RD7xsGWQTBM3adqMZVi9tIkbVtYjUa5EBaYmSoNgxNA=; b=MaCKoyiY56gfa4kQUqEKzGO6I4LjPbn0SkTzyPEXNyALYmUpwbiTU+PrI8bJhcji8a 6kOGQj9FJ6PXvcbcrPsz6ZAF979YrmnJXyM3ON3Y8eLyHePsfIG0lmYVYzyxLOlWDgPG ylP2kgrpojWdzVyvfU5ytIxNmyFEc2NiEl3sb4j8xYlsHMcSaBjkrozfVZ47ANdaAvfW oo8e/PRq5py2ljadoF6QPH4rUwYscu3nGT1eGPe06fqcGdhk4cGI0Gq16icG9URL91TV uSoF9XEsZToGtulBIOxL6sdzgMO6ESrNwTnyAlhILnmVXgYYN7CFEVCYOYatJyzlIpxF 3ipw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724581059; x=1725185859; h=content-transfer-encoding:in-reply-to:content-language:references :to:from:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=RD7xsGWQTBM3adqMZVi9tIkbVtYjUa5EBaYmSoNgxNA=; b=c0IieAf2k78P5TO0SU+MxBlM4BdK1eNjkzVRv49d41Em2rF8lpuDsJXI7nWXb9Aga3 CbnOSJGT8EFmftGMv5rB/y+V4cuN1yxGbrhvFb1WBUeyRVnLC8v1ZMJdg0Wba82oM3eW yRDkiwrmGfYVnZOms9ZI7q3ObbUkBHoEfoIJQysdtr7PFvsdugMTXK/iUsf/czkvyj9L GPhMl183Vx80XyBUuzozAmgI0wZyCyNsjE8hv/U6bBAvq1L5mXbIHbL31+asHra16tHm 0UwAeFPHufgdLDj0L4A5guklDxQy/F6ZrtLUGGzz9Asnj+MDSVFf8yJYr+cBmv8DIn3r 5shg== X-Gm-Message-State: AOJu0Yz5mZxqHNJAGArdaxlyjkTiLLZPkw35Vd+xcSwtbgAqBWbNLxxg OtekcH+q7Ac+uit6Ov2iYrn3ETobEs2ULCrfTR/AW3AvAL+nd49GNj6khA== X-Google-Smtp-Source: AGHT+IGQKfZEGeaOViLkCFHSYXPlCCcFotwp1+6K4rbJ4/Ma0AxWClJnPUKZpsVYcZgE6BT6U3UTjw== X-Received: by 2002:a05:600c:3516:b0:426:5e8e:410a with SMTP id 5b1f17b1804b1-42acc9f66a7mr55246595e9.24.1724581058391; Sun, 25 Aug 2024 03:17:38 -0700 (PDT) Received: from gmail.com (107.red-88-14-46.dynamicip.rima-tde.net. [88.14.46.107]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42abefeaa45sm155810785e9.39.2024.08.25.03.17.37 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 25 Aug 2024 03:17:38 -0700 (PDT) Message-ID: <5e35f260-056c-4af3-95d9-70d6f117bff9@gmail.com> Date: Sun, 25 Aug 2024 12:17:37 +0200 Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 1/5] apply: introduce `ignore_ws_default` From: =?utf-8?q?Rub=C3=A9n_Justo?= To: Git List References: <6dd964c2-9dee-4257-8f1a-5bc31a73722e@gmail.com> Content-Language: en-US In-Reply-To: <6dd964c2-9dee-4257-8f1a-5bc31a73722e@gmail.com> When we see `--whitespace=fix` we don't consider a possible option: `--no-ignore-whitespace`. The expected result in the following example is a failure when applying the patch, however: $ printf "a \nb\nc\n" >file $ git add file $ cat >patch < --- apply.c | 2 +- apply.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/apply.c b/apply.c index 6e1060a952..63e58086f1 100644 --- a/apply.c +++ b/apply.c @@ -115,7 +115,7 @@ int init_apply_state(struct apply_state *state, state->p_context = UINT_MAX; state->squelch_whitespace_errors = 5; state->ws_error_action = warn_on_ws_error; - state->ws_ignore_action = ignore_ws_none; + state->ws_ignore_action = ignore_ws_default; state->linenr = 1; string_list_init_nodup(&state->fn_table); string_list_init_nodup(&state->limit_by_name); diff --git a/apply.h b/apply.h index cd25d24cc4..201f953a64 100644 --- a/apply.h +++ b/apply.h @@ -16,6 +16,7 @@ enum apply_ws_error_action { }; enum apply_ws_ignore { + ignore_ws_default, ignore_ws_none, ignore_ws_change }; From patchwork Sun Aug 25 10:18:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Rub=C3=A9n_Justo?= X-Patchwork-Id: 13776731 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D2123179A3 for ; Sun, 25 Aug 2024 10:18:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724581113; cv=none; b=bdxlkCFNZ8pUiNMO6Sk8D3GNWdGyowNy0YjoMoXUUIjHsS1JCrXoTa/hcdvkp4bfvPcmhAHn7vUZchc1E6wNjqTLL1eBt2oZck+7Qe+3t+VnIsxaOHWYC8PdvXEYstzS6FKUgr4k8FgMf4nsRU1pBNB5WJPTWwvXkCG3fyF6qfw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724581113; c=relaxed/simple; bh=ic2htbZD6Vj08wheuXREoXMzo1E/lZV4ipPXEEdbqTY=; h=Message-ID:Date:MIME-Version:Subject:From:To:References: In-Reply-To:Content-Type; b=AT2/obWqa8giccyL4C7xPsIIb1enV6ZbIjZF6oRKQed/LzmC3gcpi0omDfLO2MR0IizDY4/n17EBX3JPdLhcZK73IwvXaWKFpx+VPc7TINb6zZ1fNcXiscw9D/T0pmhSg+ql/AXGN30Xxk4JfRkAsHUgbWhV+lfL3V1usfwAX6U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ddnV+iJo; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ddnV+iJo" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-3717de33d58so2008228f8f.1 for ; Sun, 25 Aug 2024 03:18:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724581109; x=1725185909; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :to:from:subject:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=DLRsFzgHLym3FXT5vCXeDqHsP12/gdWYq3ftp+fwZe8=; b=ddnV+iJo453LFL7jqnpobLFa3IPkj58yjS8PU+PIMQKrVU3Y0ivEaCP1gdNqp10o2l xFEjp1M2Aw4x0P7LFmVcJO+Tm3FedWIwm3dDilkdITUGbNDk9rIWMba3iW5hu35CwOFs q840Mh0CCNznbrkzA7ARNel4S2LSmSmzsGacu6Tgr6h1FWI12JWjkeqV+POyEC87g5Eq IjeTm/WYYjLJr/dKUgam4i9Yt6ouKtVxQ3vk04OJQKfRO/ZIhwxnJ0K40mMnhDisMLaA ml07SA+iW4XTvkeYaUcsLHepsGBhNri25pqXTP1QVGnxb97zKqte0TMBkwZ5ea+xiIgB xoTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724581109; x=1725185909; h=content-transfer-encoding:in-reply-to:content-language:references :to:from:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DLRsFzgHLym3FXT5vCXeDqHsP12/gdWYq3ftp+fwZe8=; b=X76C4bru/lT66tiZ9MZBFgukqHUBv0Qatgi6LWIWNYWVvYC6CT26Y99JvxvAeDfLok sQ6iW5zs4VaPvGClELC/vU5dRyy8VllxG6n282Zlc2KCboYlI2Fz6IyHbIMsnhLqQ9F+ yb3VBg4LRbZErrGOKaoW/jKSqzM3rRovZEXWPPPuvVvcb+7Aw23tiGA6+w/EoAXrNMFa +kqJAZrD0PCzl+yH5cA5WY5vhIxkUAd2BwXpnUHeDQrx3vDWp+ep+m8z/v8+SCydAH7R cZUJms1NVHD3IFMto4YiYuHYWfPeyddLJHbPJQxWW12y06UH03V5/2y+sYnj18LrjOjH ai9w== X-Gm-Message-State: AOJu0YwP32Q5/G/VipNkAqxdImx6I2Q9ZYUo/SUebBKxdPL6ZD3Pe0nt oxNy4zh3TINZVIpDcgx32dO+67wZzDhMn9etg3PkAimkOeM5968Xm+fOhw== X-Google-Smtp-Source: AGHT+IFBjDb2Yz8hALLnphmCaBJKQCJlTWQMz/fJi/E+VU7IhPFMN+p9OLgEf2YMk6xstAs8BKGaaA== X-Received: by 2002:a5d:464e:0:b0:371:7db6:89df with SMTP id ffacd0b85a97d-373118644e5mr4092979f8f.31.1724581109052; Sun, 25 Aug 2024 03:18:29 -0700 (PDT) Received: from gmail.com (107.red-88-14-46.dynamicip.rima-tde.net. [88.14.46.107]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37308110436sm8340720f8f.11.2024.08.25.03.18.28 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 25 Aug 2024 03:18:28 -0700 (PDT) Message-ID: <1eb33969-1739-4a27-a77b-3f4268f5519d@gmail.com> Date: Sun, 25 Aug 2024 12:18:28 +0200 Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 2/5] apply: honor `ignore_ws_none` with `correct_ws_error` From: =?utf-8?q?Rub=C3=A9n_Justo?= To: Git List References: <6dd964c2-9dee-4257-8f1a-5bc31a73722e@gmail.com> Content-Language: en-US In-Reply-To: <6dd964c2-9dee-4257-8f1a-5bc31a73722e@gmail.com> Ensure strict matching of context lines when applying with `--whitespace=fix` combined with `--no-ignore-whitespace`. Signed-off-by: Rubén Justo --- apply.c | 3 ++- t/t4124-apply-ws-rule.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/apply.c b/apply.c index 63e58086f1..0cb9d38e5a 100644 --- a/apply.c +++ b/apply.c @@ -2596,7 +2596,8 @@ static int match_fragment(struct apply_state *state, goto out; } - if (state->ws_error_action != correct_ws_error) { + if (state->ws_error_action != correct_ws_error || + state->ws_ignore_action == ignore_ws_none) { ret = 0; goto out; } diff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh index 485c7d2d12..573200da67 100755 --- a/t/t4124-apply-ws-rule.sh +++ b/t/t4124-apply-ws-rule.sh @@ -545,6 +545,33 @@ test_expect_success 'whitespace=fix to expand' ' git -c core.whitespace=tab-in-indent apply --whitespace=fix patch ' +test_expect_success 'whitespace=fix honors no-ignore-whitespace' ' + qz_to_tab_space >preimage <<-\EOF && + AZ + BZZ + EOF + qz_to_tab_space >patch <<-\EOF && + diff --git a/preimage b/preimage + --- a/preimage + +++ b/preimage + @@ -1,2 +1,2 @@ + -AZ + +A + BZZZ + EOF + test_must_fail git apply --no-ignore-whitespace --whitespace=fix patch && + qz_to_tab_space >patch <<-\EOF && + diff --git a/preimage b/preimage + --- a/preimage + +++ b/preimage + @@ -1,2 +1,2 @@ + -AZ + +A + BZZ + EOF + git apply --no-ignore-whitespace --whitespace=fix patch +' + test_expect_success 'whitespace check skipped for excluded paths' ' git config core.whitespace blank-at-eol && >used && From patchwork Sun Aug 25 10:18:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Rub=C3=A9n_Justo?= X-Patchwork-Id: 13776732 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DF4E179A3 for ; Sun, 25 Aug 2024 10:18:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724581129; cv=none; b=EGsBrPqLRjB2F35uG4DJnnKJ/ebAr2d+fBmnD7CGN733ghGyOmxiGftl0YhAcR1Q4ddEueAZZ7i4ZPzFh+8lLCUvXaJ43qGWG5njstnbOQ0VTwwIxN5vwpXpniNbgmiAFPPKKKWWcAG7nbNmF5xbvCEZf/Vbsf/8D5PyWtzIixo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724581129; c=relaxed/simple; bh=hr8jExKu0e/1cUjYg5epwuCqABp2PLGDxkjzjLW0gdI=; h=Message-ID:Date:MIME-Version:Subject:From:To:References: In-Reply-To:Content-Type; b=ZTY9aT5pdbE0MEuhpk2UAONWH4kXC8VAQBfUjNjOML0iL2IQpRb+iTsY0HSzVC3G3UUP4OCWdsO59VGnyhfwi/mgM9tDbgAg9JA4xwyG6Rh7S8XsbP30HP3hFhHj1Lnd5M4T34OLxydvk4w/H/fdAnGv0OR7UYXrxyDVhoFMrsc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YLEbB6EW; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YLEbB6EW" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-3718ca50fd7so1955148f8f.1 for ; Sun, 25 Aug 2024 03:18:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724581126; x=1725185926; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :to:from:subject:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=FZLxg3Tjo5JORP7xvYt14xiSBMulfWGQAqSKk7lufPk=; b=YLEbB6EWRfAapTuIAdEALKPznJUVoPcA96DQHRKDA6Ht1GerhWnphVnkBRCC14JvZr TQl6BFq+YzVyeXyi+htIyX4h18t38TKdRTX+63oLqCIVn1eV3W2niD/pYDjOgbrbg/jP u8a10VLJ4JFxKeRHMXJ9PieDXpz3g19PbbqPGis2T61A1IJvkEVqSKcNc4ATVb0PBBYy VcwXGY5naqRXcMLgSOBVLxbo4o7Bgf8znPjWEcfMs9T5o6sw86elgpQE5C5xbz0rX04v p7WIbeDfO5+io2XJZRVfbqCgoblhNovRbwy3ZcBXkxr6+fAH14gS8wzl1JarFBepzYk4 rFuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724581126; x=1725185926; h=content-transfer-encoding:in-reply-to:content-language:references :to:from:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FZLxg3Tjo5JORP7xvYt14xiSBMulfWGQAqSKk7lufPk=; b=EBve9HIXRwPcqf6WwjO69RFDDFhkNhcsEiIEZk1hlgwJryuLKu+obqAE0UPoaSvJLu VVCFCkaQaZTiwwvxQdE1B4RLEQ/rTvcN7fksl0+rtEwl8zTH9SPSAonHwvHM7PqEn6sk n96MQIXhRqkd440ujR3Jdtt9Z/R51uyADyLZeQOQSEGl5SDaDoz3hfbk9N88UcThVvFH xgbHp7f02HVih9BEn25P7kw6NVW41h/T7bwiCUrF5eqE+7HtHsyJj+Lpxb9ThjqDN9J6 jRINJCq1mNYwpPTK9B2O6q34By3e+2eAz3eX26zc231Hkdu4cW5C5JG7vR8X6Cls/4SB ocDw== X-Gm-Message-State: AOJu0Yy53MkfL4+zYuiqPP13LtcgjyPd7EIaZKIWyNUpNuUWAGYqO76Z 1HUPxzMtym/RgeILD51ayvvVZoXUBmJAvN7ZaQM2SyaJc5VCa2fALxmCmQ== X-Google-Smtp-Source: AGHT+IFAX2QDKfh0F6uMsNgdb+xwCZziwEeEZ6gzyIq7ke7tJtKaejD5k7/SkDEAggE9aWNNgJgisQ== X-Received: by 2002:a5d:4891:0:b0:371:83a8:afee with SMTP id ffacd0b85a97d-37311866532mr4154464f8f.27.1724581125513; Sun, 25 Aug 2024 03:18:45 -0700 (PDT) Received: from gmail.com (107.red-88-14-46.dynamicip.rima-tde.net. [88.14.46.107]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-373082657bdsm8356366f8f.107.2024.08.25.03.18.45 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 25 Aug 2024 03:18:45 -0700 (PDT) Message-ID: <5da09529-e95b-407b-9e66-34ebac4b4128@gmail.com> Date: Sun, 25 Aug 2024 12:18:44 +0200 Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 3/5] apply: whitespace errors in context lines if we have From: =?utf-8?q?Rub=C3=A9n_Justo?= To: Git List References: <6dd964c2-9dee-4257-8f1a-5bc31a73722e@gmail.com> Content-Language: en-US In-Reply-To: <6dd964c2-9dee-4257-8f1a-5bc31a73722e@gmail.com> If the user says `--no-ignore-space-change`, there's no need to check for whitespace errors in the context lines. Don't do it. Signed-off-by: Rubén Justo --- apply.c | 3 ++- t/t4124-apply-ws-rule.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apply.c b/apply.c index 0cb9d38e5a..e1b4d14dba 100644 --- a/apply.c +++ b/apply.c @@ -1734,7 +1734,8 @@ static int parse_fragment(struct apply_state *state, trailing++; check_old_for_crlf(patch, line, len); if (!state->apply_in_reverse && - state->ws_error_action == correct_ws_error) + state->ws_error_action == correct_ws_error && + state->ws_ignore_action != ignore_ws_none) check_whitespace(state, line, len, patch->ws_rule); break; case '-': diff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh index 573200da67..e12b8333c3 100755 --- a/t/t4124-apply-ws-rule.sh +++ b/t/t4124-apply-ws-rule.sh @@ -569,7 +569,8 @@ test_expect_success 'whitespace=fix honors no-ignore-whitespace' ' +A BZZ EOF - git apply --no-ignore-whitespace --whitespace=fix patch + git apply --no-ignore-whitespace --whitespace=fix patch 2>error && + test_must_be_empty error ' test_expect_success 'whitespace check skipped for excluded paths' ' From patchwork Sun Aug 25 10:19:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Rub=C3=A9n_Justo?= X-Patchwork-Id: 13776733 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E74B179A3 for ; Sun, 25 Aug 2024 10:19:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724581172; cv=none; b=OKQphKS/aO8yzjGsGZSABVlaa39UqINnGTlJFmtVpFfvsqkJ841POIQGXo89BykQNr4hLLKTn2+QHGUQDai78esmBgwhmSOwam4Kf9t18kNLr2/GWXxL86uqLwbP7kAEaqNh7ge2Oj3l98b6NPCq0TzZ55qm8iqUeZcReN5fB58= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724581172; c=relaxed/simple; bh=TzPNQJM2LaybfqVOmrOLImI8ygStqD90jdr+Sm4uN9A=; h=Message-ID:Date:MIME-Version:Subject:From:To:References: In-Reply-To:Content-Type; b=ebLCEigca0DYSRPgD/R+WV14yj+B+TMVY2U+pxN66hZJAPuLoa3ZXpsiZsNql/qlbYUHEqfMBGU/rE7iZ3xVGPjGb/jIvFV75w890WDRw24ChRFiiyO32R/c48fFXWttay/Ve7ISbJNv+ZTHQMPbmcO0I4UzWLg1sOGKa3cyGIw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ONvBcM+g; arc=none smtp.client-ip=209.85.221.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ONvBcM+g" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-37193ef72a4so2006581f8f.1 for ; Sun, 25 Aug 2024 03:19:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724581169; x=1725185969; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :to:from:subject:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=YJ5AQI1Hd3n620+6eNQxRRCpC7Z8X9Ij8X1By4E6JCg=; b=ONvBcM+gqfg06QColBQGEJ5uUi7b2B+9kMaF8kC/ckE+3MiIi27lpf70PpyM/jKt0T 1u0uJytFUC6svLXZFX8RLcrIFQJstdro+P63+64o2NnbXKPS0WoVMPXtHdGVI5Bgba20 260GLYBr7vgPwJk9pWmAQwSOS1h+1onrSsNvfud2BfI8KEl5cVZMvY5wuv+NXb7KEQEq D9lO80nHyheWPbZqRTRzXr5SpR/UQeJDru/0fOVCWB/4mOGkUlOP83otd74/P7t8ONP5 VJfwVfnRO+hkTzwO+Zb/guqmcdHFVtEOnUgJaRUF3DFwYSmpwpK0riWtYgD9C9qFf11M /kUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724581169; x=1725185969; h=content-transfer-encoding:in-reply-to:content-language:references :to:from:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YJ5AQI1Hd3n620+6eNQxRRCpC7Z8X9Ij8X1By4E6JCg=; b=Z43VCt7ZHzL8XmZdG4OGG6/hOx+OHXNtdUt0VbP1VFwOF9DXZeX5b56PKWsX9BIPje /wj+qE5+SZf+JMUDSIVb/L7IWe6jJMlfBlaeIe7+0gm+sVDfTQRmWtBj7ODyRVKtH9eZ mcTQFZuvc2C3+LakTyPXlRq9YC1x2uZDueHnVykf07zUKORU+Bqc9txFc8QujUFPaHV8 zuffCpm3FEkWCT3uIy1q5xDXoI+MDi/aYCslKA/bFrOYPr/ATZg5B1a4dd+q96IG0DEk /5T65FCCmLyX0jPF2x1QnKHz834e0lR0wh3DuhknKi3gQHIDMGYvHpSdv6k1THn/Jg8E NRpg== X-Gm-Message-State: AOJu0YwJr/CmJFCEiXIy6briX7LIvEzFynEZSlIKnX7nxQnOSxBygUnQ Pm6eXcHFrMz3WY2yULmqVIzPct+YSDfgoGvp9hkT430n9D98wMVUKZ19qw== X-Google-Smtp-Source: AGHT+IEaWoFm65ecfLdm9yZe6fHexLLmfZzD0Da8R+Dwdymw8YL/IBEB+bKu237OXbLjdhbf/OvEDA== X-Received: by 2002:a05:6000:1e52:b0:371:8292:4ede with SMTP id ffacd0b85a97d-37311926553mr4503493f8f.63.1724581168744; Sun, 25 Aug 2024 03:19:28 -0700 (PDT) Received: from gmail.com (107.red-88-14-46.dynamicip.rima-tde.net. [88.14.46.107]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37308114a2dsm8342052f8f.3.2024.08.25.03.19.28 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 25 Aug 2024 03:19:28 -0700 (PDT) Message-ID: Date: Sun, 25 Aug 2024 12:19:27 +0200 Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 4/5] apply: error message in `record_ws_error()` From: =?utf-8?q?Rub=C3=A9n_Justo?= To: Git List References: <6dd964c2-9dee-4257-8f1a-5bc31a73722e@gmail.com> Content-Language: en-US In-Reply-To: <6dd964c2-9dee-4257-8f1a-5bc31a73722e@gmail.com> It does not make sense to construct an error message if we're not going to use it, especially when the process involves memory allocations that need to be freed immediately. If we know in advance that we won't use the message, not getting it slightly reduces the workload and simplifies the code a bit. Do it. Signed-off-by: Rubén Justo --- apply.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/apply.c b/apply.c index e1b4d14dba..e6df8b6ab4 100644 --- a/apply.c +++ b/apply.c @@ -1642,8 +1642,6 @@ static void record_ws_error(struct apply_state *state, int len, int linenr) { - char *err; - if (!result) return; @@ -1652,11 +1650,12 @@ static void record_ws_error(struct apply_state *state, state->squelch_whitespace_errors < state->whitespace_error) return; - err = whitespace_error_string(result); - if (state->apply_verbosity > verbosity_silent) + if (state->apply_verbosity > verbosity_silent) { + char *err = whitespace_error_string(result); fprintf(stderr, "%s:%d: %s.\n%.*s\n", state->patch_input_file, linenr, err, len, line); - free(err); + free(err); + } } static void check_whitespace(struct apply_state *state, From patchwork Sun Aug 25 10:19:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Rub=C3=A9n_Justo?= X-Patchwork-Id: 13776734 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBC27179A3 for ; Sun, 25 Aug 2024 10:19:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724581192; cv=none; b=sVduakTmpZ7JrRdVwSEuCBzROIaU0q9LFUYpYptdrP5t95vI1hbjm1eA/Pi/iDSkfS9gkgZmYzBwrbLjb8lSm04cf3mQsSI02zwUTCNUUG19Wstjx+KCAWzHlikuVFifrtWaEHqIgzCJlvaL0x+RGIJRHMkN0r9L/PaI2exusFY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724581192; c=relaxed/simple; bh=+8mUh4ikACYE6Y+hFVmPIXhLYF/NUhbNP8roILicNVw=; h=Message-ID:Date:MIME-Version:Subject:From:To:References: In-Reply-To:Content-Type; b=C+hDp4uSYYbjurdCPGrinypgIMbG2g/2mdeZuSEyxltHs/inU3JRidnovNTPEAf76gq1Bf8E+LOOt487sudu/n+TY1AHFzArTAeMnaiTvKcfCUBtJsLi9iNqraA2Y00N6PIRHfXXPnlTYQ+up8Wz1jJoZWVuwgMOff9Yl3G2x2I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=CAEcqacJ; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CAEcqacJ" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-429da8b5feaso37437895e9.2 for ; Sun, 25 Aug 2024 03:19:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724581189; x=1725185989; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :to:from:subject:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=mScbObV+wgVrVsORXzt/+3i+eY0eZ+MCI9jiH/7mAuQ=; b=CAEcqacJJek+YhqHe0rSZEBUo1uUi+GUEAodBH9sZvin6pYSQNe8gexPMxOWzdHohb 4NUld8xnhUOF9tnWhGsaKf6UxxUmTStn562du55dDFTyeBRmZ3CYwu+sbOyibjDn73Qo NOwE3sGe0O8tL4EgA2j8AvGOLGGGQZDNPJUrTY3sVoNoBHjkfQafa/RafN7ycNfkMy9T iaSNcVReNj9vlMEHlsZcUaA0zUjW6aqefT7tIZ2LOF4D/CGbONd3FIyjWz8XyQHRTDiC mCQ4xnMTKdiT2QI+QOS74GyHJsffE81oO1j3qmLWaynxv8+TRUgzsmIcWYXFZr7Fqfrs wVnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724581189; x=1725185989; h=content-transfer-encoding:in-reply-to:content-language:references :to:from:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mScbObV+wgVrVsORXzt/+3i+eY0eZ+MCI9jiH/7mAuQ=; b=WjBfQCpwNYZNI6ruqrOrwQCJmDU9yWhkD3au8tslAWdzTgnMVTXA0P09UpuSWd/oBj 78Bqi96Kn+xKMzRM7p/nn1aCKPBEvbm9Jyhgwsx+q3E25cFHvMxHX3HA6inYuWt1g5j0 wRVU9qv8o+8xH7iWVbMoFuJ0UC+Ec8DRSGBHYqCjKChwBdk1kLhpWMCYPp/gkgMo13Ob K41vjwhJE5sqfh1rWZvQm0z0ebnJiQUwUhTTx+2z0ytvDzrzZxpiAdZ6+VmsCHcLGYh3 ngJfPQ2UdFN1KF8skiE8iUBC/MyE8wxRhnPDA+6Sl76AiXkUfDC5KtaMfmTmiE8jPjqi Q1/Q== X-Gm-Message-State: AOJu0Yyouf1lH5psiouHP5TJrjYVXWDigjQ22tgVZ9Qglt2jAPlJup8E 5siIyVcVUPeor30XgJadTkkLrRaQZCrG6gnOoo3zcV+H1+xiSI6Yldq0ww== X-Google-Smtp-Source: AGHT+IGRna8Xv1atjnVhYBs1L8rw6xadOj7fVoIKgN4uK9FVtISpNaMoY4P0ve0RMan+Uman8+qhKw== X-Received: by 2002:a05:600c:4f83:b0:426:6ee7:d594 with SMTP id 5b1f17b1804b1-42acd543423mr50999815e9.7.1724581188842; Sun, 25 Aug 2024 03:19:48 -0700 (PDT) Received: from gmail.com (107.red-88-14-46.dynamicip.rima-tde.net. [88.14.46.107]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ac5162505sm118581825e9.28.2024.08.25.03.19.48 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 25 Aug 2024 03:19:48 -0700 (PDT) Message-ID: <4c0c05a2-c143-43b4-bc1b-d70b3645c702@gmail.com> Date: Sun, 25 Aug 2024 12:19:48 +0200 Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 5/5] t4124: move test preparation into the test context From: =?utf-8?q?Rub=C3=A9n_Justo?= To: Git List References: <6dd964c2-9dee-4257-8f1a-5bc31a73722e@gmail.com> Content-Language: en-US In-Reply-To: <6dd964c2-9dee-4257-8f1a-5bc31a73722e@gmail.com> Signed-off-by: Rubén Justo --- t/t4124-apply-ws-rule.sh | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh index e12b8333c3..56f15dc3ef 100755 --- a/t/t4124-apply-ws-rule.sh +++ b/t/t4124-apply-ws-rule.sh @@ -423,14 +423,8 @@ test_expect_success 'missing blanks at EOF must only match blank lines' ' test_must_fail git apply --ignore-space-change --whitespace=fix patch ' -sed -e's/Z//' >one <one && git add one && echo d >>one && git diff -- one >patch && @@ -443,14 +437,8 @@ test_expect_success 'missing blank line should match context line with spaces' ' test_cmp expect one ' -sed -e's/Z//' >one <one && git add one && echo d >>one && cp one expect &&