summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2019-12-19 21:28:26 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-12-19 21:45:47 (GMT)
commitc847dfafeee8b0fe3e053ac307de88e04d1ad072 (patch)
tree0e87a5f3e0b804c7f3c2aa9bbdeb4af485570bea /dir.c
parent777b420347649f26022bb1a4bf7afe7c4fe0b090 (diff)
downloadgit-c847dfafeee8b0fe3e053ac307de88e04d1ad072.zip
git-c847dfafeee8b0fe3e053ac307de88e04d1ad072.tar.gz
git-c847dfafeee8b0fe3e053ac307de88e04d1ad072.tar.bz2
dir: consolidate similar code in treat_directory()
Both the DIR_SKIP_NESTED_GIT and DIR_NO_GITLINKS cases were checking for whether a path was actually a nonbare repository. That code could be shared, with just the result of how to act differing between the two cases. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/dir.c b/dir.c
index 357f959..e1b74f6 100644
--- a/dir.c
+++ b/dir.c
@@ -1461,6 +1461,8 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
const char *dirname, int len, int baselen, int exclude,
const struct pathspec *pathspec)
{
+ int nested_repo = 0;
+
/* The "len-1" is to strip the final '/' */
switch (directory_exists_in_index(istate, dirname, len-1)) {
case index_directory:
@@ -1470,15 +1472,16 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
return path_none;
case index_nonexistent:
- if (dir->flags & DIR_SKIP_NESTED_GIT) {
- int nested_repo;
+ if ((dir->flags & DIR_SKIP_NESTED_GIT) ||
+ !(dir->flags & DIR_NO_GITLINKS)) {
struct strbuf sb = STRBUF_INIT;
strbuf_addstr(&sb, dirname);
nested_repo = is_nonbare_repository_dir(&sb);
strbuf_release(&sb);
- if (nested_repo)
- return path_none;
}
+ if (nested_repo)
+ return ((dir->flags & DIR_SKIP_NESTED_GIT) ? path_none :
+ (exclude ? path_excluded : path_untracked));
if (dir->flags & DIR_SHOW_OTHER_DIRECTORIES)
break;
@@ -1506,13 +1509,6 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
return path_none;
}
- if (!(dir->flags & DIR_NO_GITLINKS)) {
- struct strbuf sb = STRBUF_INIT;
- strbuf_addstr(&sb, dirname);
- if (is_nonbare_repository_dir(&sb))
- return exclude ? path_excluded : path_untracked;
- strbuf_release(&sb);
- }
return path_recurse;
}