git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Johannes Sixt <j6t@kdbg.org>
To: git@vger.kernel.org
Cc: Joshua Jensen <jjensen@workspacewhiz.com>, Johannes Sixt <j6t@kdbg.org>
Subject: [PATCH 2/6] Case insensitivity support for .gitignore via core.ignorecase
Date: Mon, 16 Aug 2010 21:38:10 +0200	[thread overview]
Message-ID: <0207df477b402bacf5792a6c9cb410e924501b27.1281985411.git.j6t@kdbg.org> (raw)
In-Reply-To: <cover.1281985411.git.j6t@kdbg.org>

From: Joshua Jensen <jjensen@workspacewhiz.com>

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>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 dir.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/dir.c b/dir.c
index 4d001fd..be21c20 100644
--- a/dir.c
+++ b/dir.c
@@ -390,14 +390,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;
 				}
 			}
@@ -412,14 +412,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;
 				}
-- 
1.7.1.402.gf1eeb

  parent reply	other threads:[~2010-08-16 19:39 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-16 19:38 [PATCH 0/6] Extensions of core.ignorecase=true support Johannes Sixt
2010-08-16 19:38 ` [PATCH 1/6] Add string comparison functions that respect the ignore_case variable Johannes Sixt
2010-08-18 12:52   ` Ævar Arnfjörð Bjarmason
2010-08-18 12:53     ` Ævar Arnfjörð Bjarmason
2010-08-18 15:52       ` Joshua Jensen
2010-08-18 16:07         ` Ævar Arnfjörð Bjarmason
2010-08-18 18:32           ` Johannes Sixt
2010-08-18 18:58             ` Ævar Arnfjörð Bjarmason
2010-08-29 19:39             ` Ævar Arnfjörð Bjarmason
2010-08-30 14:42               ` Joshua Jensen
2010-08-30 14:51                 ` Ævar Arnfjörð Bjarmason
2010-08-30 15:05                   ` Jonathan Nieder
2010-08-30 14:52                 ` Jonathan Nieder
2010-08-30 18:40                 ` Johannes Sixt
2010-08-30 19:57                   ` Ævar Arnfjörð Bjarmason
2010-08-30 20:13                     ` Johannes Sixt
2010-08-16 19:38 ` Johannes Sixt [this message]
2010-08-16 19:38 ` [PATCH 3/6] Add case insensitivity support for directories when using git status Johannes Sixt
2010-08-16 19:38 ` [PATCH 4/6] Add case insensitivity support when using git ls-files Johannes Sixt
2010-08-16 19:38 ` [PATCH 5/6] Support case folding for git add when core.ignorecase=true Johannes Sixt
2010-08-16 19:38 ` [PATCH 6/6] Support case folding in git fast-import " Johannes Sixt
2010-08-17 19:36 ` [PATCH 0/6] Extensions of core.ignorecase=true support Robert Buck
2010-08-17 21:20   ` Johannes Sixt
2010-08-18  2:41     ` Robert Buck
2010-08-18 18:31       ` Johannes Sixt
2010-08-22  7:23 ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0207df477b402bacf5792a6c9cb410e924501b27.1281985411.git.j6t@kdbg.org \
    --to=j6t@kdbg.org \
    --cc=git@vger.kernel.org \
    --cc=jjensen@workspacewhiz.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).