From: "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: blees@dcon.de, gitster@pobox.com, kyle@kyleam.com,
sxlijin@gmail.com, Junio C Hamano <gitster@pobox.com>,
Elijah Newren <newren@gmail.com>
Subject: [PATCH v5 5/8] dir: break part of read_directory_recursive() out for reuse
Date: Thu, 19 Dec 2019 21:28:23 +0000 [thread overview]
Message-ID: <d2f5623bd71352f3adbf12f211dbae5820b33666.1576790906.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.676.v5.git.git.1576790906.gitgitgadget@gmail.com>
From: Elijah Newren <newren@gmail.com>
Create an add_path_to_appropriate_result_list() function from the code
at the end of read_directory_recursive() so we can use it elsewhere.
Signed-off-by: Elijah Newren <newren@gmail.com>
---
dir.c | 60 ++++++++++++++++++++++++++++++++++++-----------------------
1 file changed, 37 insertions(+), 23 deletions(-)
diff --git a/dir.c b/dir.c
index 517a569e10..645b44ea64 100644
--- a/dir.c
+++ b/dir.c
@@ -1932,6 +1932,40 @@ static void close_cached_dir(struct cached_dir *cdir)
}
}
+static void add_path_to_appropriate_result_list(struct dir_struct *dir,
+ struct untracked_cache_dir *untracked,
+ struct cached_dir *cdir,
+ struct index_state *istate,
+ struct strbuf *path,
+ int baselen,
+ const struct pathspec *pathspec,
+ enum path_treatment state)
+{
+ /* add the path to the appropriate result list */
+ switch (state) {
+ case path_excluded:
+ if (dir->flags & DIR_SHOW_IGNORED)
+ dir_add_name(dir, istate, path->buf, path->len);
+ else if ((dir->flags & DIR_SHOW_IGNORED_TOO) ||
+ ((dir->flags & DIR_COLLECT_IGNORED) &&
+ exclude_matches_pathspec(path->buf, path->len,
+ pathspec)))
+ dir_add_ignored(dir, istate, path->buf, path->len);
+ break;
+
+ case path_untracked:
+ if (dir->flags & DIR_SHOW_IGNORED)
+ break;
+ dir_add_name(dir, istate, path->buf, path->len);
+ if (cdir->fdir)
+ add_untracked(untracked, path->buf + baselen);
+ break;
+
+ default:
+ break;
+ }
+}
+
/*
* Read a directory tree. We currently ignore anything but
* directories, regular files and symlinks. That's because git
@@ -2035,29 +2069,9 @@ static enum path_treatment read_directory_recursive(struct dir_struct *dir,
continue;
}
- /* add the path to the appropriate result list */
- switch (state) {
- case path_excluded:
- if (dir->flags & DIR_SHOW_IGNORED)
- dir_add_name(dir, istate, path.buf, path.len);
- else if ((dir->flags & DIR_SHOW_IGNORED_TOO) ||
- ((dir->flags & DIR_COLLECT_IGNORED) &&
- exclude_matches_pathspec(path.buf, path.len,
- pathspec)))
- dir_add_ignored(dir, istate, path.buf, path.len);
- break;
-
- case path_untracked:
- if (dir->flags & DIR_SHOW_IGNORED)
- break;
- dir_add_name(dir, istate, path.buf, path.len);
- if (cdir.fdir)
- add_untracked(untracked, path.buf + baselen);
- break;
-
- default:
- break;
- }
+ add_path_to_appropriate_result_list(dir, untracked, &cdir,
+ istate, &path, baselen,
+ pathspec, state);
}
close_cached_dir(&cdir);
out:
--
gitgitgadget
next prev parent reply other threads:[~2019-12-19 21:28 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-09 20:47 [PATCH 0/8] Directory traversal bugs Elijah Newren via GitGitGadget
2019-12-09 20:47 ` [PATCH 1/8] t3011: demonstrate directory traversal failures Elijah Newren via GitGitGadget
2019-12-09 21:06 ` Denton Liu
2019-12-09 20:47 ` [PATCH 2/8] Revert "dir.c: make 'git-status --ignored' work within leading directories" Elijah Newren via GitGitGadget
2019-12-09 21:32 ` Denton Liu
2019-12-09 21:51 ` Elijah Newren
2019-12-09 22:09 ` Eric Sunshine
2019-12-09 20:47 ` [PATCH 3/8] dir: remove stray quote character in comment Elijah Newren via GitGitGadget
2019-12-09 20:47 ` [PATCH 4/8] dir: exit before wildcard fall-through if there is no wildcard Elijah Newren via GitGitGadget
2019-12-09 20:47 ` [PATCH 5/8] dir: break part of read_directory_recursive() out for reuse Elijah Newren via GitGitGadget
2019-12-09 20:47 ` [PATCH 6/8] dir: fix checks on common prefix directory Elijah Newren via GitGitGadget
2019-12-09 20:47 ` [PATCH 7/8] dir: synchronize treat_leading_path() and read_directory_recursive() Elijah Newren via GitGitGadget
2019-12-09 20:47 ` [PATCH 8/8] dir: consolidate similar code in treat_directory() Elijah Newren via GitGitGadget
2019-12-10 20:00 ` [PATCH v2 0/8] Directory traversal bugs Elijah Newren via GitGitGadget
2019-12-10 20:00 ` [PATCH v2 1/8] t3011: demonstrate directory traversal failures Elijah Newren via GitGitGadget
2019-12-10 20:00 ` [PATCH v2 2/8] Revert "dir.c: make 'git-status --ignored' work within leading directories" Elijah Newren via GitGitGadget
2019-12-10 20:00 ` [PATCH v2 3/8] dir: remove stray quote character in comment Elijah Newren via GitGitGadget
2019-12-10 20:00 ` [PATCH v2 4/8] dir: exit before wildcard fall-through if there is no wildcard Elijah Newren via GitGitGadget
2019-12-10 20:00 ` [PATCH v2 5/8] dir: break part of read_directory_recursive() out for reuse Elijah Newren via GitGitGadget
2019-12-10 20:00 ` [PATCH v2 6/8] dir: fix checks on common prefix directory Elijah Newren via GitGitGadget
2019-12-15 10:29 ` Johannes Schindelin
2019-12-16 13:51 ` Elijah Newren
2019-12-16 16:00 ` Elijah Newren
2019-12-16 18:13 ` Junio C Hamano
2019-12-16 21:08 ` Elijah Newren
2019-12-16 21:25 ` Junio C Hamano
2019-12-16 22:39 ` Elijah Newren
2019-12-17 0:04 ` Johannes Schindelin
2019-12-17 0:14 ` Junio C Hamano
2019-12-17 11:08 ` Johannes Schindelin
2019-12-17 17:33 ` Junio C Hamano
2019-12-17 19:32 ` Johannes Schindelin
2019-12-17 5:26 ` Elijah Newren
2019-12-17 11:15 ` Johannes Schindelin
2019-12-17 16:58 ` Elijah Newren
2019-12-10 20:00 ` [PATCH v2 7/8] dir: synchronize treat_leading_path() and read_directory_recursive() Elijah Newren via GitGitGadget
2019-12-10 20:00 ` [PATCH v2 8/8] dir: consolidate similar code in treat_directory() Elijah Newren via GitGitGadget
2019-12-17 8:33 ` [PATCH v3 0/3] Directory traversal bugs Elijah Newren via GitGitGadget
2019-12-17 8:33 ` [PATCH v3 1/3] t3011: demonstrate directory traversal failures Elijah Newren via GitGitGadget
2019-12-17 8:33 ` [PATCH v3 2/3] dir: remove stray quote character in comment Elijah Newren via GitGitGadget
2019-12-17 8:33 ` [PATCH v3 3/3] dir: exit before wildcard fall-through if there is no wildcard Elijah Newren via GitGitGadget
2019-12-17 11:18 ` [PATCH v3 0/3] Directory traversal bugs Johannes Schindelin
2019-12-17 18:24 ` Junio C Hamano
2019-12-21 22:05 ` Johannes Schindelin
2019-12-18 19:29 ` [PATCH v4 0/8] " Elijah Newren via GitGitGadget
2019-12-18 19:29 ` [PATCH v4 1/8] t3011: demonstrate directory traversal failures Elijah Newren via GitGitGadget
2019-12-18 19:29 ` [PATCH v4 2/8] Revert "dir.c: make 'git-status --ignored' work within leading directories" Elijah Newren via GitGitGadget
2019-12-18 19:29 ` [PATCH v4 3/8] dir: remove stray quote character in comment Elijah Newren via GitGitGadget
2019-12-18 19:29 ` [PATCH v4 4/8] dir: exit before wildcard fall-through if there is no wildcard Elijah Newren via GitGitGadget
2019-12-18 19:29 ` [PATCH v4 5/8] dir: break part of read_directory_recursive() out for reuse Elijah Newren via GitGitGadget
2019-12-18 19:29 ` [PATCH v4 6/8] dir: fix checks on common prefix directory Elijah Newren via GitGitGadget
2019-12-18 21:29 ` Junio C Hamano
2019-12-19 20:23 ` Elijah Newren
2019-12-19 22:24 ` Jeff King
2019-12-20 17:00 ` Elijah Newren
2019-12-20 21:14 ` Jeff King
2019-12-20 18:01 ` Junio C Hamano
2019-12-20 21:15 ` Jeff King
2019-12-18 19:29 ` [PATCH v4 7/8] dir: synchronize treat_leading_path() and read_directory_recursive() Elijah Newren via GitGitGadget
2019-12-18 19:29 ` [PATCH v4 8/8] dir: consolidate similar code in treat_directory() Elijah Newren via GitGitGadget
2019-12-19 21:28 ` [PATCH v5 0/8] Directory traversal bugs Elijah Newren via GitGitGadget
2019-12-19 21:28 ` [PATCH v5 1/8] t3011: demonstrate directory traversal failures Elijah Newren via GitGitGadget
2019-12-19 21:28 ` [PATCH v5 2/8] Revert "dir.c: make 'git-status --ignored' work within leading directories" Elijah Newren via GitGitGadget
2019-12-19 21:28 ` [PATCH v5 3/8] dir: remove stray quote character in comment Elijah Newren via GitGitGadget
2019-12-19 21:28 ` [PATCH v5 4/8] dir: exit before wildcard fall-through if there is no wildcard Elijah Newren via GitGitGadget
2019-12-19 21:28 ` Elijah Newren via GitGitGadget [this message]
2019-12-19 21:28 ` [PATCH v5 6/8] dir: fix checks on common prefix directory Elijah Newren via GitGitGadget
2019-12-19 21:28 ` [PATCH v5 7/8] dir: synchronize treat_leading_path() and read_directory_recursive() Elijah Newren via GitGitGadget
2019-12-19 21:28 ` [PATCH v5 8/8] dir: consolidate similar code in treat_directory() Elijah Newren via GitGitGadget
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=d2f5623bd71352f3adbf12f211dbae5820b33666.1576790906.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=blees@dcon.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=kyle@kyleam.com \
--cc=newren@gmail.com \
--cc=sxlijin@gmail.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).