diff options
author | Kyle Meyer <kyle@kyleam.com> | 2019-04-09 19:07:36 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-04-10 12:52:49 +0900 |
commit | b22827045e0b6c2ae1b12be2820cdc4b7f750895 (patch) | |
tree | b213f3cfb5da9c1c97489256ece8cfc44aed92c1 /t/t7411-submodule-config.sh | |
parent | submodule: refuse to add repository with no commits (diff) | |
download | tgif-b22827045e0b6c2ae1b12be2820cdc4b7f750895.tar.xz |
dir: do not traverse repositories with no commits
When treat_directory() encounters a directory that is not in the index
and DIR_NO_GITLINKS is unset, it calls resolve_gitlink_ref() to decide
if a directory looks like a repository, in which case the directory
won't be traversed. As a result, 'status -uall' and 'ls-files -o'
will show only the directory, even when there are untracked files
within the directory.
For the unusual case where a repository doesn't have a commit checked
out, resolve_gitlink_ref() returns -1 because HEAD cannot be resolved,
and the directory is treated as a normal directory (i.e. traversal
does not stop at the repository boundary). The status and ls-files
commands above list untracked files within the repository rather than
showing only the top-level directory. And if 'git add' is called on a
repository with no commit checked out, any untracked files under the
repository are added as blobs in the top-level project, a behavior
that is unlikely to be what the caller intended.
The above case is a corner case in an already unusual situation of the
working tree containing a repository that is not a tracked submodule,
but we might as well treat anything that looks like a repository
consistently. Loosen the "looks like a repository" criteria in
treat_directory() by replacing resolve_gitlink_ref() with
is_nonbare_repository_dir(), one of the checks that is performed
downstream when resolve_gitlink_ref() is called.
As the required update to t3700-add shows, calling 'git add' on a
repository with no commit checked out will now raise an error. While
this is the desired behavior, note that the output isn't yet
appropriate. The next commit will improve this output.
Signed-off-by: Kyle Meyer <kyle@kyleam.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7411-submodule-config.sh')
0 files changed, 0 insertions, 0 deletions