From patchwork Thu Feb 6 01:43:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Illia Bobyr X-Patchwork-Id: 13962136 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.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 5CF2C45C18 for ; Thu, 6 Feb 2025 01:43:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738806225; cv=none; b=MO5WYb5vV2tmw7RkhTWlejxlf0UOFPj3REUqEqXVrivbP4dNLd8x5EmoGva7OwODxYni5Z0rYaN7aBq7C53K/mWNByxtCRBOUI4YGUEGBdb6exsxh+W7n6+AkA68S4VDOuOwGjPumND18rsZTqR2cLgDlwrxS3CJdEjhsJoCyJ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738806225; c=relaxed/simple; bh=yEDH1VRAUATaVmjRawCJsiHulPIUDZromUFBGl7a+pQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F8PaNRKie02pRkN15AjmfnyggZoCI2VeHswRpTq7/o4c8fnlnTYqmfvZpjuWRUdwlCAsJWkHEmtYC4cYDdHGl7scejx6L9++/yw2SQUEa5d9nLrTQagMbDcinDT9VINDC5ODwq36ioHpSdRKaYJXSXnsPidKKOC8Pg2Gy3OwDfY= 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=HhRuxD/J; arc=none smtp.client-ip=209.85.216.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="HhRuxD/J" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-2f9f6a2fa8dso480169a91.1 for ; Wed, 05 Feb 2025 17:43:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738806223; x=1739411023; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t6k3o7yrdePuCkVWI0eLbWs9wf7+EOAXvk04N/TMl3Y=; b=HhRuxD/J9qIAERHH9W07UMNyo2Uiewg6l2sWav8ID6mDPobWjczpPU7L/tNoKsyY4c 5j4Ls0SPg2V9Bd+9bHyoDXcHgGLyKpe5aO8/DZGSyn/4YzTbg8Nb4tf1HbGABGMU51lj L9x6PLbo94RJYkyst15N+X5tdZsndGFq8VOW3R41g9Cr+XlEKmwCCAPGzeq/gw3cURwb 704PrFk+esdxpxVNhdjZcC4f1FPERVMK3vexJdpdsqe5bwFpqDhEzDqhmpTlsYktK4NI uJDQsG/J82rt3/G4VUF9pSZMzYgcl4hHDdHHcQEmxHGGZr927pNO4yhjMaDhJqpoTe0M wTcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738806223; x=1739411023; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t6k3o7yrdePuCkVWI0eLbWs9wf7+EOAXvk04N/TMl3Y=; b=X0bI544vaPNbNXwmO1y4hTjC7jRPsb0r5eZ5pE82CjYt7qRQ3nJCIeXMF2WyZFoq6x zbtCr6UTBPvfqSyQazvGRkFaK95HBxF+iGMkS6aeoRI7h3hjJB7guzmuaaXgRux81HVl EF6fvRw74Quk5UDPlHf1SwzhK3Wl+2sxboVGQghhDxIybCx6jNVEGaixMfBXClKKvEX3 b7Qafp13Pa1T25bD5BhtGcfjm84QeecBqtzAk9M073QF0OQhv7JSaMd8qcwYInoI6mRs zHHr/C+0qEhvUAZ2ci1Dn00CV0eaSez4Zrh6bT2WKxLc8PFdzxPaByf5kHJQT2hFD0wv 3Xig== X-Forwarded-Encrypted: i=1; AJvYcCUB4gkMg7e7ajvGPu5lKes0NCkWYzLb5AsxlTpxxPHi4k8kmandO4a8b4Htvx+yBkQvoc4=@vger.kernel.org X-Gm-Message-State: AOJu0YyvUPKu+oRDKqY6uloApBuMECww2frhXkMoKMgyH1EbZhASziiB p68oTb68S26HSXh7fuNiSysZeZrICz1KqglnwVzg7+zGg3qMX5q6 X-Gm-Gg: ASbGncvWQjvLVxwPUfR0lLUwxQ+qQFr4jee92GlXdVisgj0iU+emT9U0b4j05uxCSIn AQGAt+k3DDnsqcXaWmQ7uo55ITldlF36DKl4Fhklh3fUMp8QqAClydDAxWWObV7TOa0dGHq1Uwl Aw6bH7ceUM8Oqce1aU38jnR/NtV6A4xjOWzw1EDN/qo+xMCg4TOhMLLfc3SuKgXXDj9LD8+E3Yo YRFVhOJh4MYwUZPzV4rXSMF2TdOW+YxNrivlGuVVd9olz4j+YkwZiiefySha/7hKOLxVZS6bRzj 4UN53dODG3bIIbDWWQapZL8A8tPPAtSJzOo30VA= X-Google-Smtp-Source: AGHT+IFf9GYpeIfJLJFVnbOaMhvqz5WBeEND+AnQ1ZI0KE/eZtPFtY6hQN/Z7uNH9r4FpCEda6iMjQ== X-Received: by 2002:a05:6a00:884:b0:726:41e:b310 with SMTP id d2e1a72fcca58-7303511d84emr7781415b3a.12.1738806222462; Wed, 05 Feb 2025 17:43:42 -0800 (PST) Received: from gamma.hsd1.ca.comcast.net ([2601:647:5580:5760:c1bf:72b5:6aa3:f684]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73048ae7e54sm130111b3a.76.2025.02.05.17.43.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Feb 2025 17:43:42 -0800 (PST) From: Illia Bobyr To: Junio C Hamano , Jeff King , Johannes Sixt Cc: Illia Bobyr , git@vger.kernel.org Subject: [PATCH v3 1/1] diff: --patch-{modifies,grep} arg names for -S and -G Date: Wed, 5 Feb 2025 17:43:16 -0800 Message-ID: <20250206014324.1839232-2-illia.bobyr@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250206014324.1839232-1-illia.bobyr@gmail.com> References: <20250206014324.1839232-1-illia.bobyr@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Most arguments have both short and long versions. Long versions are easier to read, especially in scripts and command history. Tests that check just the option parsing are duplicated to check both short and long argument options. But more complex tests are updated to use the long argument in order to improve the test readability. Assuming that the usage tests have already verified that both arguments invoke the same underlying functionality. Signed-off-by: Illia Bobyr --- Documentation/diff-options.txt | 36 +++++------ Documentation/git-blame.txt | 2 +- Documentation/gitdiffcore.txt | 48 ++++++++------- diff.c | 18 +++--- diff.h | 11 +++- t/t4062-diff-pickaxe.sh | 8 +-- t/t4209-log-pickaxe.sh | 106 +++++++++++++++++++++++---------- 7 files changed, 142 insertions(+), 87 deletions(-) diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index 640eb..c9f7c 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -650,6 +650,7 @@ Note that not all diffs can feature all types. For instance, copied and renamed entries cannot appear if detection for those types is disabled. `-S`:: +`--patch-modifies=`:: Look for differences that change the number of occurrences of the specified __ (i.e. addition/deletion) in a file. Intended for the scripter's use. @@ -657,18 +658,19 @@ renamed entries cannot appear if detection for those types is disabled. It is useful when you're looking for an exact block of code (like a struct), and want to know the history of that block since it first came into being: use the feature iteratively to feed the interesting -block in the preimage back into `-S`, and keep going until you get the -very first version of the block. +block in the preimage back into `--patch-modifies`, and keep going until +you get the very first version of the block. + Binary files are searched as well. `-G`:: +`--patch-grep=`:: Look for differences whose patch text contains added/removed lines that match __. + -To illustrate the difference between `-S` `--pickaxe-regex` and -`-G`, consider a commit with the following diff in the same -file: +To illustrate the difference between `--patch-modifies= +--pickaxe-regex` and `--patch-grep=`, consider a commit with the +following diff in the same file: + ---- + return frotz(nitfol, two->ptr, 1, 0); @@ -676,9 +678,9 @@ file: - hit = frotz(nitfol, mf2.ptr, 1, 0); ---- + -While `git log -G"frotz\(nitfol"` will show this commit, `git log --S"frotz\(nitfol" --pickaxe-regex` will not (because the number of -occurrences of that string did not change). +While `git log --patch-grep="frotz\(nitfol"` will show this commit, `git +log --patch-modifies="frotz\(nitfol" --pickaxe-regex` will not (because the +number of occurrences of that string did not change). + Unless `--text` is supplied patches of binary files without a textconv filter will be ignored. @@ -687,22 +689,22 @@ See the 'pickaxe' entry in linkgit:gitdiffcore[7] for more information. `--find-object=`:: - Look for differences that change the number of occurrences of - the specified object. Similar to `-S`, just the argument is different - in that it doesn't search for a specific string but for a specific - object id. + Look for differences that change the number of occurrences of the + specified object. Similar to `--patch-modifies`, just the argument + is different in that it doesn't search for a specific string but + for a specific object id. + The object can be a blob or a submodule commit. It implies the `-t` option in `git-log` to also find trees. `--pickaxe-all`:: - When `-S` or `-G` finds a change, show all the changes in that - changeset, not just the files that contain the change - in __. + When `--patch-modifies` or `--patch-grep` finds a change, show all + the changes in that changeset, not just the files that contain the + change in __. `--pickaxe-regex`:: - Treat the __ given to `-S` as an extended POSIX regular - expression to match. + Treat the __ given to `--patch-modifies` as an extended + POSIX regular expression to match. endif::git-format-patch[] diff --git a/Documentation/git-blame.txt b/Documentation/git-blame.txt index b1d7fb..0f21d3 100644 --- a/Documentation/git-blame.txt +++ b/Documentation/git-blame.txt @@ -41,7 +41,7 @@ a text string in the diff. A small example of the pickaxe interface that searches for `blame_usage`: ----------------------------------------------------------------------------- -$ git log --pretty=oneline -S'blame_usage' +$ git log --pretty=oneline --patch-modifies='blame_usage' 5040f17eba15504bad66b14a645bddd9b015ebb7 blame -S ea4c7f9bf69e781dd0cd88d2bccb2bf5cc15c9a7 git-blame: Make the output ----------------------------------------------------------------------------- diff --git a/Documentation/gitdiffcore.txt b/Documentation/gitdiffcore.txt index 642c5..e4b18 100644 --- a/Documentation/gitdiffcore.txt +++ b/Documentation/gitdiffcore.txt @@ -245,33 +245,35 @@ diffcore-pickaxe: For Detecting Addition/Deletion of Specified String This transformation limits the set of filepairs to those that change specified strings between the preimage and the postimage in a certain -way. -S and -G options are used to -specify different ways these strings are sought. - -"-S" detects filepairs whose preimage and postimage -have different number of occurrences of the specified block of text. -By definition, it will not detect in-file moves. Also, when a -changeset moves a file wholesale without affecting the interesting -string, diffcore-rename kicks in as usual, and `-S` omits the filepair -(since the number of occurrences of that string didn't change in that +way. --patch-modifies= and +--patch-grep= options are used to specify +different ways these strings are sought. + +"-S", or "--patch-modifies=" detects +filepairs whose preimage and postimage have different number of +occurrences of the specified block of text. By definition, it will +not detect in-file moves. Also, when a changeset moves a file +wholesale without affecting the interesting string, diffcore-rename +kicks in as usual, and `--patch-modifies` omits the filepair (since +the number of occurrences of that string didn't change in that rename-detected filepair). When used with `--pickaxe-regex`, treat the as an extended POSIX regular expression to match, instead of a literal string. -"-G" (mnemonic: grep) detects filepairs whose -textual diff has an added or a deleted line that matches the given -regular expression. This means that it will detect in-file (or what -rename-detection considers the same file) moves, which is noise. The -implementation runs diff twice and greps, and this can be quite -expensive. To speed things up, binary files without textconv filters -will be ignored. - -When `-S` or `-G` are used without `--pickaxe-all`, only filepairs -that match their respective criterion are kept in the output. When -`--pickaxe-all` is used, if even one filepair matches their respective -criterion in a changeset, the entire changeset is kept. This behavior -is designed to make reviewing changes in the context of the whole -changeset easier. +"-G", or "--patch-grep=" +(mnemonic: grep) detects filepairs whose textual diff has an added or +a deleted line that matches the given regular expression. This means +that it will detect in-file (or what rename-detection considers the +same file) moves, which is noise. The implementation runs diff twice +and greps, and this can be quite expensive. To speed things up, +binary files without textconv filters will be ignored. + +When `--patch-modifies` or `--patch-grep` are used without +`--pickaxe-all`, only filepairs that match their respective criterion +are kept in the output. When `--pickaxe-all` is used, if even one +filepair matches their respective criterion in a changeset, the entire +changeset is kept. This behavior is designed to make reviewing +changes in the context of the whole changeset easier. diffcore-order: For Sorting the Output Based on Filenames --------------------------------------------------------- diff --git a/diff.c b/diff.c index d28b41..09beb 100644 --- a/diff.c +++ b/diff.c @@ -4877,15 +4877,17 @@ void diff_setup_done(struct diff_options *options) if (HAS_MULTI_BITS(options->pickaxe_opts & DIFF_PICKAXE_KINDS_MASK)) die(_("options '%s', '%s', and '%s' cannot be used together"), - "-G", "-S", "--find-object"); + "-G/--patch-grep", "-S/--patch-modifies", "--find-object"); if (HAS_MULTI_BITS(options->pickaxe_opts & DIFF_PICKAXE_KINDS_G_REGEX_MASK)) die(_("options '%s' and '%s' cannot be used together, use '%s' with '%s'"), - "-G", "--pickaxe-regex", "--pickaxe-regex", "-S"); + "-G/--patch-grep", "--pickaxe-regex", + "--pickaxe-regex", "-S/--patch-modifies"); if (HAS_MULTI_BITS(options->pickaxe_opts & DIFF_PICKAXE_KINDS_ALL_OBJFIND_MASK)) die(_("options '%s' and '%s' cannot be used together, use '%s' with '%s' and '%s'"), - "--pickaxe-all", "--find-object", "--pickaxe-all", "-G", "-S"); + "--pickaxe-all", "--find-object", + "--pickaxe-all", "-G/--patch-grep", "-S/--patch-modifies"); /* * Most of the time we can say "there are changes" @@ -5862,17 +5864,17 @@ struct option *add_diff_options(const struct option *opts, OPT_SET_INT_F(0, "ita-visible-in-index", &options->ita_invisible_in_index, N_("treat 'git add -N' entries as real in the index"), 0, PARSE_OPT_NONEG), - OPT_CALLBACK_F('S', NULL, options, N_(""), + OPT_CALLBACK_F('S', "patch-modifies", options, N_(""), N_("look for differences that change the number of occurrences of the specified string"), 0, diff_opt_pickaxe_string), - OPT_CALLBACK_F('G', NULL, options, N_(""), - N_("look for differences that change the number of occurrences of the specified regex"), + OPT_CALLBACK_F('G', "patch-grep", options, N_(""), + N_("look for differences where a patch contains the specified regex"), 0, diff_opt_pickaxe_regex), OPT_BIT_F(0, "pickaxe-all", &options->pickaxe_opts, - N_("show all changes in the changeset with -S or -G"), + N_("show all changes in the changeset with -S/--patch-modifies or -G/--patch-grep"), DIFF_PICKAXE_ALL, PARSE_OPT_NONEG), OPT_BIT_F(0, "pickaxe-regex", &options->pickaxe_opts, - N_("treat in -S as extended POSIX regular expression"), + N_("treat in -S/--patch-modifies as extended POSIX regular expression"), DIFF_PICKAXE_REGEX, PARSE_OPT_NONEG), OPT_FILENAME('O', NULL, &options->orderfile, N_("control the order in which files appear in the output")), diff --git a/diff.h b/diff.h index 6e6007..247ac 100644 --- a/diff.h +++ b/diff.h @@ -598,9 +598,16 @@ void diffcore_fix_diff_index(void); " try unchanged files as candidate for copy detection.\n" \ " -l limit rename attempts up to paths.\n" \ " -O reorder diffs according to the .\n" \ -" -S find filepair whose only one side contains the string.\n" \ +" -G\n" \ +" --patch-grep=\n" \ +" find differences whose patch contains the regex.\n" \ +" -S\n" \ +" --patch-modifies=\n" \ +" find filepair who differ in the number of occurrences of string.\n" \ +" --pickaxe-grep\n" \ +" treat as regex in the -S/--patch-modifies argument.\n" \ " --pickaxe-all\n" \ -" show all files diff when -S is used and hit is found.\n" \ +" show all files diff for -G/--patch-grep and -S/--patch-modifies.\n" \ " -a --text treat all files as text.\n" int diff_queue_is_empty(struct diff_options *o); diff --git a/t/t4062-diff-pickaxe.sh b/t/t4062-diff-pickaxe.sh index 8ad3d7..805e0f 100755 --- a/t/t4062-diff-pickaxe.sh +++ b/t/t4062-diff-pickaxe.sh @@ -16,13 +16,13 @@ test_expect_success setup ' ' # OpenBSD only supports up to 255 repetitions, so repeat twice for 64*64=4096. -test_expect_success '-G matches' ' - git diff --name-only -G "^(0{64}){64}$" HEAD^ >out && +test_expect_success '--patch-grep matches' ' + git diff --name-only --patch-grep "^(0{64}){64}$" HEAD^ >out && test 4096-zeroes.txt = "$(cat out)" ' -test_expect_success '-S --pickaxe-regex' ' - git diff --name-only -S0 --pickaxe-regex HEAD^ >out && +test_expect_success '--patch-modifies --pickaxe-regex' ' + git diff --name-only --patch-modifies 0 --pickaxe-regex HEAD^ >out && test 4096-zeroes.txt = "$(cat out)" ' diff --git a/t/t4209-log-pickaxe.sh b/t/t4209-log-pickaxe.sh index a675ac..5f4d6 100755 --- a/t/t4209-log-pickaxe.sh +++ b/t/t4209-log-pickaxe.sh @@ -1,6 +1,6 @@ #!/bin/sh -test_description='log --grep/--author/--regexp-ignore-case/-S/-G' +test_description='log --grep/--author/--regexp-ignore-case/--patch-{modifies,grep}' . ./test-lib.sh @@ -60,24 +60,48 @@ test_expect_success 'usage' ' test_expect_code 129 git log -S 2>err && test_grep "switch.*requires a value" err && + test_expect_code 129 git log --patch-modifies 2>err && + test_grep "option.*requires a value" err && + test_expect_code 129 git log -G 2>err && test_grep "switch.*requires a value" err && + test_expect_code 129 git log --patch-grep 2>err && + test_grep "option.*requires a value" err && + test_expect_code 128 git log -Gregex -Sstring 2>err && grep "cannot be used together" err && + test_expect_code 128 git log -Gregex --patch-modifies string 2>err && + grep "cannot be used together" err && + + test_expect_code 128 git log --patch-grep regex -Sstring 2>err && + grep "cannot be used together" err && + + test_expect_code 128 git log --patch-grep regex --patch-modifies string 2>err && + grep "cannot be used together" err && + test_expect_code 128 git log -Gregex --find-object=HEAD 2>err && grep "cannot be used together" err && + test_expect_code 128 git log --patch-grep regex --find-object=HEAD 2>err && + grep "cannot be used together" err && + test_expect_code 128 git log -Sstring --find-object=HEAD 2>err && grep "cannot be used together" err && + test_expect_code 128 git log --patch-modifies string --find-object=HEAD 2>err && + grep "cannot be used together" err && + test_expect_code 128 git log --pickaxe-all --find-object=HEAD 2>err && grep "cannot be used together" err ' test_expect_success 'usage: --pickaxe-regex' ' test_expect_code 128 git log -Gregex --pickaxe-regex 2>err && + grep "cannot be used together" err && + + test_expect_code 128 git log --patch-grep regex --pickaxe-regex 2>err && grep "cannot be used together" err ' @@ -89,7 +113,13 @@ test_expect_success 'usage: --no-pickaxe-regex' ' test_expect_code 128 git log -Sstring --no-pickaxe-regex 2>actual && test_cmp expect actual && - test_expect_code 128 git log -Gstring --no-pickaxe-regex 2>err && + test_expect_code 128 git log --patch-modifies string --no-pickaxe-regex 2>actual && + test_cmp expect actual && + + test_expect_code 128 git log -Gregex --no-pickaxe-regex 2>err && + test_cmp expect actual && + + test_expect_code 128 git log --patch-grep regex --no-pickaxe-regex 2>err && test_cmp expect actual ' @@ -104,47 +134,59 @@ test_log_icase expect_second --author person test_log_icase expect_nomatch --author spreon test_log expect_nomatch -G picked +test_log expect_nomatch --patch-grep picked test_log expect_second -G Picked +test_log expect_second --patch-grep Picked test_log_icase expect_nomatch -G pickle +test_log_icase expect_nomatch --patch-grep pickle test_log_icase expect_second -G picked +test_log_icase expect_second --patch-grep picked -test_expect_success 'log -G --textconv (missing textconv tool)' ' +test_expect_success 'log --patch-grep --textconv (missing textconv tool)' ' echo "* diff=test" >.gitattributes && - test_must_fail git -c diff.test.textconv=missing log -Gfoo && + test_must_fail git -c diff.test.textconv=missing log --patch-grep foo && rm .gitattributes ' -test_expect_success 'log -G --no-textconv (missing textconv tool)' ' +test_expect_success 'log --patch-grep --no-textconv (missing textconv tool)' ' echo "* diff=test" >.gitattributes && - git -c diff.test.textconv=missing log -Gfoo --no-textconv >actual && + git -c diff.test.textconv=missing log --patch-grep foo --no-textconv >actual && test_cmp expect_nomatch actual && rm .gitattributes ' test_log expect_nomatch -S picked +test_log expect_nomatch --patch-modifies picked test_log expect_second -S Picked +test_log expect_second --patch-modifies Picked test_log_icase expect_second -S picked +test_log_icase expect_second --patch-modifies picked test_log_icase expect_nomatch -S pickle +test_log_icase expect_nomatch --patch-modifies pickle test_log expect_nomatch -S p.cked --pickaxe-regex +test_log expect_nomatch --patch-modifies p.cked --pickaxe-regex test_log expect_second -S P.cked --pickaxe-regex +test_log expect_second --patch-modifies P.cked --pickaxe-regex test_log_icase expect_second -S p.cked --pickaxe-regex +test_log_icase expect_second --patch-modifies p.cked --pickaxe-regex test_log_icase expect_nomatch -S p.ckle --pickaxe-regex +test_log_icase expect_nomatch --patch-modifies p.ckle --pickaxe-regex -test_expect_success 'log -S --textconv (missing textconv tool)' ' +test_expect_success 'log --patch-modifies --textconv (missing textconv tool)' ' echo "* diff=test" >.gitattributes && - test_must_fail git -c diff.test.textconv=missing log -Sfoo && + test_must_fail git -c diff.test.textconv=missing log --patch-modifies foo && rm .gitattributes ' -test_expect_success 'log -S --no-textconv (missing textconv tool)' ' +test_expect_success 'log --patch-modifies --no-textconv (missing textconv tool)' ' echo "* diff=test" >.gitattributes && - git -c diff.test.textconv=missing log -Sfoo --no-textconv >actual && + git -c diff.test.textconv=missing log --patch-modifies foo --no-textconv >actual && test_cmp expect_nomatch actual && rm .gitattributes ' -test_expect_success 'setup log -[GS] plain & regex' ' +test_expect_success 'setup log --patch{-modifies,-grep} plain & regex' ' test_create_repo GS-plain && test_commit -C GS-plain --append A data.txt "a" && test_commit -C GS-plain --append B data.txt "a a" && @@ -159,31 +201,31 @@ test_expect_success 'setup log -[GS] plain & regex' ' git -C GS-plain log >full-log ' -test_expect_success 'log -G trims diff new/old [-+]' ' - git -C GS-plain log -G"[+-]a" >log && +test_expect_success 'log --patch-grep trims diff new/old [-+]' ' + git -C GS-plain log --patch-grep "[+-]a" >log && test_must_be_empty log && - git -C GS-plain log -G"^a" >log && + git -C GS-plain log --patch-grep "^a" >log && test_cmp log A-to-B-then-E-log ' -test_expect_success 'log -S is not a regex, but -S --pickaxe-regex is' ' - git -C GS-plain log -S"a" >log && +test_expect_success 'log --patch-modifies is not a regex, but --patch-modifies --pickaxe-regex is' ' + git -C GS-plain log --patch-modifies "a" >log && test_cmp log A-to-B-then-E-log && - git -C GS-plain log -S"[a]" >log && + git -C GS-plain log --patch-modifies "[a]" >log && test_must_be_empty log && - git -C GS-plain log -S"[a]" --pickaxe-regex >log && + git -C GS-plain log --patch-modifies "[a]" --pickaxe-regex >log && test_cmp log A-to-B-then-E-log && - git -C GS-plain log -S"[b]" >log && + git -C GS-plain log --patch-modifies "[b]" >log && test_cmp log D-then-E-log && - git -C GS-plain log -S"[b]" --pickaxe-regex >log && + git -C GS-plain log --patch-modifies "[b]" --pickaxe-regex >log && test_cmp log C-to-D-then-E-log ' -test_expect_success 'setup log -[GS] binary & --text' ' +test_expect_success 'setup log --patch{-modifies,-grep} binary & --text' ' test_create_repo GS-bin-txt && test_commit -C GS-bin-txt --printf A data.bin "a\na\0a\n" && test_commit -C GS-bin-txt --append --printf B data.bin "a\na\0a\n" && @@ -191,36 +233,36 @@ test_expect_success 'setup log -[GS] binary & --text' ' git -C GS-bin-txt log >full-log ' -test_expect_success 'log -G ignores binary files' ' - git -C GS-bin-txt log -Ga >log && +test_expect_success 'log --patch-grep ignores binary files' ' + git -C GS-bin-txt log --patch-grep a >log && test_must_be_empty log ' -test_expect_success 'log -G looks into binary files with -a' ' - git -C GS-bin-txt log -a -Ga >log && +test_expect_success 'log --patch-grep looks into binary files with -a' ' + git -C GS-bin-txt log -a --patch-grep a >log && test_cmp log full-log ' -test_expect_success 'log -G looks into binary files with textconv filter' ' +test_expect_success 'log --patch-grep looks into binary files with textconv filter' ' test_when_finished "rm GS-bin-txt/.gitattributes" && ( cd GS-bin-txt && echo "* diff=bin" >.gitattributes && - git -c diff.bin.textconv=cat log -Ga >../log + git -c diff.bin.textconv=cat log --patch-grep a >../log ) && test_cmp log full-log ' -test_expect_success 'log -S looks into binary files' ' - git -C GS-bin-txt log -Sa >log && +test_expect_success 'log --patch-modifies looks into binary files' ' + git -C GS-bin-txt log --patch-modifies a >log && test_cmp log full-log ' -test_expect_success 'log -S --pickaxe-regex looks into binary files' ' - git -C GS-bin-txt log --pickaxe-regex -Sa >log && +test_expect_success 'log --patch-modifies --pickaxe-regex looks into binary files' ' + git -C GS-bin-txt log --pickaxe-regex --patch-modifies a >log && test_cmp log full-log && - git -C GS-bin-txt log --pickaxe-regex -S"[a]" >log && + git -C GS-bin-txt log --pickaxe-regex --patch-modifies "[a]" >log && test_cmp log full-log ' From patchwork Tue Feb 11 08:50:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Illia Bobyr X-Patchwork-Id: 13969618 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (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 A61D41F0E5C for ; Tue, 11 Feb 2025 08:50:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739263855; cv=none; b=ZUrZSMTqvQztxOEz6xP/G0K3fGLH5UuLJtxIDWzckHOGt+u9TKWAgDrwL8R3ovebhKhPpkFvZdK8V4Osu8tiuKihQhCmT4Yx8FKjlGwFRPi7dAi3jrgRyQGOpDAaqzR7Lw7BJKTfFeNgLzINQLVvf7x0iVT6vFF5wlezXpbp1Ok= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739263855; c=relaxed/simple; bh=65jF1Kbg8pmJoPHIj9oX2H0kaQiQ1E4nXq89L/GPzWI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mbJuVWkGuSyxV4VrljBIQEXDxNpFMbLzZr0uG4QVt2n0NtY8cuUDZ1/l0uiCoXUYvcQX0b121eBM2Bl04irv3wKQCRXTxEiUdB2YGvZvyxidqIMLgHcAedby9iyDa6bx62y2eSFeubupnHaY+AGi128aNzaUnZ9osUWssiC0SOQ= 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=CGxRKKgy; arc=none smtp.client-ip=209.85.216.53 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="CGxRKKgy" Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-2ee9a780de4so8121387a91.3 for ; Tue, 11 Feb 2025 00:50:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739263853; x=1739868653; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RUVxVdfdEGtwV6OWjbDz6WqfhYfQoLL9SeacMktxfpA=; b=CGxRKKgyDBhOcarxcUuAu5ds1tR/CWVsm1U7XZbwyNSOOAwohAeGDkI0GtYBlyS70D YE9e+cmBPYZCsmHJ7jN2XL1dO2vnGX6KYrXw/IemUOXD9D59uXHJtIEhhwtovtRyrZ3D CRJsea+OZDpmI8vETIjWo7rtzxifEIaRHwRq0H+EUhcrxu0wbUcBbgKfnNOzQsWFJl2U K4vDkWWS7Cmg56CiPN1qploATAYQtVAaXJPAd+Of0ihJXIcmAd6F7iowybNGiw5a1XJ9 QZ/dgYG2NLeAZYS+VNNZfNnbiWTgkagwi708t0JitM1Vvx0O44fmIgRHhShuVWkO5r2F Y9Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739263853; x=1739868653; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RUVxVdfdEGtwV6OWjbDz6WqfhYfQoLL9SeacMktxfpA=; b=YdZjTycWUAn+wfEeD1fG6e+rXSXEEt9CuEomrNRPY6oh+MYm2wKxmhp4Hr6eQKiIQv upw/snfjMiM5w/cSYsYjpITmo7gwefW8AA77u5LOu9wK292o3bhGyoj4fTdWuNZa4hn2 TmPyNxYaF/I3QyLmMPj19ZYcBDnLOxoO3sGNUAfOLpciAW9COiflVXFYNOAauxfVd8iS 4FWpZWQafwIV0Kfnu1pMGd0edDZ+tcu6to71USJjwHxAWCOP1TLyzQ03ulFGOVdCkzAW AcWLs9MGLRp1rR4jIMM02cSoG0eHCC3RWHDEFIm9wbg/9KNEPRIu1ba0UyzLeVgnb7tV /1Bw== X-Forwarded-Encrypted: i=1; AJvYcCV+V/UfrivGmcGx9N34fW0YZ+qpar2LpZrMJypUGdIgcg0lyh2OyA9pPRVxYIi1lyQ7+Is=@vger.kernel.org X-Gm-Message-State: AOJu0YxQVfcY/6GnQ+gydmdJ8yYc2b6tfsbo1RPpYE5HXh/hcO4Ikeep kVvUQl3h5Fh+adwMLHMCzUCc0S3RpbNlvH8e82j2OQG5gzcxwc61 X-Gm-Gg: ASbGncuWrgeBsDI5zNVux9/oQ+1qk5qYvDuCw83XVjY/BMB8d1twwcrM9EAE9+dKXn1 4Y5RlzRSk4JlnrBcEzchNXFQlLZ+hceiQ8h47dO7WFjPXCcOeaH/WbQ3OjD3/Yx3x5nFlfjHnIH wzTH3vboungIx1xfhbPAqMWL5BT9eOz/7uW1rdUFX5oJULoH7+mUG4wqo502b7EZHjouL+QkZFR nbxxlismk4nQFrmmKTv2z51IwWxLU/9Unb6ZHUEuAHFKfdwJXDI1SSeVSYyU9QSQl6UGUzaH97N 7iAQObz+H6Bl+RFlDoA4BIbMcBhxqJtzIGBE49s= X-Google-Smtp-Source: AGHT+IGyCDGGUN+WVCFChNziMxg5bdr/ReMXAFmXj0cu+gMW68GwmAk39RxLSMrh6nli7AwfYOlZ5Q== X-Received: by 2002:a17:90b:1946:b0:2ee:a04b:92ce with SMTP id 98e67ed59e1d1-2fa243ee3f5mr22154665a91.32.1739263852905; Tue, 11 Feb 2025 00:50:52 -0800 (PST) Received: from gamma.hsd1.ca.comcast.net ([2601:647:5580:5760:3858:1e16:caad:e1d4]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fa09a46534sm10201701a91.21.2025.02.11.00.50.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2025 00:50:52 -0800 (PST) From: Illia Bobyr To: Junio C Hamano Cc: Illia Bobyr , git@vger.kernel.org Subject: [PATCH v4 02/10] diff: -G description: Correct copy/paste error Date: Tue, 11 Feb 2025 00:50:14 -0800 Message-ID: <20250211085028.3923875-3-illia.bobyr@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250206014324.1839232-1-illia.bobyr@gmail.com> References: <20250206014324.1839232-1-illia.bobyr@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Current description for -G is incorrect, seems like it was copied from the description for -S. --- diff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diff.c b/diff.c index 019fb..bd9db 100644 --- a/diff.c +++ b/diff.c @@ -5866,7 +5866,7 @@ struct option *add_diff_options(const struct option *opts, N_("look for differences that change the number of occurrences of the specified string"), 0, diff_opt_pickaxe_string), OPT_CALLBACK_F('G', NULL, options, N_(""), - N_("look for differences that change the number of occurrences of the specified regex"), + N_("look for differences where a patch contains the specified regex"), 0, diff_opt_pickaxe_regex), OPT_BIT_F(0, "pickaxe-all", &options->pickaxe_opts, N_("show all changes in the changeset with -S or -G"), From patchwork Tue Feb 11 08:50:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Illia Bobyr X-Patchwork-Id: 13969619 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 6B6A91F03F4 for ; Tue, 11 Feb 2025 08:50:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739263857; cv=none; b=kgggN/fachzktJzzbBuzf0tzSSpXjK1DqakYph/V6xi7t6nFxkzglufxMdJAf6l1fssDg/Jydv3Z15ieQCAQsaY7zvw6jQm7dosyoIbov1za9M+1teS1oi8puXHh0Oo3hZbQODnJGxgscdRwF5omOUwC/9tO6SJgcbTGxcM8qk0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739263857; c=relaxed/simple; bh=17N7VocmfZJeVnuHq/f0+bycl3xpueu5wz51Z3gMyA4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Gb9Ga+9VcHP036n0xemHIi/zF55zUdeMQzwYB5IWdxTKsVZvVvofxsEeAvT2i1T+87yhLdBMk+qpjoCw+DdJesim5AZeavxP5Mfa3Xm/cXIIOMb5O01wXjpqVJjzjTznZ33gtC8uVJkhRhkB8q5tyd1SCJl5Tgn4evszEr4q1To= 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=Pd4lDFev; arc=none smtp.client-ip=209.85.214.178 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="Pd4lDFev" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-21f4500a5c3so103531095ad.3 for ; Tue, 11 Feb 2025 00:50:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739263855; x=1739868655; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tTlfV8sxLAVM5HmOqiScCyvjUdi07C2Elp61HaMzN3c=; b=Pd4lDFevpln3FBu8S6A8OtikAezG0Xo8QK8zm3oEFQiBhC3NOfnSPZtU9FLLeeGXoU eX6UkD4axm1UoY7EjIiUwHNsxTY4D7/uSIw+hx0vw5W1jGmhF8dXZDIR71HydLHuBA32 zJROM8U8Ks0b3iPzEzcBsdZkYkC4oT2CyttkHtrGUvZtQX3QW9dYnw3F3IddFdh94bSq tLVQScw7gc3av5Of99ikt24VZYanztwqy8WBLkgx9cMhX6gqcmyWe9W3/tcOrpT/YuZZ T3i/ajgOOjlC364quzyoO5TqTjTTIvExIp3s7SFw+GWOycK2MOlxxbOQWCiG4WpTAOb+ DYyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739263855; x=1739868655; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tTlfV8sxLAVM5HmOqiScCyvjUdi07C2Elp61HaMzN3c=; b=EvMgX0neZcQBgncbUp4tiZbEg3OjzF/WOuMwBY9JxoevTxtFmaMKZc48KWH2s6rZxF 22kHcRrqT2vEUf/wgGkuBsE03tIhzHSwdOwV1Rlbzl/3kNm3onzwMiuvZxwSBvJH+bOu csHm+MDxTQmVWDCYsigrG0ItPH3WY/emntI0RnvX7/wy+Pt99j4F2OdD360wKOmUg3sQ f3/qhZttJxLtPEEDAWbDNBnQUfjWfuUrkUGUulu8tqXUoGo93G0RErWnpyeDbu7KHxyn 3ySdy/ax6ticM9I9RYW/0cjq8ZdMlYylktSJG1wF5MTbWLGyqzNNNLn/qlyVXeSQ1v4p 1eRQ== X-Forwarded-Encrypted: i=1; AJvYcCXTnriVh349eVbASUocD/Es2ritY38+iJV6Czxb0axhi/1DvJexWuqboaayT1+7MjOQAgs=@vger.kernel.org X-Gm-Message-State: AOJu0YwQG8JYbBMgaARdh0RvMnVAODYlkkpd7D48ysD25T8TqtSeU9u+ LfZfqljr7hpirHGaArbI5c/vlGNrxn/lqzNolHqiqfBOoUMuTo+M X-Gm-Gg: ASbGncsUwNtdEKQwFl6qRbKoRfuEK+3+9vg0zXycfIG5trAnaKSKhSaRjbeIit8iJ/P hqLCs5hmIzKR2P7jq+WiH43Ygl35Gm2S34UdQPhQ4irmIjwi0YpkRBYK1acyWFOe5+xiHSRhfRX wXIuY1/iAnRtPqupnV/GEJdwc1u3TfGx4y/ZaCGCcYbh/5vVyG7n2tp1oHBbx0vPGSJ/+h+4aIH zmKV904f7z37FD2I2x262sfAUxleioIm1fH0KdSEcn5pHKgPENY2fFsZaaQnFfSIn6Q+SDpTvZQ QQk+ClshOIaMqDy26DOmlTAry3A2LmbwTKRgm8M= X-Google-Smtp-Source: AGHT+IFzTIHgcadHdj/W18twGIXPV28ybGaypQNyFsFpClOJHWl6KNSukycIN7vW8FrrYNIl0Q53eA== X-Received: by 2002:a17:902:f685:b0:21f:2cb4:963 with SMTP id d9443c01a7336-21f4e7f2369mr255040595ad.50.1739263855628; Tue, 11 Feb 2025 00:50:55 -0800 (PST) Received: from gamma.hsd1.ca.comcast.net ([2601:647:5580:5760:3858:1e16:caad:e1d4]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fa09a46534sm10201701a91.21.2025.02.11.00.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2025 00:50:55 -0800 (PST) From: Illia Bobyr To: Junio C Hamano Cc: Illia Bobyr , git@vger.kernel.org Subject: [PATCH v4 03/10] diff: short help: Correct -S description Date: Tue, 11 Feb 2025 00:50:15 -0800 Message-ID: <20250211085028.3923875-4-illia.bobyr@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250206014324.1839232-1-illia.bobyr@gmail.com> References: <20250206014324.1839232-1-illia.bobyr@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 `-S` shows changes that modify the number of occurrences of the specified string, rather than only those that either completely remove it or add it for the first time. --- diff.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diff.h b/diff.h index 0a566f..49ece3 100644 --- a/diff.h +++ b/diff.h @@ -606,7 +606,7 @@ void diffcore_fix_diff_index(void); " try unchanged files as candidate for copy detection.\n" \ " -l limit rename attempts up to paths.\n" \ " -O reorder diffs according to the .\n" \ -" -S find filepair whose only one side contains the string.\n" \ +" -S find filepair who differ in the number of occurrences of string.\n" \ " --pickaxe-all\n" \ " show all files diff when -S is used and hit is found.\n" \ " -a --text treat all files as text.\n" From patchwork Tue Feb 11 08:50:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Illia Bobyr X-Patchwork-Id: 13969620 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 C70561F12F2 for ; Tue, 11 Feb 2025 08:50:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739263860; cv=none; b=rz8eP70j4uwyf8QHuCBIbN5zU/nFPXKY552O8f3zhE9oY6hlW5JjOahnZ3IBJDkSiMwHZ9tdUTTEeqY1kVEAlC3LLCXgQkgnzgMpSsdoM3oYd7ObW4LuCwW6JmpHApF8T6wDmtlqtjjnfsi5Njp41KYZrWZyfIFpaaHQyiA8y3g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739263860; c=relaxed/simple; bh=QO444lh6UAGvQI8NufzeyhxcB7Tn6BILaTBGCxPQnRo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aW1tFQzANGpZhp8bP2wkPWzYxgRuWOCa2F3+z1STex9GcYM19TYC10LKpfIwi2blCKpTlSPmLul0zvogYXQ4BPSAqDQRyu85avvWp61LrfWxBWLlTakI53pGN0noXXEjbF4IAUKfnmSdoeQCncEd7Gg2mfRjO64pCPu4CFIOVYw= 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=k+1v9FY9; arc=none smtp.client-ip=209.85.214.175 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="k+1v9FY9" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-21f61b01630so54160295ad.1 for ; Tue, 11 Feb 2025 00:50:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739263858; x=1739868658; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=57U1MVJyFXhBLaUB6ZU7XT27Jt1zemFZbnQqBPCbRSA=; b=k+1v9FY9O4WSnPjBLkx0bfA5rUInHt5Kj5sVeG7RGyunGlbCkK7cG5AxS8d1OhUgBO skHDJeQLvOyLazqkjvITOlAMmTyGMNrk8T9U3XbSvJdL209odkEH/P/z4vLy/5Bpragz ypo3OUyKZz+9PmBDoh9VCY15PUuDS9j7gFGqVgaA5FL9Nk7KidaB4ZQ12P9S+bZk1d5Q hJFs/KvgkqAKiMwdcC4sqENcd4dkHgHVLUfH7yDc67tP2u9GWCSykufc0dLEX7rmZ3Pr VcnM88K8TP4RAnTAUTu2d5Ldr2ReDxWs4fFsM8weUUzZnDCzOVCeIl5PYh9nTZFvALJb hBRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739263858; x=1739868658; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=57U1MVJyFXhBLaUB6ZU7XT27Jt1zemFZbnQqBPCbRSA=; b=t0v20Z7SG5a05m00tj5wZ93Vz8dLBgxRdrPm/KruFo+RdTYdofKCyr9LkGkLJ6N4Bu iKo7RRu4LSd6CgVE+hZdP/uKDAETc7MYB2KZ/Dv3vMgG1eIHvmZLZDQi0d9uQ+XLOuLJ FRsLAyfkiMYM/8Hh0DOKBXrKIhCpniDI6vlVKZL0hrzs/p0p7d2NNnausjb3J1rjZvdu ppVvLLIArT17uvPrjjYyXrM9NbLzBflZLEL4T4g2XCo9q6QGe3BoIDRS0vIK/sxMAkvb KjCjlwxj1ev/UuFGXIEiIC0TcAG5Z5clQ9j+mPUywI7p+N48rVxNBl75zA/JFcP15EL7 HjUA== X-Forwarded-Encrypted: i=1; AJvYcCWCQEkzY54chdpYIlVgVudL6P820qaVrjCpuscmRGhFIyCvuh/+PFp06jQAJ5/G9iTdUZo=@vger.kernel.org X-Gm-Message-State: AOJu0YyAjxlh00KlvMq2FD91JHQLwCmSKUzNzCitOh5TDFRPB84UUnZc dvtg7uKfjb+Sqk6Nf/0oLlIkTHQkLrUpdc6qYhebzbYpHQ0BSRIcz+FPXkO9 X-Gm-Gg: ASbGncuLMUYf0rPIu6epwMx95riXx0EnKIJ3lT+I6CFgW1wMSaqCeLEeckpVbFBvo4z A3v5gyh2SKCNkAoCLOjUK2b1bpodTyvXCN2f9kCtJLS4dLBAhp4CrrvnCf3iXFoJgrHiIcpdqeV bxeLzKH2H6ImlDSPQwbOmC+8e0DKtykHsPCmQHhRoHmpzmcgDGCddKlPsf2PmP9WLokN7fYYJnQ cl+cak9r7zQ0e9V7DLSjpIE7jBlRUotcnnYHp4sEAJ2J0/oNluq9Ri7DJcbK+tPS6hjJbuPJxDu wZ1PCq6n8cIqeobDZSPrALHi2PxDC9DerX9jqzg= X-Google-Smtp-Source: AGHT+IEaD6UlQIfaEajaKF3dbo0j8jCe9T7FJF1v2+Vf+E3L+bnK+QUi5VRlJbqcGgtzfUodcAeecA== X-Received: by 2002:a17:90b:4d08:b0:2fa:2252:f436 with SMTP id 98e67ed59e1d1-2faa07da202mr3874008a91.3.1739263857907; Tue, 11 Feb 2025 00:50:57 -0800 (PST) Received: from gamma.hsd1.ca.comcast.net ([2601:647:5580:5760:3858:1e16:caad:e1d4]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fa09a46534sm10201701a91.21.2025.02.11.00.50.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2025 00:50:57 -0800 (PST) From: Illia Bobyr To: Junio C Hamano Cc: Illia Bobyr , git@vger.kernel.org Subject: [PATCH v4 04/10] diff: short help: Add -G and --pickaxe-grep Date: Tue, 11 Feb 2025 00:50:16 -0800 Message-ID: <20250211085028.3923875-5-illia.bobyr@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250206014324.1839232-1-illia.bobyr@gmail.com> References: <20250206014324.1839232-1-illia.bobyr@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 -G and --pickaxe-grep seems to be on par with -S and --pickaxe-all that are already mentioned. --- diff.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/diff.h b/diff.h index 49ece3..787bb 100644 --- a/diff.h +++ b/diff.h @@ -606,9 +606,12 @@ void diffcore_fix_diff_index(void); " try unchanged files as candidate for copy detection.\n" \ " -l limit rename attempts up to paths.\n" \ " -O reorder diffs according to the .\n" \ +" -G find differences where patch contains the specified regex.\n" \ " -S find filepair who differ in the number of occurrences of string.\n" \ +" --pickaxe-grep\n" \ +" treat as a regex in the -S argument.\n" \ " --pickaxe-all\n" \ -" show all files diff when -S is used and hit is found.\n" \ +" show all files diff when -G or -S is used and hit is found.\n" \ " -a --text treat all files as text.\n" int diff_queue_is_empty(struct diff_options *o); From patchwork Tue Feb 11 08:50:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Illia Bobyr X-Patchwork-Id: 13969621 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 6B4551F0E2A for ; Tue, 11 Feb 2025 08:51:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739263861; cv=none; b=u2scBczD53baFJ8B1kdN5UP5tWWAfJb3h2Ou4Cm5yfclWHw22XZgg7jMz1d53jfmHXPkubOKdlbu1u4anO8eXK+l6fLeLTpNu6CMnYWTP2YZHwnhNcrW+96cKGKA9rdmvRMd9gQeubIpC9mqsWeEbThqnN2SxGdXI7amoHA+5dU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739263861; c=relaxed/simple; bh=RGjw+3NsTs+RCA10TmYXBkF7rHaCb2sF+LgeIGkJLEk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FELfNG5Ohm/8UyWSABEnV4S+f/t2vHJKQq5EZ5eztacvb/wDtsdlBFyuxumsjISc/tugJ3FINhB9iVZrRI7vcCdwDLDyBQUCJFu0BeMUU9xX76r3lTP9bHJ72cruzbQJy6+38mtUNzQdlad0BuLWB2lMRlON7X5n7jfmggI/vCo= 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=XvPa7asW; arc=none smtp.client-ip=209.85.214.176 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="XvPa7asW" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-21f6a47d617so46948825ad.2 for ; Tue, 11 Feb 2025 00:51:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739263859; x=1739868659; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sJBX9ytmhXtnnyRTC0AdDS8eKcCd0GaltPvaNbkp3n4=; b=XvPa7asWbqLZm72NBZu/8xtH1ata9UfV3jLM72fnljNFwoIjldi+K/ix/MTj00jCZ2 EBnggnGU3pAu6sp7u3jEMykjgPYMeokGHcABnB1CHZYIOY0VQ2JgAE7bDR4jFZkpKDCO UOuNRfeaRzFvzGrQeYFpniC+mC0JDolalvjGZbmAU0zYhkhnSFuWu0ocXBAV/TleTqtr AFK4Y7ZMRg4n/v+41Z9lbrVSC4G/sp7hzqL6dMG6JOZNNeNzozQPpfQwzG9gAqb936j8 +ZaeVgemzJ5Sw7whG5jrgC5Oe8TF+jDGah38q+1fXW9Ti8NUT0728kLUwRpW6u3i1joj SjfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739263859; x=1739868659; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sJBX9ytmhXtnnyRTC0AdDS8eKcCd0GaltPvaNbkp3n4=; b=ehX2waWusA8hdnymkfKxRATYuBeDTjrlO74IMm7W1fkOoZfRhSMVDWQTVOk4z0Y5qx lICTLfQXYtAQOIzGjQv1RkukaH1p+RtHiniQHYT6E5HmLImaq9ftiW17R2NHrNwwLFaz gUX2lVBKi6VeojMm6cQe8dyOnBBx6153mD1iWJ5/GgMMCVM639Kdhl5hrnRZje3kQ6N5 5w62VklPeAL8UYWd6jGTZa3ST9WPydrweiitPElP2a9UkPeu8+38kHnwC5Ec+7PjDxg/ pOLjA0AoxuBw3YcF0xYZTRF4i2D8hJyAF3f4cDBxdTyJRUkyWRQBBvqm4JD70OX8MQ4I TrUQ== X-Forwarded-Encrypted: i=1; AJvYcCX7dUClE8dMOqmUvs0PtHGOuqqDeuevE7ZN5MvzsblyB/4qI1jdKl0g/TVp68inNNe3oF4=@vger.kernel.org X-Gm-Message-State: AOJu0YzLP2nz8YYocfmL8wl3rS9J/4ACCsysivu+NKrsS+phMxvFzWb0 2uV667pc+mG8JfbZ5dKDifQ59huWVx5U9g99aKgzavtkDatKagPW/0AlLF3C X-Gm-Gg: ASbGncu+nMRC3OwgI/HhrztvVZqsegCltbRaOOdCkjjWLXZFBzsGGcmMdGXI6p6pDSa YMa3eAOLuBNewPGrQtznK9o/uvtLBJDU2PLmY4Z0j3BXTvDTPUWTnvDZIPVBN6wA65cVCx6LanF Zot8f5s+YgHC0w5i7PZXR0hynnNpKZo4Iv+U+eQQ7CPX9/9e9jfeH0h0LtoBGtXloR5oLetUWfu RrJQifTYku2iA7oALc7FEmzawQ7ope+3kjzZ03bLemeL9KSDEF2zc3zfjDsWZ8PiqMveV66rR58 EzVfhR5NLUvtY06Swk65EmL1CMP/IGLyIrU4yLo= X-Google-Smtp-Source: AGHT+IE1XA28dfMmcUdxaDzfLXvKZBC0pfL8x87T7NGiXNP7vCB6EhQmMR9XhX+8vG4bVWybSDXg0Q== X-Received: by 2002:a17:902:ebc1:b0:216:7175:41bd with SMTP id d9443c01a7336-21f4e759750mr251359175ad.39.1739263859548; Tue, 11 Feb 2025 00:50:59 -0800 (PST) Received: from gamma.hsd1.ca.comcast.net ([2601:647:5580:5760:3858:1e16:caad:e1d4]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fa09a46534sm10201701a91.21.2025.02.11.00.50.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2025 00:50:59 -0800 (PST) From: Illia Bobyr To: Junio C Hamano Cc: Illia Bobyr , git@vger.kernel.org Subject: [PATCH v4 05/10] docs: gitdiffcore: -G and -S: Use regex/string placeholders Date: Tue, 11 Feb 2025 00:50:17 -0800 Message-ID: <20250211085028.3923875-6-illia.bobyr@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250206014324.1839232-1-illia.bobyr@gmail.com> References: <20250206014324.1839232-1-illia.bobyr@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In the rest of the documentation (and in the code) we use `regex` and `string` as `-G` and `-S` argument placeholders. While `regular-expression` and `block-of-text` are a bit easier to read, it is a bit consistent. And we could assume that everyone who uses git should be able to understand that a "string" and a "block-of-text", as well as a "regex" and "regular-expression" are the same thing. So, using a shorter version is also more consistent. --- Documentation/gitdiffcore.adoc | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Documentation/gitdiffcore.adoc b/Documentation/gitdiffcore.adoc index 642c5..0d7d66 100644 --- a/Documentation/gitdiffcore.adoc +++ b/Documentation/gitdiffcore.adoc @@ -245,26 +245,25 @@ diffcore-pickaxe: For Detecting Addition/Deletion of Specified String This transformation limits the set of filepairs to those that change specified strings between the preimage and the postimage in a certain -way. -S and -G options are used to -specify different ways these strings are sought. +way. `-S` and `-G` options are used to specify +different ways these strings are sought. -"-S" detects filepairs whose preimage and postimage -have different number of occurrences of the specified block of text. +`-S` detects filepairs whose preimage and postimage +have different number of occurrences of the specified __. By definition, it will not detect in-file moves. Also, when a changeset moves a file wholesale without affecting the interesting string, diffcore-rename kicks in as usual, and `-S` omits the filepair (since the number of occurrences of that string didn't change in that rename-detected filepair). When used with `--pickaxe-regex`, treat -the as an extended POSIX regular expression to match, +the __ as an extended POSIX regular expression to match, instead of a literal string. -"-G" (mnemonic: grep) detects filepairs whose -textual diff has an added or a deleted line that matches the given -regular expression. This means that it will detect in-file (or what -rename-detection considers the same file) moves, which is noise. The -implementation runs diff twice and greps, and this can be quite -expensive. To speed things up, binary files without textconv filters -will be ignored. +`-G` (mnemonic: grep) detects filepairs whose textual diff has +an added or a deleted line that matches the given __. This +means that it will detect in-file (or what rename-detection considers +the same file) moves, which is noise. The implementation runs diff +twice and greps, and this can be quite expensive. To speed things up, +binary files without textconv filters will be ignored. When `-S` or `-G` are used without `--pickaxe-all`, only filepairs that match their respective criterion are kept in the output. When From patchwork Tue Feb 11 08:50:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Illia Bobyr X-Patchwork-Id: 13969622 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (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 4B3291F12FC for ; Tue, 11 Feb 2025 08:51:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739263863; cv=none; b=Zm23esf/H8ZLOGFOZIlSFSDoODq2MG7NIQbPwkygYa96G20Xh7UlvCDuC9x5awQtjwMDgI6dV75Atqd6KnUeJh9mmuiGkF18ehVjw6go2m0VjozLhypH1xF51DNFdu0+pKhNiy6592wVjw8aj3u5V8G76/xc0mCPaPAJpoZNenc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739263863; c=relaxed/simple; bh=3UnR73GTtifLICN8stfTJilSCo3nLALgm1y+Qv4ynbU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aQ2pDZC3j4ATtrve37peUt3vJCGfgsnrAfs4JEUST/wMjP3wSzGxQviANAdFkaKA4y1POjWGagsvijFwltaL/P9ip5+PZ/gLXBl1zoDD63PDDzAdM00H5YvWzNo3cGmpRtUgQQoMp7TYd/SU4AjUdh4aDHf5jIttpRArwB1slO8= 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=JeyWbkLL; arc=none smtp.client-ip=209.85.216.47 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="JeyWbkLL" Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-2fa0c039d47so7638566a91.1 for ; Tue, 11 Feb 2025 00:51:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739263860; x=1739868660; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=G36treEwss/9WNMzHAXXug4APvUl7PF1Bzub2QZpVIs=; b=JeyWbkLLj17xzDmFAggko4ODCBGZxtq/grC5nI9ZscftPFOAd+kF5lZNlsDfflqS+B yqshBOdo4V5fe962bkSloIfGdEhfXE3kyVYEsQi7ciOjKw3X0u3iY1TDC2HCp1Q0Paod n13N8zxXTQizaotyTOyE+sDihVO2GXDzJ5tOIebUN9x15a3uETqbVlnaXwQNVaEDqWnR Hl9Jcm0RQcoNmvKBwa022jzMbLK0O5GjM4MkIH8MADC6+jEysIO6FVW73aQ2Vam8LH9G khelJr30Fr6yHiFIz+4sSc7KPp39FQ4uErbcZnKvRZGaucBrrcDLo2ny4GbiXVk1cpsA S2NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739263860; x=1739868660; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G36treEwss/9WNMzHAXXug4APvUl7PF1Bzub2QZpVIs=; b=fIC6+8z11aWq7y4vC+76PDUBC7JZWFmGwnbkIePWTEVD2sicKJ5EkZBwMB97k01UFI W/qDPmgaQe+A8mRoo949Bach0hQynvl/bg9f6z7v6Lujjw7rBrCNaAkQFGLiPamxCWZq Mwlk8quuLwrJa5KyHHGC4EJppzON5BRyw7i0/KQM1RtC78ef8rIz2vmd7zmsjpQFKY5E kAhMBHL/GGc6eHIh/1heD49ZqqbfNGtO3QR5JsvPMDxffGQJ2uliW8fzufW6aXpaqRFN ddKsiqSC6KwWj8C5mo9Yf0JdB4AGEnEIjODYH/2+4yFaIWIRJfiDzXNvSV9X+4HjOPrM BUuQ== X-Forwarded-Encrypted: i=1; AJvYcCW3iuD+BHW+yTvdVWmFCFtwDoEe+wa6CjNdw5DhsWd/wkmKrLt1oTAopZeY3i8Vrnb6mRg=@vger.kernel.org X-Gm-Message-State: AOJu0YwPgSiWoq0VKmSSsX4d2azLKkYfCWJ/EhU7gBVcTpEWDeu+hEzx C9RkkkAnMxo5OYn+AGWhbgI8DQWHUVB0uXefzAvTO5smJSscSHtvtZQxbxDq X-Gm-Gg: ASbGncskdiSIaxl5CROnL3TWq1r8kWW4QORSgOPLrIlfDTGtQwPJEHM/2LDF4oc71g3 5PeSl0KJThaZu2tNxtU/+PiT11lBmahyMsY3GQh19ivQrkTisZ0L+/aBg/dbZvnN8noUSOps3Og r42OwvaDWmCzZp2FLT45yC/DkD6O2Jq1u0l7XOR7pFUXUzJ+BLRF0iqrYkE7yr2UfjA506ww6sE o0arLMkXsiXRO0ImFh39W4M8Mu+weKF0zmm+RWH1AGyFycUWff2AVOGjlXOwh/4CNuBnCIrGJeE eU23KM0KbggQq5ApJ0la8o0/Wtx7NPDzWBnoL7Q= X-Google-Smtp-Source: AGHT+IFukAfhKqckZ18oUry7iMoJIlq0nAaNdqkUKCGuLo1giqpfoisawihcaFyhEcSkHzgq6Oxfsg== X-Received: by 2002:a17:90b:4b0b:b0:2fa:ba3:5455 with SMTP id 98e67ed59e1d1-2fa23f55dcdmr27026693a91.7.1739263860508; Tue, 11 Feb 2025 00:51:00 -0800 (PST) Received: from gamma.hsd1.ca.comcast.net ([2601:647:5580:5760:3858:1e16:caad:e1d4]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fa09a46534sm10201701a91.21.2025.02.11.00.50.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2025 00:51:00 -0800 (PST) From: Illia Bobyr To: Junio C Hamano Cc: Illia Bobyr , git@vger.kernel.org Subject: [PATCH v4 06/10] diff: --patch-{grep,modifies} arg names for -G and -S Date: Tue, 11 Feb 2025 00:50:18 -0800 Message-ID: <20250211085028.3923875-7-illia.bobyr@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250206014324.1839232-1-illia.bobyr@gmail.com> References: <20250206014324.1839232-1-illia.bobyr@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Most arguments have both short and long versions. Long versions are easier to read, especially in scripts and command history. This change mostly keeps existing uses of -G and -S as is in the tests, documentation and help output. Tests that check just the option parsing are duplicated to check both short and long argument options. Signed-off-by: Illia Bobyr --- Documentation/diff-options.adoc | 2 ++ Documentation/gitdiffcore.adoc | 3 ++- diff.c | 12 ++++++---- diff.h | 8 +++++-- t/t4209-log-pickaxe.sh | 42 +++++++++++++++++++++++++++++++++ 5 files changed, 59 insertions(+), 8 deletions(-) diff --git a/Documentation/diff-options.adoc b/Documentation/diff-options.adoc index 640eb..07413d 100644 --- a/Documentation/diff-options.adoc +++ b/Documentation/diff-options.adoc @@ -650,6 +650,7 @@ Note that not all diffs can feature all types. For instance, copied and renamed entries cannot appear if detection for those types is disabled. `-S`:: +`--patch-modifies=`:: Look for differences that change the number of occurrences of the specified __ (i.e. addition/deletion) in a file. Intended for the scripter's use. @@ -663,6 +664,7 @@ very first version of the block. Binary files are searched as well. `-G`:: +`--patch-grep=`:: Look for differences whose patch text contains added/removed lines that match __. + diff --git a/Documentation/gitdiffcore.adoc b/Documentation/gitdiffcore.adoc index 0d7d66..e934b9 100644 --- a/Documentation/gitdiffcore.adoc +++ b/Documentation/gitdiffcore.adoc @@ -245,7 +245,8 @@ diffcore-pickaxe: For Detecting Addition/Deletion of Specified String This transformation limits the set of filepairs to those that change specified strings between the preimage and the postimage in a certain -way. `-S` and `-G` options are used to specify +way. `--patch-modifies=` (`-S` for short) and +`--patch-grep=` (`-G` for short) are used to specify different ways these strings are sought. `-S` detects filepairs whose preimage and postimage diff --git a/diff.c b/diff.c index bd9db..ac2cd 100644 --- a/diff.c +++ b/diff.c @@ -4877,15 +4877,17 @@ void diff_setup_done(struct diff_options *options) if (HAS_MULTI_BITS(options->pickaxe_opts & DIFF_PICKAXE_KINDS_MASK)) die(_("options '%s', '%s', and '%s' cannot be used together"), - "-G", "-S", "--find-object"); + "-G/--patch-grep", "-S/--patch-modifies", "--find-object"); if (HAS_MULTI_BITS(options->pickaxe_opts & DIFF_PICKAXE_KINDS_G_REGEX_MASK)) die(_("options '%s' and '%s' cannot be used together, use '%s' with '%s'"), - "-G", "--pickaxe-regex", "--pickaxe-regex", "-S"); + "-G/--patch-grep", "--pickaxe-regex", + "--pickaxe-regex", "-S/--patch-modifies"); if (HAS_MULTI_BITS(options->pickaxe_opts & DIFF_PICKAXE_KINDS_ALL_OBJFIND_MASK)) die(_("options '%s' and '%s' cannot be used together, use '%s' with '%s' and '%s'"), - "--pickaxe-all", "--find-object", "--pickaxe-all", "-G", "-S"); + "--pickaxe-all", "--find-object", + "--pickaxe-all", "-G/--patch-grep", "-S/--patch-modifies"); /* * Most of the time we can say "there are changes" @@ -5862,10 +5864,10 @@ struct option *add_diff_options(const struct option *opts, OPT_SET_INT_F(0, "ita-visible-in-index", &options->ita_invisible_in_index, N_("treat 'git add -N' entries as real in the index"), 0, PARSE_OPT_NONEG), - OPT_CALLBACK_F('S', NULL, options, N_(""), + OPT_CALLBACK_F('S', "patch-modifies", options, N_(""), N_("look for differences that change the number of occurrences of the specified string"), 0, diff_opt_pickaxe_string), - OPT_CALLBACK_F('G', NULL, options, N_(""), + OPT_CALLBACK_F('G', "patch-grep", options, N_(""), N_("look for differences where a patch contains the specified regex"), 0, diff_opt_pickaxe_regex), OPT_BIT_F(0, "pickaxe-all", &options->pickaxe_opts, diff --git a/diff.h b/diff.h index 787bb..ed48a 100644 --- a/diff.h +++ b/diff.h @@ -606,8 +606,12 @@ void diffcore_fix_diff_index(void); " try unchanged files as candidate for copy detection.\n" \ " -l limit rename attempts up to paths.\n" \ " -O reorder diffs according to the .\n" \ -" -G find differences where patch contains the specified regex.\n" \ -" -S find filepair who differ in the number of occurrences of string.\n" \ +" -G\n" \ +" --patch-grep=\n" \ +" find differences where patch contains the regex.\n" \ +" -S\n" \ +" --patch-modifies=\n" \ +" find filepair who differ in the number of occurrences of string.\n" \ " --pickaxe-grep\n" \ " treat as a regex in the -S argument.\n" \ " --pickaxe-all\n" \ diff --git a/t/t4209-log-pickaxe.sh b/t/t4209-log-pickaxe.sh index ed70c..ab14b 100755 --- a/t/t4209-log-pickaxe.sh +++ b/t/t4209-log-pickaxe.sh @@ -60,24 +60,48 @@ test_expect_success 'usage' ' test_expect_code 129 git log -S 2>err && test_grep "switch.*requires a value" err && + test_expect_code 129 git log --patch-modifies 2>err && + test_grep "option.*requires a value" err && + test_expect_code 129 git log -G 2>err && test_grep "switch.*requires a value" err && + test_expect_code 129 git log --patch-grep 2>err && + test_grep "option.*requires a value" err && + test_expect_code 128 git log -Gregex -Sstring 2>err && grep "cannot be used together" err && + test_expect_code 128 git log -Gregex --patch-modifies string 2>err && + grep "cannot be used together" err && + + test_expect_code 128 git log --patch-grep regex -Sstring 2>err && + grep "cannot be used together" err && + + test_expect_code 128 git log --patch-grep regex --patch-modifies string 2>err && + grep "cannot be used together" err && + test_expect_code 128 git log -Gregex --find-object=HEAD 2>err && grep "cannot be used together" err && + test_expect_code 128 git log --patch-grep regex --find-object=HEAD 2>err && + grep "cannot be used together" err && + test_expect_code 128 git log -Sstring --find-object=HEAD 2>err && grep "cannot be used together" err && + test_expect_code 128 git log --patch-modifies string --find-object=HEAD 2>err && + grep "cannot be used together" err && + test_expect_code 128 git log --pickaxe-all --find-object=HEAD 2>err && grep "cannot be used together" err ' test_expect_success 'usage: --pickaxe-regex' ' test_expect_code 128 git log -Gregex --pickaxe-regex 2>err && + grep "cannot be used together" err && + + test_expect_code 128 git log --patch-grep regex --pickaxe-regex 2>err && grep "cannot be used together" err ' @@ -89,7 +113,13 @@ test_expect_success 'usage: --no-pickaxe-regex' ' test_expect_code 128 git log -Sstring --no-pickaxe-regex 2>actual && test_cmp expect actual && + test_expect_code 128 git log --patch-modifies string --no-pickaxe-regex 2>actual && + test_cmp expect actual && + test_expect_code 128 git log -Gregex --no-pickaxe-regex 2>err && + test_cmp expect actual && + + test_expect_code 128 git log --patch-grep regex --no-pickaxe-regex 2>err && test_cmp expect actual ' @@ -104,9 +134,13 @@ test_log_icase expect_second --author person test_log_icase expect_nomatch --author spreon test_log expect_nomatch -G picked +test_log expect_nomatch --patch-grep picked test_log expect_second -G Picked +test_log expect_second --patch-grep Picked test_log_icase expect_nomatch -G pickle +test_log_icase expect_nomatch --patch-grep pickle test_log_icase expect_second -G picked +test_log_icase expect_second --patch-grep picked test_expect_success 'log -G --textconv (missing textconv tool)' ' echo "* diff=test" >.gitattributes && @@ -122,14 +156,22 @@ test_expect_success 'log -G --no-textconv (missing textconv tool)' ' ' test_log expect_nomatch -S picked +test_log expect_nomatch --patch-modifies picked test_log expect_second -S Picked +test_log expect_second --patch-modifies Picked test_log_icase expect_second -S picked +test_log_icase expect_second --patch-modifies picked test_log_icase expect_nomatch -S pickle +test_log_icase expect_nomatch --patch-modifies pickle test_log expect_nomatch -S p.cked --pickaxe-regex +test_log expect_nomatch --patch-modifies p.cked --pickaxe-regex test_log expect_second -S P.cked --pickaxe-regex +test_log expect_second --patch-modifies P.cked --pickaxe-regex test_log_icase expect_second -S p.cked --pickaxe-regex +test_log_icase expect_second --patch-modifies p.cked --pickaxe-regex test_log_icase expect_nomatch -S p.ckle --pickaxe-regex +test_log_icase expect_nomatch --patch-modifies p.ckle --pickaxe-regex test_expect_success 'log -S --textconv (missing textconv tool)' ' echo "* diff=test" >.gitattributes && From patchwork Tue Feb 11 08:50:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Illia Bobyr X-Patchwork-Id: 13969623 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 38F3A1F0E34 for ; Tue, 11 Feb 2025 08:51:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739263863; cv=none; b=DM8oz+lZlih6OnTQFX8tTR4Al3pNM1rRRk/DqShkL095VAH7bAStSWmywrn3OjAztNDlcYnQs5TLpaYBbUknZ3cQoMhui2WFHv4gjLYxACOEmFPM8eN0g8XNKcXXq4YT3KOfTAx5wY27pc62y7ND16U2zDH1EULd3j1b2vLNNlA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739263863; c=relaxed/simple; bh=sA2Fl6EaZ/yJyhqVWnSlz2kiXbSnEIokifLfU1UBcuw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oJ8iAdC9ZTxH3jC9AklHuBhmtIswveYX3jC3gn02iPDTblfR6ZlZu9QxcrIwV2iT5JxQQRnVTXlgpwvt7ZMQ2QU2sox7w74VD0vgcFuLOIO2baImlOFLKadYp8XUhNVsFWqHfGXBdLtwNPilEXrckRyU+SbPg8xAuXtc681gfA0= 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=cNzSE5QE; arc=none smtp.client-ip=209.85.214.180 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="cNzSE5QE" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-21fa56e1583so25611915ad.3 for ; Tue, 11 Feb 2025 00:51:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739263861; x=1739868661; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oShxNFBA2whHNuM0znTUdxztBoBluLeuiQwSYo49ZOQ=; b=cNzSE5QE7GYwLKxsSXrFYszbaw2SlmInazC6gfH1wmVyam+enHp8Zo2HleVUuhCJnA mZ1ziZBou+3zuxjpuhlrjTno0Sub8CGbl4g2hbXrDEpVWYrQo0czRErIus27twJ0sCe9 UKbgs8kGkmoHWyd+D+mL5QIbUwv7WcyJ+7JQUJzYs5fbi+LaGdDbul1G/00kO5Yrbk/5 BV6WpzXPNzI5DTtZSd/SAdyyKsRQ1vc+V6kSUvBNAtAaFNclcV/bCosG/iwqDKFO+3J2 eG8Rm8PZeqFh7houigIyUzW91mHmLNQEMNlUNhCKe16llXA3HUi+amL1TjQhqZjdeipb wuZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739263861; x=1739868661; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oShxNFBA2whHNuM0znTUdxztBoBluLeuiQwSYo49ZOQ=; b=HO14niWj/gLaM0HlWC4lTHPJvrT584Nk9GHHMLle8v+gMzi3wiRPZG0p6sslLXOTD+ 7uhlRdGwdYQyqqdicGY7p2tPOfWfhgqe16Lo4PJ18va+qg3CqmMmfeUT+XpEhgfYUqMb poF5gbgCnmWz7GgNnesqbGnjpbw2HJtnQ+QUCqQcDS5ejElpCzojd6y+8rCkLQQqNzK5 M9ZKSCmy6cjkE1kDIRZFywKWj4Ofn6KTH1wfwbZLgVY+Ik1z8Dmz70UmN7dUy+5eq1Rt Hbu5NLEIbBRgIEryAmmHEyrl410Dcv4F6N8xGLoHlCSEUJOiEq2DEdNMXW/X3iqUFq9m RWkA== X-Forwarded-Encrypted: i=1; AJvYcCVRQhnEXLC81XPVVlz+9rpGh4mRXBs0+M6twj6g5EzdYHbPBba/gOU8yI2b6uP/3Q0pwiU=@vger.kernel.org X-Gm-Message-State: AOJu0YykO3qikw4O7Ju9zYCRnYHAGjofTNQ5L0Z+SlBf2Lrd8cONdzKp qQIRTad/tickmqDAP4KyjgIYHNabUDJU4NezONHaj2/72cQN2HRonBFJ3PIT X-Gm-Gg: ASbGncumdVy0JOFM2z+JZ6cY/KB5/VhP5XjAPslUL2jWEac2K+SbS5L+cwF/pp9V2JR 3OGCGQWsFaYFzrOD1PhevZuqiX9xEl+liC7aLNJRAeA5HilxZd0oEZIOjvMAjuQBUgh05a9HEAq bjhGpVXiCkAGaGcDPZr5ZZvRcpVNj8OM3s/wnh5wESHNCmG0P9j7bSNWicDdlUQ6ePZl5REKtm9 h1Xu2Pf60MhVWocOCyEqhlYuUmdt+dUQuL3hxYOBqEx5iG8ynQ/QuznAEgos5Rg+/6ns/LApZKi L/g++DfzeVQW/jMV6yXudQJ+uPWdgFGowxBOraU= X-Google-Smtp-Source: AGHT+IFLMMlRo0GjPxip9xanWxy/ex9ghxi2+9Z23hspX8Nhn7c+DJfbxGnxfzlnpDRPm+6SOsIA+w== X-Received: by 2002:a17:902:f681:b0:216:2dc4:50ab with SMTP id d9443c01a7336-21f4e1cb849mr284637925ad.2.1739263861396; Tue, 11 Feb 2025 00:51:01 -0800 (PST) Received: from gamma.hsd1.ca.comcast.net ([2601:647:5580:5760:3858:1e16:caad:e1d4]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fa09a46534sm10201701a91.21.2025.02.11.00.51.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2025 00:51:01 -0800 (PST) From: Illia Bobyr To: Junio C Hamano Cc: Illia Bobyr , git@vger.kernel.org Subject: [PATCH v4 07/10] completion: Support --patch-{grep,modifies} Date: Tue, 11 Feb 2025 00:50:19 -0800 Message-ID: <20250211085028.3923875-8-illia.bobyr@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250206014324.1839232-1-illia.bobyr@gmail.com> References: <20250206014324.1839232-1-illia.bobyr@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- contrib/completion/git-completion.bash | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 41391..daf335 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1900,6 +1900,7 @@ __git_diff_common_options="--stat --numstat --shortstat --summary --output= --output-indicator-context= --output-indicator-new= --output-indicator-old= --ws-error-highlight= + --patch-grep= --patch-modifies= --pickaxe-all --pickaxe-regex --patch-with-raw " @@ -2216,7 +2217,7 @@ __git_complete_log_opts () __git_complete_symbol --cur="${cur#:}" --sfx=":" return ;; - -G,*|-S,*) + -G,*|--patch-grep,*|-S,*|--patch-modifies,*) __git_complete_symbol return ;; @@ -2239,6 +2240,14 @@ __git_complete_log_opts () __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}" return ;; + --patch-grep=*) + __git_complete_symbol --pfx="--patch-grep=" --cur="${cur#--patch-grep=}" + return + ;; + --patch-modifies=*) + __git_complete_symbol --pfx="--patch-modifies=" --cur="${cur#--patch-modifies=}" + return + ;; --submodule=*) __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}" return From patchwork Tue Feb 11 08:50:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Illia Bobyr X-Patchwork-Id: 13969624 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (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 203381F130F for ; Tue, 11 Feb 2025 08:51:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739263864; cv=none; b=CsNji4PfExMqzulXRzzVLOjthgxVOGeTYBvNEb/Y4HuAUCGG6kiomDFe0rjDkqv8a2GtA1r9VKBvkGUonntduyn0U86IMjQdlTPK2KuJEFWHxP4TrcC+2dwb+XWlbyd4uEopOnU7iXBr1jjAN55aThmFOKLTMEb5G6V6QYNzrKU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739263864; c=relaxed/simple; bh=1k6sZFd5SlI1tRrsIV2iTwLP+8Q3ipcVpAKF+jzh+uQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PQ/sn3FGZzP+J+sXFo+eSvdC7BkSGpOaxtivrwnlMdWdS5iTfdMdF16Vh3fbYwWDXJ4AW27hQc93SVvcf2rZeG/Kmgvd0zJN0F+uuAz8G9Kg1yW2vwcwbzJ6H2Pw0frFMJzwsCw/PPKS8MOLsTFTze8qyrNiMRCUEB3AD5s4yI4= 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=eqt9s3Ku; arc=none smtp.client-ip=209.85.216.41 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="eqt9s3Ku" Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-2fa488351ffso4073343a91.3 for ; Tue, 11 Feb 2025 00:51:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739263862; x=1739868662; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8yLM0t6bi/COjCWc8nMIU3KttU+/DAqFPI83g6CJ4i4=; b=eqt9s3KuXRqHX684/2CBEzdgi6zMSiu1jwhFTjRR6vdkDteQoWBz0fc9UO2NKN95up ohKEYbj2k3obKsKbU+SdgNCYR09VhDzMYj905oO1a0CeAMZG/go8VYdtyYDvfTkq4Jnb Hdw0Jd+5Ms6xa35uirBT6s3GWzVQT63A5hZFVUefTVHf/PLioAtASLXCpkp8jYgENlnh j3Ufuo6JdbTn+/Nm57eQUwa7TJ6Y1xPaogPhW0Ljhq6LMH3Ver8n4kcQAb1ZnFrmmJPJ U0frMIW9uN0bVeNfiPuhdI2ryVzX5ejhriAxK2y2EjoNIyY3WFbMn6SWyHy2y0by8wpO qO7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739263862; x=1739868662; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8yLM0t6bi/COjCWc8nMIU3KttU+/DAqFPI83g6CJ4i4=; b=O3WAXM5SR6+lh+KxlnAQd3CZAprI8T/4soAwJUIb5GsNLpGUde/LrWIS6eBJx1dB+f 1yp6FlO1VLq1xhd2KMTFNRPgNtepZWk/69ARX05fFOdR5JovomZKC7Fs7Y2z0xDNOhla vmTW/CVowW7gAo1Oy/T7iK72BQt88zRRC5TeZjKRQL6nS+EmYOSfinGiTn/KiaAY2//W IPkUYTXIlZeaChh9r77uiMO2/TbAFVPhlXUN5eWqKFc5og0MafnMUupJKgowLdtPSxXU rntIBifObbPIxUkdLjDm8pZRCyM39IodhGOHHfIBiM7HBr3y7CZ6ydgmVk3X9V8BAkCo 2UgQ== X-Forwarded-Encrypted: i=1; AJvYcCXCxEmGPkalbHfdJyDW3RdZUFAHcFwNhTzK0HasGQ+i/EsQOL6XtKBxCbYE5CqLzgssqjs=@vger.kernel.org X-Gm-Message-State: AOJu0Yz9OUETAmUWC1OmXXF5+4sx3oz7QngavIbUfEo32TUkcHxMoe0j P6sGKWYP3zsYUGrr0xtIiVu8+3I5EPNuCTdyDGr8MBwsqHNjNQKCtF9K07Qr X-Gm-Gg: ASbGncu0+HfUezLYhZQRIbaFCLtLSZ3+rLGwpg+1pQA+7O9xHlS/t2CKZ0OIU7oW1g6 iTscpLRq8aT5w5WfSI/DWQVdHydkvIWDvgV9/w5W3LZ4kSTAOLjMGK6hOLcOrZSg1nowH1lHlHg 1W6JjUWEQmz8wO0lGHqDd2VdMABiHCjrgdqu8GPMVrGBYlQ4KPX06VpFZ0Mw0bzoEjPqLbzJxvi l61sAIl1AZ1rSxbjroMg47XKf9ehskGa+47ge4qIQH+vGr11AJA2JZi+peheLHv8BRXXL4343MW eduw8uU7zVMpZXdQ4Sv26B8IJSnbENKJ/jLmNrU= X-Google-Smtp-Source: AGHT+IFa7W+HVVOIfOgpPRVU6XXgCAWA8LRI0R4ri7jE0w9L6rOEVzjJKKbJaMhTFgAI8y7/Rh6dpg== X-Received: by 2002:a17:90b:3143:b0:2ee:f22a:61dd with SMTP id 98e67ed59e1d1-2fa243eef9bmr23269818a91.32.1739263862326; Tue, 11 Feb 2025 00:51:02 -0800 (PST) Received: from gamma.hsd1.ca.comcast.net ([2601:647:5580:5760:3858:1e16:caad:e1d4]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fa09a46534sm10201701a91.21.2025.02.11.00.51.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2025 00:51:01 -0800 (PST) From: Illia Bobyr To: Junio C Hamano Cc: Illia Bobyr , git@vger.kernel.org Subject: [PATCH v4 08/10] diff: test: Use --patch-{grep,modifies} over -G/-S Date: Tue, 11 Feb 2025 00:50:20 -0800 Message-ID: <20250211085028.3923875-9-illia.bobyr@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250206014324.1839232-1-illia.bobyr@gmail.com> References: <20250206014324.1839232-1-illia.bobyr@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Long argument names are easier to read, compared to short ones. So while short arguments are great when you want to type a command quickly, tests are more readable if we use long argument names. There are still test that verify that both short and long arguments work interchangeably when parsing the arguments. Tests where the focus is not on the argument names are updated to use long argument names. --- t/t4062-diff-pickaxe.sh | 8 +++--- t/t4209-log-pickaxe.sh | 62 ++++++++++++++++++++--------------------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/t/t4062-diff-pickaxe.sh b/t/t4062-diff-pickaxe.sh index 8ad3d7..805e0f 100755 --- a/t/t4062-diff-pickaxe.sh +++ b/t/t4062-diff-pickaxe.sh @@ -16,13 +16,13 @@ test_expect_success setup ' ' # OpenBSD only supports up to 255 repetitions, so repeat twice for 64*64=4096. -test_expect_success '-G matches' ' - git diff --name-only -G "^(0{64}){64}$" HEAD^ >out && +test_expect_success '--patch-grep matches' ' + git diff --name-only --patch-grep "^(0{64}){64}$" HEAD^ >out && test 4096-zeroes.txt = "$(cat out)" ' -test_expect_success '-S --pickaxe-regex' ' - git diff --name-only -S0 --pickaxe-regex HEAD^ >out && +test_expect_success '--patch-modifies --pickaxe-regex' ' + git diff --name-only --patch-modifies 0 --pickaxe-regex HEAD^ >out && test 4096-zeroes.txt = "$(cat out)" ' diff --git a/t/t4209-log-pickaxe.sh b/t/t4209-log-pickaxe.sh index ab14b..5f4d6 100755 --- a/t/t4209-log-pickaxe.sh +++ b/t/t4209-log-pickaxe.sh @@ -1,6 +1,6 @@ #!/bin/sh -test_description='log --grep/--author/--regexp-ignore-case/-S/-G' +test_description='log --grep/--author/--regexp-ignore-case/--patch-{modifies,grep}' . ./test-lib.sh @@ -142,15 +142,15 @@ test_log_icase expect_nomatch --patch-grep pickle test_log_icase expect_second -G picked test_log_icase expect_second --patch-grep picked -test_expect_success 'log -G --textconv (missing textconv tool)' ' +test_expect_success 'log --patch-grep --textconv (missing textconv tool)' ' echo "* diff=test" >.gitattributes && - test_must_fail git -c diff.test.textconv=missing log -Gfoo && + test_must_fail git -c diff.test.textconv=missing log --patch-grep foo && rm .gitattributes ' -test_expect_success 'log -G --no-textconv (missing textconv tool)' ' +test_expect_success 'log --patch-grep --no-textconv (missing textconv tool)' ' echo "* diff=test" >.gitattributes && - git -c diff.test.textconv=missing log -Gfoo --no-textconv >actual && + git -c diff.test.textconv=missing log --patch-grep foo --no-textconv >actual && test_cmp expect_nomatch actual && rm .gitattributes ' @@ -173,20 +173,20 @@ test_log_icase expect_second --patch-modifies p.cked --pickaxe-regex test_log_icase expect_nomatch -S p.ckle --pickaxe-regex test_log_icase expect_nomatch --patch-modifies p.ckle --pickaxe-regex -test_expect_success 'log -S --textconv (missing textconv tool)' ' +test_expect_success 'log --patch-modifies --textconv (missing textconv tool)' ' echo "* diff=test" >.gitattributes && - test_must_fail git -c diff.test.textconv=missing log -Sfoo && + test_must_fail git -c diff.test.textconv=missing log --patch-modifies foo && rm .gitattributes ' -test_expect_success 'log -S --no-textconv (missing textconv tool)' ' +test_expect_success 'log --patch-modifies --no-textconv (missing textconv tool)' ' echo "* diff=test" >.gitattributes && - git -c diff.test.textconv=missing log -Sfoo --no-textconv >actual && + git -c diff.test.textconv=missing log --patch-modifies foo --no-textconv >actual && test_cmp expect_nomatch actual && rm .gitattributes ' -test_expect_success 'setup log -[GS] plain & regex' ' +test_expect_success 'setup log --patch{-modifies,-grep} plain & regex' ' test_create_repo GS-plain && test_commit -C GS-plain --append A data.txt "a" && test_commit -C GS-plain --append B data.txt "a a" && @@ -201,31 +201,31 @@ test_expect_success 'setup log -[GS] plain & regex' ' git -C GS-plain log >full-log ' -test_expect_success 'log -G trims diff new/old [-+]' ' - git -C GS-plain log -G"[+-]a" >log && +test_expect_success 'log --patch-grep trims diff new/old [-+]' ' + git -C GS-plain log --patch-grep "[+-]a" >log && test_must_be_empty log && - git -C GS-plain log -G"^a" >log && + git -C GS-plain log --patch-grep "^a" >log && test_cmp log A-to-B-then-E-log ' -test_expect_success 'log -S is not a regex, but -S --pickaxe-regex is' ' - git -C GS-plain log -S"a" >log && +test_expect_success 'log --patch-modifies is not a regex, but --patch-modifies --pickaxe-regex is' ' + git -C GS-plain log --patch-modifies "a" >log && test_cmp log A-to-B-then-E-log && - git -C GS-plain log -S"[a]" >log && + git -C GS-plain log --patch-modifies "[a]" >log && test_must_be_empty log && - git -C GS-plain log -S"[a]" --pickaxe-regex >log && + git -C GS-plain log --patch-modifies "[a]" --pickaxe-regex >log && test_cmp log A-to-B-then-E-log && - git -C GS-plain log -S"[b]" >log && + git -C GS-plain log --patch-modifies "[b]" >log && test_cmp log D-then-E-log && - git -C GS-plain log -S"[b]" --pickaxe-regex >log && + git -C GS-plain log --patch-modifies "[b]" --pickaxe-regex >log && test_cmp log C-to-D-then-E-log ' -test_expect_success 'setup log -[GS] binary & --text' ' +test_expect_success 'setup log --patch{-modifies,-grep} binary & --text' ' test_create_repo GS-bin-txt && test_commit -C GS-bin-txt --printf A data.bin "a\na\0a\n" && test_commit -C GS-bin-txt --append --printf B data.bin "a\na\0a\n" && @@ -233,36 +233,36 @@ test_expect_success 'setup log -[GS] binary & --text' ' git -C GS-bin-txt log >full-log ' -test_expect_success 'log -G ignores binary files' ' - git -C GS-bin-txt log -Ga >log && +test_expect_success 'log --patch-grep ignores binary files' ' + git -C GS-bin-txt log --patch-grep a >log && test_must_be_empty log ' -test_expect_success 'log -G looks into binary files with -a' ' - git -C GS-bin-txt log -a -Ga >log && +test_expect_success 'log --patch-grep looks into binary files with -a' ' + git -C GS-bin-txt log -a --patch-grep a >log && test_cmp log full-log ' -test_expect_success 'log -G looks into binary files with textconv filter' ' +test_expect_success 'log --patch-grep looks into binary files with textconv filter' ' test_when_finished "rm GS-bin-txt/.gitattributes" && ( cd GS-bin-txt && echo "* diff=bin" >.gitattributes && - git -c diff.bin.textconv=cat log -Ga >../log + git -c diff.bin.textconv=cat log --patch-grep a >../log ) && test_cmp log full-log ' -test_expect_success 'log -S looks into binary files' ' - git -C GS-bin-txt log -Sa >log && +test_expect_success 'log --patch-modifies looks into binary files' ' + git -C GS-bin-txt log --patch-modifies a >log && test_cmp log full-log ' -test_expect_success 'log -S --pickaxe-regex looks into binary files' ' - git -C GS-bin-txt log --pickaxe-regex -Sa >log && +test_expect_success 'log --patch-modifies --pickaxe-regex looks into binary files' ' + git -C GS-bin-txt log --pickaxe-regex --patch-modifies a >log && test_cmp log full-log && - git -C GS-bin-txt log --pickaxe-regex -S"[a]" >log && + git -C GS-bin-txt log --pickaxe-regex --patch-modifies "[a]" >log && test_cmp log full-log ' From patchwork Tue Feb 11 08:50:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Illia Bobyr X-Patchwork-Id: 13969625 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 DE89B1F1510 for ; Tue, 11 Feb 2025 08:51:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739263865; cv=none; b=FKwc0VEHUo7js+LBwq2kMmKUrO07UD8SVkvtsr87aYTwPQDeYGZc1uBxNoal2rYKVwNqxV9JN4Jjum0wQ9AEWwmqEU3IIbD8rD1yH44Wg7WlNnT2AukQcN2q/LktgVzTLNtZlHKS8ySZr2JXqiDybvNWdCSgAzltthqOpqA3PVw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739263865; c=relaxed/simple; bh=at0aJg0TAgmlpPYtiUNOgwEq/y1ZzMivTl9xaEzT55k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KF90DDkXpnzSNo6Z09lzhmlSOg/ISzUp9I3nF4/Nqqdrti4X0hzBHySTPkXw0El6b4T8Anhh0zRYku1zVg4ZagmHhU9Lw1wXhaE3ZQ+7TchsF/8WH56LiGNdGFqHB/d9qJhWrLm8EkbLi9+RMoL/Ggdz94XJlSGU6CABzmYQNUI= 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=ifje3y18; arc=none smtp.client-ip=209.85.216.49 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="ifje3y18" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-2fa51743d80so3797843a91.2 for ; Tue, 11 Feb 2025 00:51:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739263863; x=1739868663; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xWUP9PAoX6nXGAi7BUu9ADVDebYFDrcl3z3wLBs5/5U=; b=ifje3y18GWcpofGLhePkVC3kNYVkifc+RMSMddz/cMdo/aypWOBUjhfHZFPcaq/YcK 9n64PEfPakeVoidn8rKlsXU+NtRaNzWoOvmDualUTjWF4DBxhrOtc5PNuNukGTeaNa81 nWp7jFfbQGSh8lMA2IxQtyXQI2bk7DnampuGH+943uHvR4A1s2+adLmrjI+ptzSEj/8p CDBUGSlhq0Bq7/VPN7nkwhRH8S3kX6bpIv7DkcPAj2vY+qMLlfazQgINuy00jqBOEYtq ZAlwP4EoEx02HlrKCyIiVJX0EdznzYNMghUEG7/7vzfi6ZihNpE/FLMDbVEvSGKFJNVk BvrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739263863; x=1739868663; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xWUP9PAoX6nXGAi7BUu9ADVDebYFDrcl3z3wLBs5/5U=; b=GowlZkTwfbjGcUQUR6rwjN44K/bgV1lB9zdEChUwdN0qXJRQ58izHDyoXJDUyouBzd wb8EfNBygvQbBDRdVW5Z6ekG+Oc252sa8VpYVyzcB9VDW4D/7vGIynFQOZlxiNoUC+HP MLcLWHM5I958XvcJaD/Ka7hqrfVxp9H+OCr9y8HAIS+lQxGxSV7hYID8KCB+Zq59Snx2 h/eF1xDhgDgxWKSr3P0nBU0WVGfjhUaeOPbEYykqZt1Y/Fx/XbNCsSbxl19jRG7VKnw1 457pDCT3HQhabFPNGo0auvLc+wcrY8F2v3YAGR7ly8TROxBEK3zPGBGWS+DcmuKXRZTR sE5A== X-Forwarded-Encrypted: i=1; AJvYcCXBhyn+BSmhTfPHiRg0oKExShnEm5YjGZa6k6D1+zk8njd4aqdSXqWf2r4m4MlPWXcMfYU=@vger.kernel.org X-Gm-Message-State: AOJu0Yw2xEhEQG2r7Cn+A5/cdxC3dq1o26pD2/KvrCZHyfos1lSqM46D zEtXB6EIB/nQqEkrNzfmLpsexi5BKuO8/2TMIqxmobnvaBfQsnSvX4X7CfU4 X-Gm-Gg: ASbGncuqFXSO0uhcY7lMRz6JteCLakzYqGJlLvk2ynLEPm/zEaRgwc2Gz4avd2wVY66 zvvLG66swN8iybSUwTqNHdkzQjQkGN8nQ1AW0Wy1+fx2LcFwZKTRafNjb8E/+mHWNnTsNBb+r8T 3rMSXrqFVwO2vNlTht2jOusEu02atp5LMuszq5GJROh3dlmnXni36/nKqK8guI+ORUu9QmffI2t vOlUG280jUGh9O4I1LFexXi7waKv2ugCrwhQDF024ehwrsDLHhGfdgOt3B9d1Af2HGgKbHPlyAE 7LAqQZ8TcYo0uIf0fJy5sfugtsbU06ObzyYfPOw= X-Google-Smtp-Source: AGHT+IHTZhADEuyNSWSwsNGtvWWzQRGjENjJsFCTW0zEoAxwt3GcHekdva4OqVr+m6fw+ifkxOnhwg== X-Received: by 2002:a17:90a:6fa1:b0:2f8:b2c:5ef3 with SMTP id 98e67ed59e1d1-2fa24063babmr29549220a91.14.1739263863231; Tue, 11 Feb 2025 00:51:03 -0800 (PST) Received: from gamma.hsd1.ca.comcast.net ([2601:647:5580:5760:3858:1e16:caad:e1d4]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fa09a46534sm10201701a91.21.2025.02.11.00.51.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2025 00:51:02 -0800 (PST) From: Illia Bobyr To: Junio C Hamano Cc: Illia Bobyr , git@vger.kernel.org Subject: [PATCH v4 09/10] diff: --pickaxe-{all,regex} help: Add --patch-{grep,modifies} Date: Tue, 11 Feb 2025 00:50:21 -0800 Message-ID: <20250211085028.3923875-10-illia.bobyr@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250206014324.1839232-1-illia.bobyr@gmail.com> References: <20250206014324.1839232-1-illia.bobyr@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 For less experienced users --patch-{grep,modifies} should be easier to understand than just -S or -G. By mentioning the long argument names in the help messages we save those users from having to search the list of options for an explanation of what -S or -G stand for. --- diff.c | 4 ++-- diff.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/diff.c b/diff.c index ac2cd..a9e78 100644 --- a/diff.c +++ b/diff.c @@ -5871,10 +5871,10 @@ struct option *add_diff_options(const struct option *opts, N_("look for differences where a patch contains the specified regex"), 0, diff_opt_pickaxe_regex), OPT_BIT_F(0, "pickaxe-all", &options->pickaxe_opts, - N_("show all changes in the changeset with -S or -G"), + N_("show all changes in the changeset with -S/--patch-modifies or -G/--patch-grep"), DIFF_PICKAXE_ALL, PARSE_OPT_NONEG), OPT_BIT_F(0, "pickaxe-regex", &options->pickaxe_opts, - N_("treat in -S as extended POSIX regular expression"), + N_("treat in -S/--patch-modifies as extended POSIX regular expression"), DIFF_PICKAXE_REGEX, PARSE_OPT_NONEG), OPT_FILENAME('O', NULL, &options->orderfile, N_("control the order in which files appear in the output")), diff --git a/diff.h b/diff.h index ed48a..9ad37 100644 --- a/diff.h +++ b/diff.h @@ -613,9 +613,9 @@ void diffcore_fix_diff_index(void); " --patch-modifies=\n" \ " find filepair who differ in the number of occurrences of string.\n" \ " --pickaxe-grep\n" \ -" treat as a regex in the -S argument.\n" \ +" treat as a regex in the -S/--patch-modifies argument.\n" \ " --pickaxe-all\n" \ -" show all files diff when -G or -S is used and hit is found.\n" \ +" show all files diff for -G/--patch-grep and -S/--patch-modifies.\n" \ " -a --text treat all files as text.\n" int diff_queue_is_empty(struct diff_options *o); From patchwork Tue Feb 11 08:50:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Illia Bobyr X-Patchwork-Id: 13969626 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (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 0D0E81F1531 for ; Tue, 11 Feb 2025 08:51:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739263866; cv=none; b=dIhpyqKSRjpgyfZLfVEXm4NEx5S7ouvjzJ9gOj4FJEPogFbCGYbRijkxzd+hOE7poE3O/SXk0+79tWmIdXGmIZNgEtqnm2DVufnRj5C/G3ylV4nvwp/lnHxkrdKieQdjz2qtBCrF/LIW2Chq/90VsaQ4BFekIfKJfkx1qV7HAAA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739263866; c=relaxed/simple; bh=ZsWjGimXpmQn9cPBe7u+bT9hy9pA5OSNwTrDWZ4GmKc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hEZcFduaf9EIESCMD9jt41Fm9mIK8gF5GJGVLjmSZ9aculH2+2WJkRZDC+ugjEyqn0vPefc5RIJWP9aXngVZ7AAazfPG6kBdpFQ7LhjD302yRbr57cxk4WSt21yjoeD7wBD817fN9W3PfiQr75VMR3fT15TD++MYs2vwqIcpIMs= 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=KBGfy5Sm; arc=none smtp.client-ip=209.85.216.43 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="KBGfy5Sm" Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-2f42992f608so8033805a91.0 for ; Tue, 11 Feb 2025 00:51:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739263864; x=1739868664; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yDX88l6a351yJl4J67+MLD3V7wGrx+WJItQnoPZae5s=; b=KBGfy5SmKEJtAGNzDb2WeMbvSPQqIDFe0cqs9oMuwm5V8Y00fW9vBmrIdEJl4C1TX9 UTNP0GBeIAjAM2TA0DS6zV5ZyGnUlqTvFi3BujFEkYiS5t/vqa1YoHawDVCrkB/cA+VO T+mN4TmEVC8xo1WLB+b91onFhWC8Xr/Bk1znlMOVdxinGhnQdAcnEKFdwGB8GnCwOe6c 2p2YGf9dTFqeJP7Q5GwaByvKsgR3OAhIB9jSgtUUZ74UhaAzeSVipsz5Fcetf1vWkOlb jvkjD4qQQdQsef3zz4MyTtUGeOcKVTivcQmew4prPysWeiKsU5IYFBkyi22OhMzSRriY 2RFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739263864; x=1739868664; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yDX88l6a351yJl4J67+MLD3V7wGrx+WJItQnoPZae5s=; b=Qp/GGvt1QSgtjiraicpJLNjH/rew/mQKTn28GE1kt5xjODov4UlNAHSzLOiC3o8f3T RQ4dytzB/RQLMfghX8awjCi+ViGEzxbWiok8XIAMNWtmxGfPkSG+ODgnZ7wK9nxzyH0H DU37cqzEaTNJIes0i38q+JMiSuCoyHDRBQXixe31/XA0i+Fmy293P23d5ETXObc/sIJ/ x1QVWL8KwAfOgtQ7VqeOA7ELaE61mYq2e+1PTzbtIx3EOR1UFqf2LTxt7iDlJnq4Xwo0 B6Uh4bTGCSQNVIwK5she+fCy6dJKknCxSLAYoy6WMJ6dmaxS0xveE0PEKGfn0lAJkuC8 sRGQ== X-Forwarded-Encrypted: i=1; AJvYcCWKSPxZIEzkNm/XLGSolcEtDg3w/oVTb8/ReXQyNdDliNJK0hM6/twYl1wZUrRL4uYPPmY=@vger.kernel.org X-Gm-Message-State: AOJu0YzRZZiJSFl9X6c9sxDOn5gosY7+GN4oLBb5dATMAOowhzVbso7f 48gjSSvh7irPc168fFuLqEHAs3PyWQmK8jEX98e5GLNfVWYgSE0f X-Gm-Gg: ASbGncvClba7jwtnfc4HnjALOI38El9rcMggKsl1WtxJ7pQ8ARM8wKKnEjAIxSED/Vu apCCHc194kLQXXt93fpAFWzhtV15U/oYPWt19/EJtbxxfna/r6s/YsLOWgF+s8gRmzDlr1dJwdc EYpDlkVqpenMjNMk1gECSW3RP6ZoNFXVnTVJvao7HBCy/VZ9cuCoTEJ+w8th98qSCuzl0k4VVIS sq2sbstIGLq9UHjx70qFeIQSiXfSlN85hobpzEI+u+TbfHFEM9VDm5sjZXjTNQJe8N1awoDioHv tlRI0r2O/vxlS8C7mh6dK0kNPSGZhr5/UKd/aj0= X-Google-Smtp-Source: AGHT+IGtztw2BiPIDW6cnXq6xkfl6L7Z8UhhhYhU+uoTm8dgJibI3vSry5Y+/WcwDk0CEhxwNJhT2w== X-Received: by 2002:a17:90b:1d52:b0:2ee:aa28:79aa with SMTP id 98e67ed59e1d1-2fa23f423e4mr21066957a91.6.1739263864284; Tue, 11 Feb 2025 00:51:04 -0800 (PST) Received: from gamma.hsd1.ca.comcast.net ([2601:647:5580:5760:3858:1e16:caad:e1d4]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fa09a46534sm10201701a91.21.2025.02.11.00.51.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2025 00:51:03 -0800 (PST) From: Illia Bobyr To: Junio C Hamano Cc: Illia Bobyr , git@vger.kernel.org Subject: [PATCH v4 10/10] diff: docs: Use --patch-{grep,modifies} over -G/-S Date: Tue, 11 Feb 2025 00:50:22 -0800 Message-ID: <20250211085028.3923875-11-illia.bobyr@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250206014324.1839232-1-illia.bobyr@gmail.com> References: <20250206014324.1839232-1-illia.bobyr@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Long argument names are easier to read, compared to short ones. So while short arguments are great when you want to type a command quickly, the documentation readability is improved if we use long argument names. Note for reviewers: All changes are just a replacement of `-G` with `--patch-grep` and `-S` with `--patch-modifies`. But as the text was reformatted to fit the same width in a few places it might look like there are more changes, if the diff is only line-wise and not word-wise. The only an exception are changes in `gitdiffcore.adoc`, where I did rephrase a sentence. I've moved introduction of the short versions of the `--patch-{grep,modifies}` into a subsequent paragraph. The reason is that I wanted to keep a note on the `-G` mnemonic, and it was awkward if I would repeat the short definition twice over a span of two paragraphs. --- Documentation/diff-options.adoc | 34 ++++++++++---------- Documentation/git-blame.adoc | 2 +- Documentation/gitdiffcore.adoc | 55 +++++++++++++++++---------------- 3 files changed, 46 insertions(+), 45 deletions(-) diff --git a/Documentation/diff-options.adoc b/Documentation/diff-options.adoc index 07413d..c9f7c 100644 --- a/Documentation/diff-options.adoc +++ b/Documentation/diff-options.adoc @@ -658,8 +658,8 @@ renamed entries cannot appear if detection for those types is disabled. It is useful when you're looking for an exact block of code (like a struct), and want to know the history of that block since it first came into being: use the feature iteratively to feed the interesting -block in the preimage back into `-S`, and keep going until you get the -very first version of the block. +block in the preimage back into `--patch-modifies`, and keep going until +you get the very first version of the block. + Binary files are searched as well. @@ -668,9 +668,9 @@ Binary files are searched as well. Look for differences whose patch text contains added/removed lines that match __. + -To illustrate the difference between `-S` `--pickaxe-regex` and -`-G`, consider a commit with the following diff in the same -file: +To illustrate the difference between `--patch-modifies= +--pickaxe-regex` and `--patch-grep=`, consider a commit with the +following diff in the same file: + ---- + return frotz(nitfol, two->ptr, 1, 0); @@ -678,9 +678,9 @@ file: - hit = frotz(nitfol, mf2.ptr, 1, 0); ---- + -While `git log -G"frotz\(nitfol"` will show this commit, `git log --S"frotz\(nitfol" --pickaxe-regex` will not (because the number of -occurrences of that string did not change). +While `git log --patch-grep="frotz\(nitfol"` will show this commit, `git +log --patch-modifies="frotz\(nitfol" --pickaxe-regex` will not (because the +number of occurrences of that string did not change). + Unless `--text` is supplied patches of binary files without a textconv filter will be ignored. @@ -689,22 +689,22 @@ See the 'pickaxe' entry in linkgit:gitdiffcore[7] for more information. `--find-object=`:: - Look for differences that change the number of occurrences of - the specified object. Similar to `-S`, just the argument is different - in that it doesn't search for a specific string but for a specific - object id. + Look for differences that change the number of occurrences of the + specified object. Similar to `--patch-modifies`, just the argument + is different in that it doesn't search for a specific string but + for a specific object id. + The object can be a blob or a submodule commit. It implies the `-t` option in `git-log` to also find trees. `--pickaxe-all`:: - When `-S` or `-G` finds a change, show all the changes in that - changeset, not just the files that contain the change - in __. + When `--patch-modifies` or `--patch-grep` finds a change, show all + the changes in that changeset, not just the files that contain the + change in __. `--pickaxe-regex`:: - Treat the __ given to `-S` as an extended POSIX regular - expression to match. + Treat the __ given to `--patch-modifies` as an extended + POSIX regular expression to match. endif::git-format-patch[] diff --git a/Documentation/git-blame.adoc b/Documentation/git-blame.adoc index f75ed..10736a 100644 --- a/Documentation/git-blame.adoc +++ b/Documentation/git-blame.adoc @@ -41,7 +41,7 @@ a text string in the diff. A small example of the pickaxe interface that searches for `blame_usage`: ----------------------------------------------------------------------------- -$ git log --pretty=oneline -S'blame_usage' +$ git log --pretty=oneline --patch-modifies='blame_usage' 5040f17eba15504bad66b14a645bddd9b015ebb7 blame -S ea4c7f9bf69e781dd0cd88d2bccb2bf5cc15c9a7 git-blame: Make the output ----------------------------------------------------------------------------- diff --git a/Documentation/gitdiffcore.adoc b/Documentation/gitdiffcore.adoc index e934b9..e7f98 100644 --- a/Documentation/gitdiffcore.adoc +++ b/Documentation/gitdiffcore.adoc @@ -245,33 +245,34 @@ diffcore-pickaxe: For Detecting Addition/Deletion of Specified String This transformation limits the set of filepairs to those that change specified strings between the preimage and the postimage in a certain -way. `--patch-modifies=` (`-S` for short) and -`--patch-grep=` (`-G` for short) are used to specify -different ways these strings are sought. - -`-S` detects filepairs whose preimage and postimage -have different number of occurrences of the specified __. -By definition, it will not detect in-file moves. Also, when a -changeset moves a file wholesale without affecting the interesting -string, diffcore-rename kicks in as usual, and `-S` omits the filepair -(since the number of occurrences of that string didn't change in that -rename-detected filepair). When used with `--pickaxe-regex`, treat -the __ as an extended POSIX regular expression to match, -instead of a literal string. - -`-G` (mnemonic: grep) detects filepairs whose textual diff has -an added or a deleted line that matches the given __. This -means that it will detect in-file (or what rename-detection considers -the same file) moves, which is noise. The implementation runs diff -twice and greps, and this can be quite expensive. To speed things up, -binary files without textconv filters will be ignored. - -When `-S` or `-G` are used without `--pickaxe-all`, only filepairs -that match their respective criterion are kept in the output. When -`--pickaxe-all` is used, if even one filepair matches their respective -criterion in a changeset, the entire changeset is kept. This behavior -is designed to make reviewing changes in the context of the whole -changeset easier. +way. `--patch-modifies=` and `--patch-grep=` are used +to specify different ways these strings are sought. + +`--patch-modifies=` (`-S` for short) detects filepairs +whose preimage and postimage have different number of occurrences of +the specified __. By definition, it will not detect in-file +moves. Also, when a changeset moves a file wholesale without +affecting the interesting string, diffcore-rename kicks in as usual, +and `--patch-modifies` omits the filepair (since the number of +occurrences of that string didn't change in that rename-detected +filepair). When used with `--pickaxe-regex`, treat the __ as +an extended POSIX regular expression to match, instead of a literal +string. + +`--patch-grep=` (`-G` for short, mnemonic: grep) detects +filepairs whose textual diff has an added or a deleted line that +matches the given regular expression. This means that it will detect +in-file (or what rename-detection considers the same file) moves, +which is noise. The implementation runs diff twice and greps, and +this can be quite expensive. To speed things up, binary files without +textconv filters will be ignored. + +When `--patch-modifies` or `--patch-grep` are used without +`--pickaxe-all`, only filepairs that match their respective criterion +are kept in the output. When `--pickaxe-all` is used, if even one +filepair matches their respective criterion in a changeset, the entire +changeset is kept. This behavior is designed to make reviewing +changes in the context of the whole changeset easier. diffcore-order: For Sorting the Output Based on Filenames ---------------------------------------------------------