mergetool: honor diff.orderFile
Teach mergetool to get the list of files to edit via `diff` so that we gain support for diff.orderFile. Suggested-by: Luis Gutierrez <luisgutz@gmail.com> Helped-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: David Aguilar <davvid@gmail.com> Reviewed-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
08221e3fa2
commit
57937f70a0
@ -79,6 +79,11 @@ success of the resolution after the custom tool has exited.
|
|||||||
Prompt before each invocation of the merge resolution program
|
Prompt before each invocation of the merge resolution program
|
||||||
to give the user a chance to skip the path.
|
to give the user a chance to skip the path.
|
||||||
|
|
||||||
|
DIFF ORDER FILES
|
||||||
|
----------------
|
||||||
|
`git mergetool` honors the `diff.orderFile` configuration variable
|
||||||
|
used by `git diff`. See linkgit:git-config[1] for more details.
|
||||||
|
|
||||||
TEMPORARY FILES
|
TEMPORARY FILES
|
||||||
---------------
|
---------------
|
||||||
`git mergetool` creates `*.orig` backup files while resolving merges.
|
`git mergetool` creates `*.orig` backup files while resolving merges.
|
||||||
|
@ -382,6 +382,11 @@ prompt_after_failed_merge () {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print_noop_and_exit () {
|
||||||
|
echo "No files need merging"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
main () {
|
main () {
|
||||||
prompt=$(git config --bool mergetool.prompt)
|
prompt=$(git config --bool mergetool.prompt)
|
||||||
guessed_merge_tool=false
|
guessed_merge_tool=false
|
||||||
@ -445,28 +450,23 @@ main () {
|
|||||||
merge_keep_backup="$(git config --bool mergetool.keepBackup || echo true)"
|
merge_keep_backup="$(git config --bool mergetool.keepBackup || echo true)"
|
||||||
merge_keep_temporaries="$(git config --bool mergetool.keepTemporaries || echo false)"
|
merge_keep_temporaries="$(git config --bool mergetool.keepTemporaries || echo false)"
|
||||||
|
|
||||||
files=
|
if test $# -eq 0 && test -e "$GIT_DIR/MERGE_RR"
|
||||||
|
|
||||||
if test $# -eq 0
|
|
||||||
then
|
then
|
||||||
cd_to_toplevel
|
set -- $(git rerere remaining)
|
||||||
|
if test $# -eq 0
|
||||||
if test -e "$GIT_DIR/MERGE_RR"
|
|
||||||
then
|
then
|
||||||
files=$(git rerere remaining)
|
print_noop_and_exit
|
||||||
else
|
|
||||||
files=$(git ls-files -u |
|
|
||||||
sed -e 's/^[^ ]* //' | sort -u)
|
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
files=$(git ls-files -u -- "$@" |
|
|
||||||
sed -e 's/^[^ ]* //' | sort -u)
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
files=$(git -c core.quotePath=false \
|
||||||
|
diff --name-only --diff-filter=U -- "$@")
|
||||||
|
|
||||||
|
cd_to_toplevel
|
||||||
|
|
||||||
if test -z "$files"
|
if test -z "$files"
|
||||||
then
|
then
|
||||||
echo "No files need merging"
|
print_noop_and_exit
|
||||||
exit 0
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "Merging:\n"
|
printf "Merging:\n"
|
||||||
|
@ -606,4 +606,37 @@ test_expect_success MKTEMP 'temporary filenames are used with mergetool.writeToT
|
|||||||
git reset --hard master >/dev/null 2>&1
|
git reset --hard master >/dev/null 2>&1
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'diff.orderFile configuration is honored' '
|
||||||
|
test_config diff.orderFile order-file &&
|
||||||
|
test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
|
||||||
|
test_config mergetool.myecho.trustExitCode true &&
|
||||||
|
echo b >order-file &&
|
||||||
|
echo a >>order-file &&
|
||||||
|
git checkout -b order-file-start master &&
|
||||||
|
echo start >a &&
|
||||||
|
echo start >b &&
|
||||||
|
git add a b &&
|
||||||
|
git commit -m start &&
|
||||||
|
git checkout -b order-file-side1 order-file-start &&
|
||||||
|
echo side1 >a &&
|
||||||
|
echo side1 >b &&
|
||||||
|
git add a b &&
|
||||||
|
git commit -m side1 &&
|
||||||
|
git checkout -b order-file-side2 order-file-start &&
|
||||||
|
echo side2 >a &&
|
||||||
|
echo side2 >b &&
|
||||||
|
git add a b &&
|
||||||
|
git commit -m side2 &&
|
||||||
|
test_must_fail git merge order-file-side1 &&
|
||||||
|
cat >expect <<-\EOF &&
|
||||||
|
Merging:
|
||||||
|
b
|
||||||
|
a
|
||||||
|
EOF
|
||||||
|
git mergetool --no-prompt --tool myecho >output &&
|
||||||
|
git grep --no-index -h -A2 Merging: output >actual &&
|
||||||
|
test_cmp expect actual &&
|
||||||
|
git reset --hard >/dev/null
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user