Browse Source

Merge branch 'en/dir-nonbare-embedded'

"ls-files -o" mishandled the top-level directory of another git
working tree that hangs in the current git working tree.

* en/dir-nonbare-embedded:
  dir: avoid prematurely marking nonbare repositories as matches
  t3000: fix some test description typos
maint
Junio C Hamano 5 years ago
parent
commit
11f433f79c
  1. 9
      dir.c
  2. 24
      t/t3000-ls-files-others.sh

9
dir.c

@ -1792,9 +1792,12 @@ static enum path_treatment treat_directory(struct dir_struct *dir, @@ -1792,9 +1792,12 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
nested_repo = is_nonbare_repository_dir(&sb);
strbuf_release(&sb);
}
if (nested_repo)
return ((dir->flags & DIR_SKIP_NESTED_GIT) ? path_none :
(excluded ? path_excluded : path_untracked));
if (nested_repo) {
if ((dir->flags & DIR_SKIP_NESTED_GIT) ||
(matches_how == MATCHED_RECURSIVELY_LEADING_PATHSPEC))
return path_none;
return excluded ? path_excluded : path_untracked;
}

if (!(dir->flags & DIR_SHOW_OTHER_DIRECTORIES)) {
if (excluded &&

24
t/t3000-ls-files-others.sh

@ -152,7 +152,7 @@ test_expect_success 'ls-files -o --directory with mix dir/file pathspecs' ' @@ -152,7 +152,7 @@ test_expect_success 'ls-files -o --directory with mix dir/file pathspecs' '
)
'

test_expect_success 'ls-files --o --directory with glob filetype match' '
test_expect_success 'ls-files -o --directory with glob filetype match' '
(
cd nested &&

@ -168,7 +168,7 @@ test_expect_success 'ls-files --o --directory with glob filetype match' ' @@ -168,7 +168,7 @@ test_expect_success 'ls-files --o --directory with glob filetype match' '
)
'

test_expect_success 'ls-files --o --directory with mix of tracked states' '
test_expect_success 'ls-files -o --directory with mix of tracked states' '
(
cd nested &&

@ -184,7 +184,7 @@ test_expect_success 'ls-files --o --directory with mix of tracked states' ' @@ -184,7 +184,7 @@ test_expect_success 'ls-files --o --directory with mix of tracked states' '
)
'

test_expect_success 'ls-files --o --directory with glob filetype match only' '
test_expect_success 'ls-files -o --directory with glob filetype match only' '
(
cd nested &&

@ -198,7 +198,7 @@ test_expect_success 'ls-files --o --directory with glob filetype match only' ' @@ -198,7 +198,7 @@ test_expect_success 'ls-files --o --directory with glob filetype match only' '
)
'

test_expect_success 'ls-files --o --directory to get immediate paths under one dir only' '
test_expect_success 'ls-files -o --directory to get immediate paths under one dir only' '
(
cd nested &&

@ -212,4 +212,20 @@ test_expect_success 'ls-files --o --directory to get immediate paths under one d @@ -212,4 +212,20 @@ test_expect_success 'ls-files --o --directory to get immediate paths under one d
)
'

test_expect_success 'ls-files -o avoids listing untracked non-matching gitdir' '
test_when_finished "rm -rf nested/untracked/deep/empty" &&
(
cd nested &&

git init untracked/deep/empty &&
git ls-files --others "untracked/*.c" >actual &&

cat <<-EOF >expect &&
untracked/deep/foo.c
EOF

test_cmp expect actual
)
'

test_done

Loading…
Cancel
Save