diff options
author | Russell Belfer <rb@github.com> | 2013-07-02 16:49:57 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-07-10 12:15:03 -0700 |
commit | 125655fe3f0caf8b3d9fff2ec45ec694b34eed04 (patch) | |
tree | 677bb10e844cc18726ae2720e49987bd7aedfef0 /src/diff.c | |
parent | 9564229af42b68d205376853410c55b957546a14 (diff) | |
download | libgit2-125655fe3f0caf8b3d9fff2ec45ec694b34eed04.tar.gz |
Untracked directories with .git should be ignored
This restores a behavior that was accidentally lost during some
diff refactoring where an untracked directory that contains a .git
item should be treated as IGNORED, not as UNTRACKED. The submodule
code already detects this, but the diff code was not handling the
scenario right.
This also updates a number of existing tests that were actually
exercising the behavior but did not have the right expectations in
place. It actually makes the new
`test_diff_submodules__diff_ignore_options` test feel much better
because the "not-a-submodule" entries are now ignored instead of
showing up as untracked items.
Fixes #1697
Diffstat (limited to 'src/diff.c')
-rw-r--r-- | src/diff.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/diff.c b/src/diff.c index 5fa635f05..e875d09b3 100644 --- a/src/diff.c +++ b/src/diff.c @@ -735,7 +735,7 @@ static int maybe_modified( /* if we got here and decided that the files are modified, but we * haven't calculated the OID of the new item, then calculate it now */ - if (status != GIT_DELTA_UNMODIFIED && git_oid_iszero(&nitem->oid)) { + if (status == GIT_DELTA_MODIFIED && git_oid_iszero(&nitem->oid)) { if (git_oid_iszero(&noid)) { if (git_diff__oid_for_file(diff->repo, nitem->path, nitem->mode, nitem->file_size, &noid) < 0) @@ -858,7 +858,7 @@ static int handle_unmatched_new_item( git_buf_clear(&info->ignore_prefix); } - if (S_ISDIR(nitem->mode)) { + if (nitem->mode == GIT_FILEMODE_TREE) { bool recurse_into_dir = contains_oitem; /* if not already inside an ignored dir, check if this is ignored */ @@ -962,6 +962,16 @@ static int handle_unmatched_new_item( else if (info->new_iter->type != GIT_ITERATOR_TYPE_WORKDIR) delta_type = GIT_DELTA_ADDED; + else if (nitem->mode == GIT_FILEMODE_COMMIT) { + git_submodule *sm; + + /* ignore things that are not actual submodules */ + if (git_submodule_lookup(&sm, info->repo, nitem->path) != 0) { + giterr_clear(); + delta_type = GIT_DELTA_IGNORED; + } + } + /* Actually create the record for this item if necessary */ if ((error = diff_delta__from_one(diff, delta_type, nitem)) < 0) return error; |