path: root/diff-lib.c
diff options
authorJens Lehmann <>2010-03-12 21:23:52 (GMT)
committerJunio C Hamano <>2010-03-13 06:17:24 (GMT)
commit85adbf2f751a91429de6b431c45737ba9d7e9e00 (patch)
tree26535fe961ff33d741746167c8fd6f851a0bd8a4 /diff-lib.c
parentae6d5c1b6f78ef48f606e5a267915fa31b37a679 (diff)
git status: Fix false positive "new commits" output for dirty submodules
Testing if the output "new commits" should appear in the long format of "git status" is done by comparing the hashes of the diffpair. This always resulted in printing "new commits" for submodules that contained untracked or modified content, even if they did not contain new commits. The reason was that match_stat_with_submodule() did set the "changed" flag for dirty submodules, resulting in two->sha1 being set to the null_sha1 at the call sites, which indicates that new commits are present. This is changed so that when no new commits are present, the same object names are in the sha1 field for both sides of the filepair, and the working tree side will have the "dirty_submodule" flag set when appropriate. For a submodule to be seen as modified even when it just has a dirty work tree, some conditions had to be extended to also check for the "dirty_submodule" flag. Unfortunately the test case that should have found this bug had been changed incorrectly too. It is fixed and extended to test for other combinations too. Signed-off-by: Jens Lehmann <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'diff-lib.c')
1 files changed, 2 insertions, 4 deletions
diff --git a/diff-lib.c b/diff-lib.c
index ea9cf56..87a2591 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -72,8 +72,6 @@ static int match_stat_with_submodule(struct diff_options *diffopt,
&& (!changed || DIFF_OPT_TST(diffopt, DIRTY_SUBMODULES))) {
*dirty_submodule = is_submodule_modified(ce->name);
- if (*dirty_submodule)
- changed = 1;
return changed;
@@ -202,7 +200,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
changed = match_stat_with_submodule(&revs->diffopt, ce, &st,
ce_option, &dirty_submodule);
- if (!changed) {
+ if (!changed && !dirty_submodule) {
if (!DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))
@@ -333,7 +331,7 @@ static int show_modified(struct rev_info *revs,
oldmode = old->ce_mode;
- if (mode == oldmode && !hashcmp(sha1, old->sha1) &&
+ if (mode == oldmode && !hashcmp(sha1, old->sha1) && !dirty_submodule &&
return 0;