git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	pawel.sikora@agmk.net, Jens.Lehmann@web.de,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH v2 3/9] Rename match_pathspec_depth() to match_pathspec()
Date: Fri, 24 Jan 2014 20:40:30 +0700	[thread overview]
Message-ID: <1390570836-20394-4-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1390570836-20394-1-git-send-email-pclouds@gmail.com>

A long time ago, for some reason I was not happy with
match_pathspec(). I created a better version, match_pathspec_depth()
that was suppose to replace match_pathspec()
eventually. match_pathspec() has finally been gone since 6 months
ago. Use the shorter name for match_pathspec_depth().

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/clean.c           |  4 ++--
 builtin/ls-files.c        |  6 ++++--
 builtin/ls-tree.c         |  2 +-
 dir.c                     | 20 ++++++++++----------
 dir.h                     | 10 +++++-----
 rerere.c                  |  4 ++--
 t/t6131-pathspec-icase.sh |  6 +++---
 7 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/builtin/clean.c b/builtin/clean.c
index 2f26297..f59c753 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -961,8 +961,8 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
 			die_errno("Cannot lstat '%s'", ent->name);
 
 		if (pathspec.nr)
-			matches = match_pathspec_depth(&pathspec, ent->name,
-						       len, 0, NULL);
+			matches = match_pathspec(&pathspec, ent->name,
+						 len, 0, NULL);
 
 		if (S_ISDIR(st.st_mode)) {
 			if (remove_directories || (matches == MATCHED_EXACTLY)) {
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index e238608..02db0e1 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -139,7 +139,8 @@ static void show_ce_entry(const char *tag, const struct cache_entry *ce)
 	if (len >= ce_namelen(ce))
 		die("git ls-files: internal error - cache entry not superset of prefix");
 
-	if (!match_pathspec_depth(&pathspec, ce->name, ce_namelen(ce), len, ps_matched))
+	if (!match_pathspec(&pathspec, ce->name, ce_namelen(ce),
+			    len, ps_matched))
 		return;
 
 	if (tag && *tag && show_valid_bit &&
@@ -195,7 +196,8 @@ static void show_ru_info(void)
 		len = strlen(path);
 		if (len < max_prefix_len)
 			continue; /* outside of the prefix */
-		if (!match_pathspec_depth(&pathspec, path, len, max_prefix_len, ps_matched))
+		if (!match_pathspec(&pathspec, path, len,
+				    max_prefix_len, ps_matched))
 			continue; /* uninterested */
 		for (i = 0; i < 3; i++) {
 			if (!ui->mode[i])
diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c
index 65ec931..51184df 100644
--- a/builtin/ls-tree.c
+++ b/builtin/ls-tree.c
@@ -171,7 +171,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
 	 * show_recursive() rolls its own matching code and is
 	 * generally ignorant of 'struct pathspec'. The magic mask
 	 * cannot be lifted until it is converted to use
-	 * match_pathspec_depth() or tree_entry_interesting()
+	 * match_pathspec() or tree_entry_interesting()
 	 */
 	parse_pathspec(&pathspec, PATHSPEC_GLOB | PATHSPEC_ICASE,
 		       PATHSPEC_PREFER_CWD,
diff --git a/dir.c b/dir.c
index d10a63f..8960ea1 100644
--- a/dir.c
+++ b/dir.c
@@ -218,7 +218,7 @@ static int match_pathspec_item(const struct pathspec_item *item, int prefix,
 	 * The normal call pattern is:
 	 * 1. prefix = common_prefix_len(ps);
 	 * 2. prune something, or fill_directory
-	 * 3. match_pathspec_depth()
+	 * 3. match_pathspec()
 	 *
 	 * 'prefix' at #1 may be shorter than the command's prefix and
 	 * it's ok for #2 to match extra files. Those extras will be
@@ -282,10 +282,10 @@ static int match_pathspec_item(const struct pathspec_item *item, int prefix,
  * pathspec did not match any names, which could indicate that the
  * user mistyped the nth pathspec.
  */
-static int match_pathspec_depth_1(const struct pathspec *ps,
-				  const char *name, int namelen,
-				  int prefix, char *seen,
-				  int exclude)
+static int do_match_pathspec(const struct pathspec *ps,
+			     const char *name, int namelen,
+			     int prefix, char *seen,
+			     int exclude)
 {
 	int i, retval = 0;
 
@@ -350,15 +350,15 @@ static int match_pathspec_depth_1(const struct pathspec *ps,
 	return retval;
 }
 
-int match_pathspec_depth(const struct pathspec *ps,
-			 const char *name, int namelen,
-			 int prefix, char *seen)
+int match_pathspec(const struct pathspec *ps,
+		   const char *name, int namelen,
+		   int prefix, char *seen)
 {
 	int positive, negative;
-	positive = match_pathspec_depth_1(ps, name, namelen, prefix, seen, 0);
+	positive = do_match_pathspec(ps, name, namelen, prefix, seen, 0);
 	if (!(ps->magic & PATHSPEC_EXCLUDE) || !positive)
 		return positive;
-	negative = match_pathspec_depth_1(ps, name, namelen, prefix, seen, 1);
+	negative = do_match_pathspec(ps, name, namelen, prefix, seen, 1);
 	return negative ? 0 : positive;
 }
 
diff --git a/dir.h b/dir.h
index 65f54b6..c31ed9a 100644
--- a/dir.h
+++ b/dir.h
@@ -132,9 +132,9 @@ struct dir_struct {
 extern int simple_length(const char *match);
 extern int no_wildcard(const char *string);
 extern char *common_prefix(const struct pathspec *pathspec);
-extern int match_pathspec_depth(const struct pathspec *pathspec,
-				const char *name, int namelen,
-				int prefix, char *seen);
+extern int match_pathspec(const struct pathspec *pathspec,
+			  const char *name, int namelen,
+			  int prefix, char *seen);
 extern int within_depth(const char *name, int namelen, int depth, int max_depth);
 
 extern int fill_directory(struct dir_struct *dir, const struct pathspec *pathspec);
@@ -209,14 +209,14 @@ static inline int ce_path_match(const struct cache_entry *ce,
 				const struct pathspec *pathspec,
 				char *seen)
 {
-	return match_pathspec_depth(pathspec, ce->name, ce_namelen(ce), 0, seen);
+	return match_pathspec(pathspec, ce->name, ce_namelen(ce), 0, seen);
 }
 
 static inline int dir_path_match(const struct dir_entry *ent,
 				 const struct pathspec *pathspec,
 				 int prefix, char *seen)
 {
-	return match_pathspec_depth(pathspec, ent->name, ent->len, prefix, seen);
+	return match_pathspec(pathspec, ent->name, ent->len, prefix, seen);
 }
 
 #endif
diff --git a/rerere.c b/rerere.c
index 1f2d21a..34a21c4 100644
--- a/rerere.c
+++ b/rerere.c
@@ -672,8 +672,8 @@ int rerere_forget(struct pathspec *pathspec)
 	find_conflict(&conflict);
 	for (i = 0; i < conflict.nr; i++) {
 		struct string_list_item *it = &conflict.items[i];
-		if (!match_pathspec_depth(pathspec, it->string, strlen(it->string),
-					  0, NULL))
+		if (!match_pathspec(pathspec, it->string,
+				    strlen(it->string), 0, NULL))
 			continue;
 		rerere_forget_one_path(it->string, &merge_rr);
 	}
diff --git a/t/t6131-pathspec-icase.sh b/t/t6131-pathspec-icase.sh
index a7c7ff5..39fc3f6 100755
--- a/t/t6131-pathspec-icase.sh
+++ b/t/t6131-pathspec-icase.sh
@@ -69,7 +69,7 @@ test_expect_success 'tree_entry_interesting matches :(icase)bar with empty prefi
 	test_cmp expect actual
 '
 
-test_expect_success 'match_pathspec_depth matches :(icase)bar' '
+test_expect_success 'match_pathspec matches :(icase)bar' '
 	cat <<-EOF >expect &&
 	BAR
 	bAr
@@ -79,7 +79,7 @@ test_expect_success 'match_pathspec_depth matches :(icase)bar' '
 	test_cmp expect actual
 '
 
-test_expect_success 'match_pathspec_depth matches :(icase)bar with prefix' '
+test_expect_success 'match_pathspec matches :(icase)bar with prefix' '
 	cat <<-EOF >expect &&
 	fOo/BAR
 	fOo/bAr
@@ -89,7 +89,7 @@ test_expect_success 'match_pathspec_depth matches :(icase)bar with prefix' '
 	test_cmp expect actual
 '
 
-test_expect_success 'match_pathspec_depth matches :(icase)bar with empty prefix' '
+test_expect_success 'match_pathspec matches :(icase)bar with empty prefix' '
 	cat <<-EOF >expect &&
 	bar
 	fOo/BAR
-- 
1.8.5.2.240.g8478abd

  parent reply	other threads:[~2014-01-24 13:35 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-20 18:25 problematic git log submodule-dir/ Paweł Sikora
2014-01-22 20:35 ` Jens Lehmann
2014-01-22 23:56   ` Duy Nguyen
2014-01-23 13:22 ` [PATCH 1/2] tree-walk.c: ignore trailing slash on submodule in tree_entry_interesting() Nguyễn Thái Ngọc Duy
2014-01-23 13:22   ` [PATCH 2/2] t4010: match_pathspec_depth() and trailing slash after submodule Nguyễn Thái Ngọc Duy
2014-01-23 21:09     ` Junio C Hamano
2014-01-23 21:25       ` Jens Lehmann
2014-01-23 21:38         ` Junio C Hamano
2014-01-24  5:48           ` Duy Nguyen
2014-01-24 13:40   ` [PATCH v2 0/9] About the trailing slashes Nguyễn Thái Ngọc Duy
2014-01-24 13:40     ` [PATCH v2 1/9] Convert some match_pathspec_depth() to ce_path_match() Nguyễn Thái Ngọc Duy
2014-01-24 13:40     ` [PATCH v2 2/9] Convert some match_pathspec_depth() to dir_path_match() Nguyễn Thái Ngọc Duy
2014-01-24 13:40     ` Nguyễn Thái Ngọc Duy [this message]
2014-01-24 13:40     ` [PATCH v2 4/9] dir.c: prepare match_pathspec_item for taking more flags Nguyễn Thái Ngọc Duy
2014-01-24 13:40     ` [PATCH v2 5/9] match_pathspec: match pathspec "foo/" against directory "foo" Nguyễn Thái Ngọc Duy
2014-01-24 13:40     ` [PATCH v2 6/9] Pass directory indicator to match_pathspec_item() Nguyễn Thái Ngọc Duy
2014-01-24 21:22       ` Eric Sunshine
2014-01-25  4:24         ` Duy Nguyen
2014-01-24 13:40     ` [PATCH v2 7/9] clean: replace match_pathspec() with dir_path_match() Nguyễn Thái Ngọc Duy
2014-01-24 13:40     ` [PATCH v2 8/9] clean: use cache_name_is_other() Nguyễn Thái Ngọc Duy
2014-01-24 13:40     ` [PATCH v2 9/9] tree-walk.c: ignore trailing slash on submodule in tree_entry_interesting() Nguyễn Thái Ngọc Duy
2014-01-24 19:22     ` [PATCH v2 0/9] About the trailing slashes Junio C Hamano
2014-01-25  1:14       ` Duy Nguyen
2014-01-27 22:47     ` 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

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

  git send-email \
    --in-reply-to=1390570836-20394-4-git-send-email-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=Jens.Lehmann@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pawel.sikora@agmk.net \
    /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.
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 NNTP newsgroup(s).