git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re* [PATCH 0/5] diff --ignore-case

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 21, 2012, 09:02 UTC
Message-ID
<7vwr7gh83t.fsf_-_@alter.siamese.dyndns.org>
In-Reply-To
<7vvcn1l21d.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 18 quoted lines
> Thomas Rast <trast@inf.ethz.ch> writes:
>
>> I wonder which one of us misunderstood the original request ;-)
>
> Heh, I did ;-)
>
>> It was
>>
>> } Is there any way to run diff -G with a case insensitivity flag?
>>
>> and I took that to mean "I want to find addition/removal of a string
>> like -G does, but I don't know how it was capitalized".
>
> I think it is just the matter of checking REG_ICASE that may be set in
> revs->grep_filter.regflags, and propagating it down to the regcomp at the
> beginning of diffcore_pickaxe_grep().
>
> Want to try and see how well it works?
The gist of the patch should look like this.

Even though I haven't done anything more than just to compile and run "git log -p -i -G search 233054d", it looks obviously correct ;-)

Note that this does not depend on any of the "diff --ignore-case" topic, and it may conflict with [PATCH 6/5]. Among the two "else if" that flips the REG_ICASE in revision.c, it needs to be decided if only one of them, or both of them should set the new option. I haven't thought things through to decide which.

 diff.h             |    1 +
 diffcore-pickaxe.c |    6 +++++-
 revision.c         |    1 +
 3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/diff.h b/diff.h
index 7af5f1e..182cb0e 100644
--- a/diff.h
+++ b/diff.h
@@ -82,6 +82,7 @@ typedef struct strbuf *(*diff_prefix_fn_t)(struct diff_options *opt, void *data)
 #define DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG (1 << 27)
 #define DIFF_OPT_DIRSTAT_BY_LINE     (1 << 28)
 #define DIFF_OPT_FUNCCONTEXT         (1 << 29)
+#define DIFF_OPT_PICKAXE_IGNORE_CASE (1 << 30)
 
 #define DIFF_OPT_TST(opts, flag)    ((opts)->flags & DIFF_OPT_##flag)
 #define DIFF_OPT_SET(opts, flag)    ((opts)->flags |= DIFF_OPT_##flag)
diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c
index 380a837..8ffb741 100644
--- a/diffcore-pickaxe.c
+++ b/diffcore-pickaxe.c
@@ -138,8 +138,12 @@ static void diffcore_pickaxe_grep(struct diff_options *o)
 {
 	int err;
 	regex_t regex;
+	int cflags = REG_EXTENDED | REG_NEWLINE;
 
-	err = regcomp(&regex, o->pickaxe, REG_EXTENDED | REG_NEWLINE);
+	if (DIFF_OPT_TST(o, PICKAXE_IGNORE_CASE))
+		cflags |= REG_ICASE;
+
+	err = regcomp(&regex, o->pickaxe, cflags);
 	if (err) {
 		char errbuf[1024];
 		regerror(err, &regex, errbuf, 1024);
diff --git a/revision.c b/revision.c
index 819ff01..b3554ed 100644
--- a/revision.c
+++ b/revision.c
@@ -1582,6 +1582,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
 		revs->grep_filter.regflags |= REG_EXTENDED;
 	} else if (!strcmp(arg, "--regexp-ignore-case") || !strcmp(arg, "-i")) {
 		revs->grep_filter.regflags |= REG_ICASE;
+		DIFF_OPT_SET(&revs->diffopt, PICKAXE_IGNORE_CASE);
 	} else if (!strcmp(arg, "--fixed-strings") || !strcmp(arg, "-F")) {
 		revs->grep_filter.fixed = 1;
 	} else if (!strcmp(arg, "--all-match")) {
Previous: Chris Leong
Message 14 of 14 in “diff --ignore-case”
  1. 0/5 diff --ignore-caseJunio C Hamano, Feb 20, 2012
  2. 1/5 xdiff: remove XDL_PATCH_* macrosJunio C Hamano, Feb 20, 2012
  3. 2/5 xdiff: PATIENCE/HISTOGRAM are not independent option bitsJunio C Hamano, Feb 20, 2012
  4. 3/5 xdiff: introduce XDF_INEXACT_MATCHJunio C Hamano, Feb 20, 2012
  5. 4/5 xdiff: introduce XDF_IGNORE_CASEJunio C Hamano, Feb 20, 2012
  6. Jakub NarebskiFeb 22, 2012
  7. 5/5 diff: --ignore-caseJunio C Hamano, Feb 20, 2012
  8. 6/5 diff -iJunio C Hamano, Feb 20, 2012
  9. Johannes SixtFeb 20, 2012
  10. Junio C HamanoFeb 20, 2012
  11. Thomas RastFeb 20, 2012
  12. Junio C HamanoFeb 20, 2012
  13. Chris LeongFeb 20, 2012
  14. Re* [PATCH 0/5] diff --ignore-caseJunio C Hamano, Feb 21, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.