Submodules: Don't parse .gitmodules when it contains, merge conflicts

Commands like "git status", "git diff" and "git fetch" would fail when the
.gitmodules file contained merge conflicts because the config parser would
call die() when hitting the conflict markers:

    "fatal: bad config file line <n> in <path>/.gitmodules"

While this behavior was on the safe side, it is really unhelpful to the
user to have commands like status and diff fail, as these are needed to
find out what's going on. And the error message is only mildly helpful,
as it points to the right file but doesn't mention that it is unmerged.
Users of git gui were not shown any conflicts at all when this happened.

Improve the situation by checking if the index records .gitmodules as
unmerged. When that is the case we can't make any assumptions about the
configuration to be found there after the merge conflict is resolved by
the user, so assume that all recursion is disabled unless .git/config or
the global config say otherwise.

As soon as the merge conflict is resolved and the .gitmodules file has
been staged subsequent commands again honor any configuration done there.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jens Lehmann
2011-05-14 18:26:58 +02:00
committed by Junio C Hamano
parent 44ca0c8ed9
commit d4e98b581b
2 changed files with 32 additions and 5 deletions

View File

@ -196,7 +196,7 @@ AA .gitmodules
A sub1
EOF
test_expect_failure 'status with merge conflict in .gitmodules' '
test_expect_success 'status with merge conflict in .gitmodules' '
git clone . super &&
test_create_repo_with_commit sub1 &&
test_tick &&
@ -255,7 +255,7 @@ index badaa4c,44f999a..0000000
++>>>>>>> add_sub1
EOF
test_expect_failure 'diff with merge conflict in .gitmodules' '
test_expect_success 'diff with merge conflict in .gitmodules' '
(
cd super &&
git diff >../diff_actual 2>&1
@ -263,7 +263,7 @@ test_expect_failure 'diff with merge conflict in .gitmodules' '
test_cmp diff_actual diff_expect
'
test_expect_failure 'diff --submodule with merge conflict in .gitmodules' '
test_expect_success 'diff --submodule with merge conflict in .gitmodules' '
(
cd super &&
git diff --submodule >../diff_submodule_actual 2>&1