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,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Junio C Hamano <gitster@pobox.com>
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [RFC PATCH v3 5/8] dir.c: export excluded_1() and add_excludes_from_file_1()
Date: Tue, 11 Aug 2009 22:44:03 +0700	[thread overview]
Message-ID: <1250005446-12047-6-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1250005446-12047-5-git-send-email-pclouds@gmail.com>

These functions are used to handle .gitignore. They are now exported
so that sparse checkout can reuse.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 dir.c |   32 ++++++++++++++++----------------
 dir.h |    4 ++++
 2 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/dir.c b/dir.c
index c990938..bc35586 100644
--- a/dir.c
+++ b/dir.c
@@ -224,12 +224,12 @@ static void *read_assume_unchanged_from_index(const char *path, size_t *size)
 	return data;
 }
 
-static int add_excludes_from_file_1(const char *fname,
-				    const char *base,
-				    int baselen,
-				    char **buf_p,
-				    struct exclude_list *which,
-				    int check_index)
+int add_excludes_from_file_to_list(const char *fname,
+				   const char *base,
+				   int baselen,
+				   char **buf_p,
+				   struct exclude_list *which,
+				   int check_index)
 {
 	struct stat st;
 	int fd, i;
@@ -275,8 +275,8 @@ static int add_excludes_from_file_1(const char *fname,
 
 void add_excludes_from_file(struct dir_struct *dir, const char *fname)
 {
-	if (add_excludes_from_file_1(fname, "", 0, NULL,
-				     &dir->exclude_list[EXC_FILE], 0) < 0)
+	if (add_excludes_from_file_to_list(fname, "", 0, NULL,
+					   &dir->exclude_list[EXC_FILE], 0) < 0)
 		die("cannot use %s as an exclude file", fname);
 }
 
@@ -325,9 +325,9 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen)
 		memcpy(dir->basebuf + current, base + current,
 		       stk->baselen - current);
 		strcpy(dir->basebuf + stk->baselen, dir->exclude_per_dir);
-		add_excludes_from_file_1(dir->basebuf,
-					 dir->basebuf, stk->baselen,
-					 &stk->filebuf, el, 1);
+		add_excludes_from_file_to_list(dir->basebuf,
+					       dir->basebuf, stk->baselen,
+					       &stk->filebuf, el, 1);
 		dir->exclude_stack = stk;
 		current = stk->baselen;
 	}
@@ -337,9 +337,9 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen)
 /* Scan the list and let the last match determine the fate.
  * Return 1 for exclude, 0 for include and -1 for undecided.
  */
