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

[PATCH v2 2/6] Case insensitivity support for .gitignore via core.ignorecase

From
Joshua Jensen <jjensen@workspacewhiz.com>
Date
Oct 3, 2010, 04:32 UTC
Message-ID
<20101003043234.1960.12596.stgit@SlamDunk>
In-Reply-To
<20101003043221.1960.73178.stgit@SlamDunk>

This is especially beneficial when using Windows and Perforce and the git-p4 bridge. Internally, Perforce preserves a given file's full path including its case at the time it was added to the Perforce repository. When syncing a file down via Perforce, missing directories are created, if necessary, using the case as stored with the filename. Unfortunately, two files in the same directory can have differing cases for their respective paths, such as /diRa/file1.c and /DirA/file2.c. Depending on sync order, DirA/ may get created instead of diRa/.

It is possible to handle directory names in a case insensitive manner without this patch, but it is highly inconvenient, requiring each character to be specified like so: [Bb][Uu][Ii][Ll][Dd]. With this patch, the gitignore exclusions honor the core.ignorecase=true configuration setting and make the process less error prone. The above is specified like so: Build

Signed-off-by: Joshua Jensen <jjensen@workspacewhiz.com>
---
 dir.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/dir.c b/dir.c
index ffa410d..63d7b41 100644
--- a/dir.c
+++ b/dir.c
@@ -436,14 +436,14 @@ int excluded_from_list(const char *pathname,
 			if (x->flags & EXC_FLAG_NODIR) {
 				/* match basename */
 				if (x->flags & EXC_FLAG_NOWILDCARD) {
-					if (!strcmp(exclude, basename))
+					if (!strcmp_icase(exclude, basename))
 						return to_exclude;
 				} else if (x->flags & EXC_FLAG_ENDSWITH) {
 					if (x->patternlen - 1 <= pathlen &&
-					    !strcmp(exclude + 1, pathname + pathlen - x->patternlen + 1))
+					    !strcmp_icase(exclude + 1, pathname + pathlen - x->patternlen + 1))
 						return to_exclude;
 				} else {
-					if (fnmatch(exclude, basename, 0) == 0)
+					if (fnmatch_icase(exclude, basename, 0) == 0)
 						return to_exclude;
 				}
 			}
@@ -458,14 +458,14 @@ int excluded_from_list(const char *pathname,
 
 				if (pathlen < baselen ||
 				    (baselen && pathname[baselen-1] != '/') ||
-				    strncmp(pathname, x->base, baselen))
+				    strncmp_icase(pathname, x->base, baselen))
 				    continue;
 
 				if (x->flags & EXC_FLAG_NOWILDCARD) {
-					if (!strcmp(exclude, pathname + baselen))
+					if (!strcmp_icase(exclude, pathname + baselen))
 						return to_exclude;
 				} else {
-					if (fnmatch(exclude, pathname+baselen,
+					if (fnmatch_icase(exclude, pathname+baselen,
 						    FNM_PATHNAME) == 0)
 					    return to_exclude;
 				}
Previous: Joshua JensenNext: Joshua Jensen
Message 34 of 45 in “Extensions of core.ignorecase=true support”
  1. 0/6 Extensions of core.ignorecase=true supportJoshua Jensen, Oct 3, 2010
  2. 1/6 Add string comparison functions that respect the ignore_case variable.Joshua Jensen, Oct 3, 2010
  3. Ævar Arnfjörð BjarmasonOct 3, 2010
  4. Joshua JensenOct 3, 2010
  5. 0/8 ab/icase-directory: jj/icase-directory with Makefile + configure checksÆvar Arnfjörð Bjarmason, Oct 3, 2010
  6. 1/8 Makefile & configure: add a NO_FNMATCH flagÆvar Arnfjörð Bjarmason, Oct 3, 2010
  7. 2/8 Makefile & configure: add a NO_FNMATCH_CASEFOLD flagÆvar Arnfjörð Bjarmason, Oct 3, 2010
  8. Johannes SixtOct 3, 2010
  9. 2/8 Makefile & configure: add a NO_FNMATCH_CASEFOLD flagÆvar Arnfjörð Bjarmason, Oct 4, 2010
  10. 3/8 Add string comparison functions that respect the ignore_case variable.Ævar Arnfjörð Bjarmason, Oct 3, 2010
  11. 4/8 Case insensitivity support for .gitignore via core.ignorecaseÆvar Arnfjörð Bjarmason, Oct 3, 2010
  12. 5/8 Add case insensitivity support for directories when using git statusÆvar Arnfjörð Bjarmason, Oct 3, 2010
  13. 6/8 Add case insensitivity support when using git ls-filesÆvar Arnfjörð Bjarmason, Oct 3, 2010
  14. Thomas AdamOct 3, 2010
  15. Johannes SixtOct 3, 2010
  16. Thomas AdamOct 3, 2010
  17. Jonathan NiederOct 4, 2010
  18. Ævar Arnfjörð BjarmasonOct 4, 2010
  19. Erik Faye-LundOct 4, 2010
  20. Joshua JensenOct 4, 2010
  21. Jonathan NiederOct 4, 2010
  22. Robin RosenbergOct 4, 2010
  23. Ævar Arnfjörð BjarmasonOct 4, 2010
  24. Erik Faye-LundOct 4, 2010
  25. Joshua JensenOct 4, 2010
  26. Jonathan NiederOct 4, 2010
  27. Ævar Arnfjörð BjarmasonOct 4, 2010
  28. Johannes SixtOct 4, 2010
  29. Ævar Arnfjörð BjarmasonOct 4, 2010
  30. 7/8 Support case folding for git add when core.ignorecase=trueÆvar Arnfjörð Bjarmason, Oct 3, 2010
  31. 8/8 Support case folding in git fast-import when core.ignorecase=trueÆvar Arnfjörð Bjarmason, Oct 3, 2010
  32. Junio C HamanoOct 7, 2010
  33. Joshua JensenOct 7, 2010
  34. 2/6 Case insensitivity support for .gitignore via core.ignorecaseJoshua Jensen, Oct 3, 2010
  35. 3/6 Add case insensitivity support for directories when using git statusJoshua Jensen, Oct 3, 2010
  36. 4/6 Add case insensitivity support when using git ls-filesJoshua Jensen, Oct 3, 2010
  37. 5/6 Support case folding for git add when core.ignorecase=trueJoshua Jensen, Oct 3, 2010
  38. 6/6 Support case folding in git fast-import when core.ignorecase=trueJoshua Jensen, Oct 3, 2010
  39. Sverre RabbelierOct 3, 2010
  40. Johannes SixtOct 3, 2010
  41. Junio C HamanoOct 3, 2010
  42. Robert BuckOct 3, 2010
  43. Johannes SixtOct 3, 2010
  44. Robert BuckOct 6, 2010
  45. Joshua JensenOct 6, 2010

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.