mirror of
https://github.com/git/git.git
synced 2024-12-12 03:14:11 +08:00
diff: report dirty submodules as changes in builtin_diff()
The diff machinery has two ways to detect changes to set the exit code:
Just comparing hashes and comparing blob contents. The latter is needed
if certain changes have to be ignored, e.g. with --ignore-space-change
or --ignore-matching-lines. It's enabled by the diff_options flag
diff_from_contents.
The slower mode as never considered submodules (and subrepos) as changes
with --submodule=diff or --submodule=log, which is inconsistent with
--submodule=short (the default). Fix it.
d7b97b7185
(diff: let external diffs report that changes are
uninteresting, 2024-06-09) set diff_from_contents if external diff
programs are allowed. This is the default e.g. for git diff, and so
that change exposed the inconsistency much more widely.
Reported-by: David Hull <david.hull@friendbuy.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
87cf96094a
commit
11591850dd
2
diff.c
2
diff.c
@ -3565,6 +3565,7 @@ static void builtin_diff(const char *name_a,
|
||||
show_submodule_diff_summary(o, one->path ? one->path : two->path,
|
||||
&one->oid, &two->oid,
|
||||
two->dirty_submodule);
|
||||
o->found_changes = 1;
|
||||
return;
|
||||
} else if (o->submodule_format == DIFF_SUBMODULE_INLINE_DIFF &&
|
||||
(!one->mode || S_ISGITLINK(one->mode)) &&
|
||||
@ -3573,6 +3574,7 @@ static void builtin_diff(const char *name_a,
|
||||
show_submodule_inline_diff(o, one->path ? one->path : two->path,
|
||||
&one->oid, &two->oid,
|
||||
two->dirty_submodule);
|
||||
o->found_changes = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -159,4 +159,25 @@ do
|
||||
"
|
||||
done
|
||||
|
||||
test_expect_success 'setup dirty subrepo' '
|
||||
git reset --hard &&
|
||||
test_create_repo subrepo &&
|
||||
test_commit -C subrepo subrepo-file &&
|
||||
test_tick &&
|
||||
git add subrepo &&
|
||||
git commit -m subrepo &&
|
||||
test_commit -C subrepo another-subrepo-file
|
||||
'
|
||||
|
||||
for option in --exit-code --quiet
|
||||
do
|
||||
for submodule_format in diff log short
|
||||
do
|
||||
opts="$option --submodule=$submodule_format" &&
|
||||
test_expect_success "git diff $opts returns 1 for dirty subrepo" "
|
||||
test_expect_code 1 git diff $opts
|
||||
"
|
||||
done
|
||||
done
|
||||
|
||||
test_done
|
||||
|
Loading…
Reference in New Issue
Block a user