summaryrefslogtreecommitdiff
path: root/src/status.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-06-13 15:30:26 -0700
committerRussell Belfer <rb@github.com>2013-06-17 10:03:49 -0700
commit3a68d7f00289afbaa415c3b34d5eeca183dcfb52 (patch)
tree34e0cc61ac4ce3806dccb66f55df310ebee3e864 /src/status.c
parent4e28e638ea016f5a5b35ba952d9f06a1108d6b5e (diff)
downloadlibgit2-3a68d7f00289afbaa415c3b34d5eeca183dcfb52.tar.gz
Fix broken status EXCLUDE_SUBMODULES logic
The exclude submodules flag was not doing the right thing, in that a file with no diff between the head and the index and just a delete in the workdir could be excluded if submodules were excluded.
Diffstat (limited to 'src/status.c')
-rw-r--r--src/status.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/status.c b/src/status.c
index 20e45b75f..ba4eef895 100644
--- a/src/status.c
+++ b/src/status.c
@@ -81,23 +81,33 @@ static unsigned int workdir_delta2status(git_delta_t workdir_status)
}
static bool status_is_included(
- git_status_list *statuslist,
+ git_status_list *status,
git_diff_delta *head2idx,
git_diff_delta *idx2wd)
{
+ if (!(status->opts.flags & GIT_STATUS_OPT_EXCLUDE_SUBMODULES))
+ return 1;
+
/* if excluding submodules and this is a submodule everywhere */
- if ((statuslist->opts.flags & GIT_STATUS_OPT_EXCLUDE_SUBMODULES) != 0) {
- bool in_tree = (head2idx && head2idx->status != GIT_DELTA_ADDED);
- bool in_index = (head2idx && head2idx->status != GIT_DELTA_DELETED);
- bool in_wd = (idx2wd && idx2wd->status != GIT_DELTA_DELETED);
-
- if ((!in_tree || head2idx->old_file.mode == GIT_FILEMODE_COMMIT) &&
- (!in_index || head2idx->new_file.mode == GIT_FILEMODE_COMMIT) &&
- (!in_wd || idx2wd->new_file.mode == GIT_FILEMODE_COMMIT))
- return 0;
+ if (head2idx) {
+ if (head2idx->status != GIT_DELTA_ADDED &&
+ head2idx->old_file.mode != GIT_FILEMODE_COMMIT)
+ return 1;
+ if (head2idx->status != GIT_DELTA_DELETED &&
+ head2idx->new_file.mode != GIT_FILEMODE_COMMIT)
+ return 1;
+ }
+ if (idx2wd) {
+ if (idx2wd->status != GIT_DELTA_ADDED &&
+ idx2wd->old_file.mode != GIT_FILEMODE_COMMIT)
+ return 1;
+ if (idx2wd->status != GIT_DELTA_DELETED &&
+ idx2wd->new_file.mode != GIT_FILEMODE_COMMIT)
+ return 1;
}
- return 1;
+ /* only get here if every valid mode is GIT_FILEMODE_COMMIT */
+ return 0;
}
static git_status_t status_compute(