Skip to content

Commit 6f3a0b6

Browse files
committed
Merge branch 'bw/submodule-config-cleanup'
Recent update to the submodule configuration code broke "diff-tree" by accidentally stopping to read from the index upfront. * bw/submodule-config-cleanup: diff-tree: read the index so attribute checks work in bare repositories
2 parents a328b2c + fd66bcc commit 6f3a0b6

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

builtin/diff-tree.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
110110

111111
git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
112112
init_revisions(opt, prefix);
113+
if (read_cache() < 0)
114+
die(_("index file corrupt"));
113115
opt->abbrev = 0;
114116
opt->diff = 1;
115117
opt->disable_stdin = 1;

t/t4015-diff-whitespace.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,23 @@ test_expect_success 'check with space before tab in indent (diff-tree)' '
636636
test_must_fail git diff-tree --check HEAD^ HEAD
637637
'
638638

639+
test_expect_success 'check with ignored trailing whitespace attr (diff-tree)' '
640+
test_when_finished "git reset --hard HEAD^" &&
641+
642+
# create a whitespace error that should be ignored
643+
echo "* -whitespace" >.gitattributes &&
644+
git add .gitattributes &&
645+
echo "foo(); " >x &&
646+
git add x &&
647+
git commit -m "add trailing space" &&
648+
649+
# with a worktree diff-tree ignores the whitespace error
650+
git diff-tree --root --check HEAD &&
651+
652+
# without a worktree diff-tree still ignores the whitespace error
653+
git -C .git diff-tree --root --check HEAD
654+
'
655+
639656
test_expect_success 'check trailing whitespace (trailing-space: off)' '
640657
git config core.whitespace "-trailing-space" &&
641658
echo "foo (); " >x &&

0 commit comments

Comments
 (0)