зеркало из https://github.com/microsoft/git.git
Merge branch 'rl/am-3way-config'
"git am" learned am.threeWay configuration variable. * rl/am-3way-config: git-am: add am.threeWay config variable t4150-am: refactor am -3 tests git-am.sh: fix initialization of the threeway variable
This commit is contained in:
Коммит
4b64c8a1ee
|
@ -769,6 +769,14 @@ am.keepcr::
|
||||||
by giving '--no-keep-cr' from the command line.
|
by giving '--no-keep-cr' from the command line.
|
||||||
See linkgit:git-am[1], linkgit:git-mailsplit[1].
|
See linkgit:git-am[1], linkgit:git-mailsplit[1].
|
||||||
|
|
||||||
|
am.threeWay::
|
||||||
|
By default, `git am` will fail if the patch does not apply cleanly. When
|
||||||
|
set to true, this setting tells `git am` to fall back on 3-way merge if
|
||||||
|
the patch records the identity of blobs it is supposed to apply to and
|
||||||
|
we have those blobs available locally (equivalent to giving the `--3way`
|
||||||
|
option from the command line). Defaults to `false`.
|
||||||
|
See linkgit:git-am[1].
|
||||||
|
|
||||||
apply.ignoreWhitespace::
|
apply.ignoreWhitespace::
|
||||||
When set to 'change', tells 'git apply' to ignore changes in
|
When set to 'change', tells 'git apply' to ignore changes in
|
||||||
whitespace, in the same way as the '--ignore-space-change'
|
whitespace, in the same way as the '--ignore-space-change'
|
||||||
|
|
|
@ -10,7 +10,7 @@ SYNOPSIS
|
||||||
--------
|
--------
|
||||||
[verse]
|
[verse]
|
||||||
'git am' [--signoff] [--keep] [--[no-]keep-cr] [--[no-]utf8]
|
'git am' [--signoff] [--keep] [--[no-]keep-cr] [--[no-]utf8]
|
||||||
[--3way] [--interactive] [--committer-date-is-author-date]
|
[--[no-]3way] [--interactive] [--committer-date-is-author-date]
|
||||||
[--ignore-date] [--ignore-space-change | --ignore-whitespace]
|
[--ignore-date] [--ignore-space-change | --ignore-whitespace]
|
||||||
[--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]
|
[--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]
|
||||||
[--exclude=<path>] [--include=<path>] [--reject] [-q | --quiet]
|
[--exclude=<path>] [--include=<path>] [--reject] [-q | --quiet]
|
||||||
|
@ -90,10 +90,13 @@ default. You can use `--no-utf8` to override this.
|
||||||
|
|
||||||
-3::
|
-3::
|
||||||
--3way::
|
--3way::
|
||||||
|
--no-3way::
|
||||||
When the patch does not apply cleanly, fall back on
|
When the patch does not apply cleanly, fall back on
|
||||||
3-way merge if the patch records the identity of blobs
|
3-way merge if the patch records the identity of blobs
|
||||||
it is supposed to apply to and we have those blobs
|
it is supposed to apply to and we have those blobs
|
||||||
available locally.
|
available locally. `--no-3way` can be used to override
|
||||||
|
am.threeWay configuration variable. For more information,
|
||||||
|
see am.threeWay in linkgit:git-config[1].
|
||||||
|
|
||||||
--ignore-space-change::
|
--ignore-space-change::
|
||||||
--ignore-whitespace::
|
--ignore-whitespace::
|
||||||
|
|
10
git-am.sh
10
git-am.sh
|
@ -378,6 +378,7 @@ committer_date_is_author_date=
|
||||||
ignore_date=
|
ignore_date=
|
||||||
allow_rerere_autoupdate=
|
allow_rerere_autoupdate=
|
||||||
gpg_sign_opt=
|
gpg_sign_opt=
|
||||||
|
threeway=
|
||||||
|
|
||||||
if test "$(git config --bool --get am.messageid)" = true
|
if test "$(git config --bool --get am.messageid)" = true
|
||||||
then
|
then
|
||||||
|
@ -389,6 +390,11 @@ then
|
||||||
keepcr=t
|
keepcr=t
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test "$(git config --bool --get am.threeWay)" = true
|
||||||
|
then
|
||||||
|
threeway=t
|
||||||
|
fi
|
||||||
|
|
||||||
while test $# != 0
|
while test $# != 0
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
@ -400,6 +406,8 @@ it will be removed. Please do not use it anymore."
|
||||||
;;
|
;;
|
||||||
-3|--3way)
|
-3|--3way)
|
||||||
threeway=t ;;
|
threeway=t ;;
|
||||||
|
--no-3way)
|
||||||
|
threeway=f ;;
|
||||||
-s|--signoff)
|
-s|--signoff)
|
||||||
sign=t ;;
|
sign=t ;;
|
||||||
-u|--utf8)
|
-u|--utf8)
|
||||||
|
@ -657,6 +665,8 @@ fi
|
||||||
if test "$(cat "$dotest/threeway")" = t
|
if test "$(cat "$dotest/threeway")" = t
|
||||||
then
|
then
|
||||||
threeway=t
|
threeway=t
|
||||||
|
else
|
||||||
|
threeway=f
|
||||||
fi
|
fi
|
||||||
git_apply_opt=$(cat "$dotest/apply-opt")
|
git_apply_opt=$(cat "$dotest/apply-opt")
|
||||||
if test "$(cat "$dotest/sign")" = t
|
if test "$(cat "$dotest/sign")" = t
|
||||||
|
|
|
@ -274,15 +274,21 @@ test_expect_success 'am --keep-non-patch really keeps the non-patch part' '
|
||||||
grep "^\[foo\] third" actual
|
grep "^\[foo\] third" actual
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'am -3 falls back to 3-way merge' '
|
test_expect_success 'setup am -3' '
|
||||||
rm -fr .git/rebase-apply &&
|
rm -fr .git/rebase-apply &&
|
||||||
git reset --hard &&
|
git reset --hard &&
|
||||||
git checkout -b lorem2 master2 &&
|
git checkout -b base3way master2 &&
|
||||||
sed -n -e "3,\$p" msg >file &&
|
sed -n -e "3,\$p" msg >file &&
|
||||||
head -n 9 msg >>file &&
|
head -n 9 msg >>file &&
|
||||||
git add file &&
|
git add file &&
|
||||||
test_tick &&
|
test_tick &&
|
||||||
git commit -m "copied stuff" &&
|
git commit -m "copied stuff"
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'am -3 falls back to 3-way merge' '
|
||||||
|
rm -fr .git/rebase-apply &&
|
||||||
|
git reset --hard &&
|
||||||
|
git checkout -b lorem2 base3way &&
|
||||||
git am -3 lorem-move.patch &&
|
git am -3 lorem-move.patch &&
|
||||||
test_path_is_missing .git/rebase-apply &&
|
test_path_is_missing .git/rebase-apply &&
|
||||||
git diff --exit-code lorem
|
git diff --exit-code lorem
|
||||||
|
@ -291,17 +297,31 @@ test_expect_success 'am -3 falls back to 3-way merge' '
|
||||||
test_expect_success 'am -3 -p0 can read --no-prefix patch' '
|
test_expect_success 'am -3 -p0 can read --no-prefix patch' '
|
||||||
rm -fr .git/rebase-apply &&
|
rm -fr .git/rebase-apply &&
|
||||||
git reset --hard &&
|
git reset --hard &&
|
||||||
git checkout -b lorem3 master2 &&
|
git checkout -b lorem3 base3way &&
|
||||||
sed -n -e "3,\$p" msg >file &&
|
|
||||||
head -n 9 msg >>file &&
|
|
||||||
git add file &&
|
|
||||||
test_tick &&
|
|
||||||
git commit -m "copied stuff" &&
|
|
||||||
git am -3 -p0 lorem-zero.patch &&
|
git am -3 -p0 lorem-zero.patch &&
|
||||||
test_path_is_missing .git/rebase-apply &&
|
test_path_is_missing .git/rebase-apply &&
|
||||||
git diff --exit-code lorem
|
git diff --exit-code lorem
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'am with config am.threeWay falls back to 3-way merge' '
|
||||||
|
rm -fr .git/rebase-apply &&
|
||||||
|
git reset --hard &&
|
||||||
|
git checkout -b lorem4 base3way &&
|
||||||
|
test_config am.threeWay 1 &&
|
||||||
|
git am lorem-move.patch &&
|
||||||
|
test_path_is_missing .git/rebase-apply &&
|
||||||
|
git diff --exit-code lorem
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'am with config am.threeWay overridden by --no-3way' '
|
||||||
|
rm -fr .git/rebase-apply &&
|
||||||
|
git reset --hard &&
|
||||||
|
git checkout -b lorem5 base3way &&
|
||||||
|
test_config am.threeWay 1 &&
|
||||||
|
test_must_fail git am --no-3way lorem-move.patch &&
|
||||||
|
test_path_is_dir .git/rebase-apply
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'am can rename a file' '
|
test_expect_success 'am can rename a file' '
|
||||||
grep "^rename from" rename.patch &&
|
grep "^rename from" rename.patch &&
|
||||||
rm -fr .git/rebase-apply &&
|
rm -fr .git/rebase-apply &&
|
||||||
|
@ -338,12 +358,7 @@ test_expect_success 'am -3 can rename a file after falling back to 3-way merge'
|
||||||
test_expect_success 'am -3 -q is quiet' '
|
test_expect_success 'am -3 -q is quiet' '
|
||||||
rm -fr .git/rebase-apply &&
|
rm -fr .git/rebase-apply &&
|
||||||
git checkout -f lorem2 &&
|
git checkout -f lorem2 &&
|
||||||
git reset master2 --hard &&
|
git reset base3way --hard &&
|
||||||
sed -n -e "3,\$p" msg >file &&
|
|
||||||
head -n 9 msg >>file &&
|
|
||||||
git add file &&
|
|
||||||
test_tick &&
|
|
||||||
git commit -m "copied stuff" &&
|
|
||||||
git am -3 -q lorem-move.patch >output.out 2>&1 &&
|
git am -3 -q lorem-move.patch >output.out 2>&1 &&
|
||||||
! test -s output.out
|
! test -s output.out
|
||||||
'
|
'
|
||||||
|
|
Загрузка…
Ссылка в новой задаче