-static int excluded_1(const char *pathname,
-		      int pathlen, const char *basename, int *dtype,
-		      struct exclude_list *el)
+int excluded_from_list(const char *pathname,
+		       int pathlen, const char *basename, int *dtype,
+		       struct exclude_list *el)
 {
 	int i;
 
@@ -413,8 +413,8 @@ int excluded(struct dir_struct *dir, const char *pathname, int *dtype_p)
 
 	prep_exclude(dir, pathname, basename-pathname);
 	for (st = EXC_CMDL; st <= EXC_FILE; st++) {
-		switch (excluded_1(pathname, pathlen, basename,
-				   dtype_p, &dir->exclude_list[st])) {
+		switch (excluded_from_list(pathname, pathlen, basename,
+					   dtype_p, &dir->exclude_list[st])) {
 		case 0:
 			return 0;
 		case 1:
diff --git a/dir.h b/dir.h
index a631446..472e11e 100644
--- a/dir.h
+++ b/dir.h
@@ -69,7 +69,11 @@ extern int match_pathspec(const char **pathspec, const char *name, int namelen,
 extern int fill_directory(struct dir_struct *dir, const char **pathspec);
 extern int read_directory(struct dir_struct *, const char *path, int len, const char **pathspec);
 
+extern int excluded_from_list(const char *pathname, int pathlen, const char *basename,
+			      int *dtype, struct exclude_list *el);
 extern int excluded(struct dir_struct *, const char *, int *);
+extern int add_excludes_from_file_to_list(const char *fname, const char *base, int baselen,
+					  char **buf_p, struct exclude_list *which, int check_index);
 extern void add_excludes_from_file(struct dir_struct *, const char *fname);
 extern void add_exclude(const char *string, const char *base,
 			int baselen, struct exclude_list *which);
-- 
1.6.3.GIT

  reply	other threads:[~2009-08-11 15:44 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-11 15:43 [RFC PATCH v3 0/8] Sparse checkout Nguyễn Thái Ngọc Duy
2009-08-11 15:43 ` [RFC PATCH v3 1/8] Prevent diff machinery from examining assume-unchanged entries on worktree Nguyễn Thái Ngọc Duy
2009-08-11 15:44   ` [RFC PATCH v3 2/8] Avoid writing to buffer in add_excludes_from_file_1() Nguyễn Thái Ngọc Duy
2009-08-11 15:44     ` [RFC PATCH v3 3/8] Read .gitignore from index if it is assume-unchanged Nguyễn Thái Ngọc Duy
2009-08-11 15:44       ` [RFC PATCH v3 4/8] excluded_1(): support exclude "directories" in index Nguyễn Thái Ngọc Duy
2009-08-11 15:44         ` Nguyễn Thái Ngọc Duy [this message]
2009-08-11 15:44           ` [RFC PATCH v3 6/8] unpack-trees.c: generalize verify_* functions Nguyễn Thái Ngọc Duy
2009-08-11 15:44             ` [RFC PATCH v3 7/8] Support sparse checkout in unpack_trees() and read-tree Nguyễn Thái Ngọc Duy
2009-08-11 15:44               ` [RFC PATCH v3 8/8] --sparse for porcelains Nguyễn Thái Ngọc Duy
2009-08-12  6:33                 ` Junio C Hamano
2009-08-12 10:01                   ` Nguyen Thai Ngoc Duy
2009-08-13  7:20                   ` Nguyen Thai Ngoc Duy
2009-08-13  9:58                     ` Jakub Narebski
2009-08-13 12:38                       ` Nguyen Thai Ngoc Duy
2009-08-14 20:23                         ` Jakub Narebski
2009-08-15  2:01                           ` Junio C Hamano
2009-08-15 23:37                             ` Jakub Narebski
2009-08-16  8:14                               ` Johannes Schindelin
2009-08-17  9:08                                 ` Johannes Schindelin
2009-08-17 12:49                                   ` Nguyen Thai Ngoc Duy
2009-08-17 13:35                                     ` Johannes Schindelin
2009-08-17 14:41                                       ` Nguyen Thai Ngoc Duy
2009-08-17 15:19                                         ` Johannes Schindelin
2009-08-17 16:13                                           ` Nguyen Thai Ngoc Duy
2009-08-17 15:41                                   ` Junio C Hamano
2009-08-17 16:06                                     ` Nguyen Thai Ngoc Duy
2009-08-17 16:19                                     ` Johannes Schindelin
2009-08-17 18:39                                       ` Junio C Hamano
2009-08-17 22:02                                         ` Johannes Schindelin
2009-08-17 23:02                                           ` skillzero
2009-08-17 23:16                                             ` Johannes Schindelin
2009-08-18  0:17                                               ` Jakub Narebski
2009-08-18  0:34                                                 ` skillzero
2009-08-18  1:43                                                   ` Nguyen Thai Ngoc Duy
2009-08-18  6:25                                                     ` git find (was: [RFC PATCH v3 8/8] --sparse for porcelains) Jakub Narebski
2009-08-18 14:35                                                       ` Nguyen Thai Ngoc Duy
2009-08-18 16:00                                                         ` Jakub Narebski
2009-08-18  0:49                                                 ` [RFC PATCH v3 8/8] --sparse for porcelains Jakub Narebski
2009-08-18  0:23                                               ` skillzero
2009-08-17 16:46                                     ` Junio C Hamano
2009-08-17 21:45                                       ` Johannes Schindelin
2009-08-17 16:01                                 ` Jakub Narebski
2009-08-12  7:31                 ` Johannes Sixt
2009-08-12  9:53                   ` Nguyen Thai Ngoc Duy
2009-08-12 15:40                     ` Raja R Harinath
2009-08-13  7:37                       ` Johannes Sixt
2009-08-11 21:18               ` [RFC PATCH v3 7/8] Support sparse checkout in unpack_trees() and read-tree skillzero
2009-08-11 21:38                 ` Jakub Narebski
2009-08-11 22:03                   ` skillzero
2009-08-12  1:30                     ` Nguyen Thai Ngoc Duy
2009-08-12  4:59                       ` skillzero
2009-08-12  2:51       ` [RFC PATCH v3 3/8] Read .gitignore from index if it is assume-unchanged Junio C Hamano
2009-08-13  6:37         ` Nguyen Thai Ngoc Duy

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=1250005446-12047-6-git-send-email-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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.
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).