mirror of
https://github.com/git/git.git
synced 2024-11-29 04:54:56 +08:00
Merge branch 'jc/am-options'
* jc/am-options: git-am: rename apply_opt_extra file to apply-opt Test that git-am does not lose -C/-p/--whitespace options git-am: propagate --3way options as well git-am: propagate -C<n>, -p<n> options as well git-am --whitespace: do not lose the command line option
This commit is contained in:
commit
d8af75d76f
15
git-am.sh
15
git-am.sh
@ -247,10 +247,11 @@ else
|
||||
exit 1
|
||||
}
|
||||
|
||||
# -s, -u, -k and --whitespace flags are kept for the
|
||||
# resuming session after a patch failure.
|
||||
# -3 and -i can and must be given when resuming.
|
||||
echo " $ws" >"$dotest/whitespace"
|
||||
# -s, -u, -k, --whitespace, -3, -C and -p flags are kept
|
||||
# for the resuming session after a patch failure.
|
||||
# -i can and must be given when resuming.
|
||||
echo " $git_apply_opt" >"$dotest/apply-opt"
|
||||
echo "$threeway" >"$dotest/threeway"
|
||||
echo "$sign" >"$dotest/sign"
|
||||
echo "$utf8" >"$dotest/utf8"
|
||||
echo "$keep" >"$dotest/keep"
|
||||
@ -283,7 +284,11 @@ if test "$(cat "$dotest/keep")" = t
|
||||
then
|
||||
keep=-k
|
||||
fi
|
||||
ws=`cat "$dotest/whitespace"`
|
||||
if test "$(cat "$dotest/threeway")" = t
|
||||
then
|
||||
threeway=t
|
||||
fi
|
||||
git_apply_opt=$(cat "$dotest/apply-opt")
|
||||
if test "$(cat "$dotest/sign")" = t
|
||||
then
|
||||
SIGNOFF=`git var GIT_COMMITTER_IDENT | sed -e '
|
||||
|
53
t/t4252-am-options.sh
Executable file
53
t/t4252-am-options.sh
Executable file
@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description='git am not losing options'
|
||||
. ./test-lib.sh
|
||||
|
||||
tm="$TEST_DIRECTORY/t4252"
|
||||
|
||||
test_expect_success setup '
|
||||
cp "$tm/file-1-0" file-1 &&
|
||||
cp "$tm/file-2-0" file-2 &&
|
||||
git add file-1 file-2 &&
|
||||
test_tick &&
|
||||
git commit -m initial &&
|
||||
git tag initial
|
||||
'
|
||||
|
||||
test_expect_success 'interrupted am --whitespace=fix' '
|
||||
rm -rf .git/rebase-apply &&
|
||||
git reset --hard initial &&
|
||||
test_must_fail git am --whitespace=fix "$tm"/am-test-1-? &&
|
||||
git am --skip &&
|
||||
grep 3 file-1 &&
|
||||
grep "^Six$" file-2
|
||||
'
|
||||
|
||||
test_expect_success 'interrupted am -C1' '
|
||||
rm -rf .git/rebase-apply &&
|
||||
git reset --hard initial &&
|
||||
test_must_fail git am -C1 "$tm"/am-test-2-? &&
|
||||
git am --skip &&
|
||||
grep 3 file-1 &&
|
||||
grep "^Three$" file-2
|
||||
'
|
||||
|
||||
test_expect_success 'interrupted am -p2' '
|
||||
rm -rf .git/rebase-apply &&
|
||||
git reset --hard initial &&
|
||||
test_must_fail git am -p2 "$tm"/am-test-3-? &&
|
||||
git am --skip &&
|
||||
grep 3 file-1 &&
|
||||
grep "^Three$" file-2
|
||||
'
|
||||
|
||||
test_expect_success 'interrupted am -C1 -p2' '
|
||||
rm -rf .git/rebase-apply &&
|
||||
git reset --hard initial &&
|
||||
test_must_fail git am -p2 -C1 "$tm"/am-test-4-? &&
|
||||
git am --skip &&
|
||||
grep 3 file-1 &&
|
||||
grep "^Three$" file-2
|
||||
'
|
||||
|
||||
test_done
|
19
t/t4252/am-test-1-1
Normal file
19
t/t4252/am-test-1-1
Normal file
@ -0,0 +1,19 @@
|
||||
From: A U Thor <au.thor@example.com>
|
||||
Date: Thu Dec 4 16:00:00 2008 -0800
|
||||
Subject: Three
|
||||
|
||||
Application of this should be rejected because the first line in the
|
||||
context does not match.
|
||||
|
||||
diff --git i/file-1 w/file-1
|
||||
index 06e567b..10f8342 100644
|
||||
--- i/file-1
|
||||
+++ w/file-1
|
||||
@@ -1,6 +1,6 @@
|
||||
One
|
||||
2
|
||||
-3
|
||||
+Three
|
||||
4
|
||||
5
|
||||
6
|
21
t/t4252/am-test-1-2
Normal file
21
t/t4252/am-test-1-2
Normal file
@ -0,0 +1,21 @@
|
||||
From: A U Thor <au.thor@example.com>
|
||||
Date: Thu Dec 4 16:00:00 2008 -0800
|
||||
Subject: Six
|
||||
|
||||
Applying this patch with --whitespace=fix should lose
|
||||
the trailing whitespace after "Six".
|
||||
|
||||
diff --git i/file-2 w/file-2
|
||||
index 06e567b..b6f3a16 100644
|
||||
--- i/file-2
|
||||
+++ w/file-2
|
||||
@@ -1,7 +1,7 @@
|
||||
1
|
||||
2
|
||||
-3
|
||||
+Three
|
||||
4
|
||||
5
|
||||
-6
|
||||
+Six
|
||||
7
|
19
t/t4252/am-test-2-1
Normal file
19
t/t4252/am-test-2-1
Normal file
@ -0,0 +1,19 @@
|
||||
From: A U Thor <au.thor@example.com>
|
||||
Date: Thu Dec 4 16:00:00 2008 -0800
|
||||
Subject: Three
|
||||
|
||||
Application of this should be rejected even with -C1 because the
|
||||
preimage line in the context does not match.
|
||||
|
||||
diff --git i/file-1 w/file-1
|
||||
index 06e567b..10f8342 100644
|
||||
--- i/file-1
|
||||
+++ w/file-1
|
||||
@@ -1,6 +1,6 @@
|
||||
1
|
||||
2
|
||||
-Tres
|
||||
+Three
|
||||
4
|
||||
5
|
||||
6
|
21
t/t4252/am-test-2-2
Normal file
21
t/t4252/am-test-2-2
Normal file
@ -0,0 +1,21 @@
|
||||
From: A U Thor <au.thor@example.com>
|
||||
Date: Thu Dec 4 16:00:00 2008 -0800
|
||||
Subject: Six
|
||||
|
||||
Applying this patch with -C1 should be successful even though
|
||||
the first line in the context does not match.
|
||||
|
||||
diff --git i/file-2 w/file-2
|
||||
index 06e567b..b6f3a16 100644
|
||||
--- i/file-2
|
||||
+++ w/file-2
|
||||
@@ -1,7 +1,7 @@
|
||||
One
|
||||
2
|
||||
-3
|
||||
+Three
|
||||
4
|
||||
5
|
||||
-6
|
||||
+Six
|
||||
7
|
19
t/t4252/am-test-3-1
Normal file
19
t/t4252/am-test-3-1
Normal file
@ -0,0 +1,19 @@
|
||||
From: A U Thor <au.thor@example.com>
|
||||
Date: Thu Dec 4 16:00:00 2008 -0800
|
||||
Subject: Three
|
||||
|
||||
Application of this should be rejected even with -p2 because the
|
||||
preimage line in the context does not match.
|
||||
|
||||
diff --git i/junk/file-1 w/junk/file-1
|
||||
index 06e567b..10f8342 100644
|
||||
--- i/junk/file-1
|
||||
+++ w/junk/file-1
|
||||
@@ -1,6 +1,6 @@
|
||||
1
|
||||
2
|
||||
-Tres
|
||||
+Three
|
||||
4
|
||||
5
|
||||
6
|
21
t/t4252/am-test-3-2
Normal file
21
t/t4252/am-test-3-2
Normal file
@ -0,0 +1,21 @@
|
||||
From: A U Thor <au.thor@example.com>
|
||||
Date: Thu Dec 4 16:00:00 2008 -0800
|
||||
Subject: Six
|
||||
|
||||
Applying this patch with -p2 should be successful even though
|
||||
the patch is against a wrong level.
|
||||
|
||||
diff --git i/junk/file-2 w/junk/file-2
|
||||
index 06e567b..b6f3a16 100644
|
||||
--- i/junk/file-2
|
||||
+++ w/junk/file-2
|
||||
@@ -1,7 +1,7 @@
|
||||
1
|
||||
2
|
||||
-3
|
||||
+Three
|
||||
4
|
||||
5
|
||||
-6
|
||||
+Six
|
||||
7
|
19
t/t4252/am-test-4-1
Normal file
19
t/t4252/am-test-4-1
Normal file
@ -0,0 +1,19 @@
|
||||
From: A U Thor <au.thor@example.com>
|
||||
Date: Thu Dec 4 16:00:00 2008 -0800
|
||||
Subject: Three
|
||||
|
||||
Application of this should be rejected even with -C1 -p2 because
|
||||
the preimage line in the context does not match.
|
||||
|
||||
diff --git i/junk/file-1 w/junk/file-1
|
||||
index 06e567b..10f8342 100644
|
||||
--- i/junk/file-1
|
||||
+++ w/junk/file-1
|
||||
@@ -1,6 +1,6 @@
|
||||
1
|
||||
2
|
||||
-Tres
|
||||
+Three
|
||||
4
|
||||
5
|
||||
6
|
22
t/t4252/am-test-4-2
Normal file
22
t/t4252/am-test-4-2
Normal file
@ -0,0 +1,22 @@
|
||||
From: A U Thor <au.thor@example.com>
|
||||
Date: Thu Dec 4 16:00:00 2008 -0800
|
||||
Subject: Six
|
||||
|
||||
Applying this patch with -C1 -p2 should be successful even though
|
||||
the patch is against a wrong level and the first context line does
|
||||
not match.
|
||||
|
||||
diff --git i/junk/file-2 w/junk/file-2
|
||||
index 06e567b..b6f3a16 100644
|
||||
--- i/junk/file-2
|
||||
+++ w/junk/file-2
|
||||
@@ -1,7 +1,7 @@
|
||||
One
|
||||
2
|
||||
-3
|
||||
+Three
|
||||
4
|
||||
5
|
||||
-6
|
||||
+Six
|
||||
7
|
7
t/t4252/file-1-0
Normal file
7
t/t4252/file-1-0
Normal file
@ -0,0 +1,7 @@
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
7
t/t4252/file-2-0
Normal file
7
t/t4252/file-2-0
Normal file
@ -0,0 +1,7 @@
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
Loading…
Reference in New Issue
Block a user