Skip to content

Commit d8af75d

Browse files
committed
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
2 parents 7f705dc + 9b9f5a2 commit d8af75d

File tree

12 files changed

+238
-5
lines changed

12 files changed

+238
-5
lines changed

git-am.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,11 @@ else
247247
exit 1
248248
}
249249

250-
# -s, -u, -k and --whitespace flags are kept for the
251-
# resuming session after a patch failure.
252-
# -3 and -i can and must be given when resuming.
253-
echo " $ws" >"$dotest/whitespace"
250+
# -s, -u, -k, --whitespace, -3, -C and -p flags are kept
251+
# for the resuming session after a patch failure.
252+
# -i can and must be given when resuming.
253+
echo " $git_apply_opt" >"$dotest/apply-opt"
254+
echo "$threeway" >"$dotest/threeway"
254255
echo "$sign" >"$dotest/sign"
255256
echo "$utf8" >"$dotest/utf8"
256257
echo "$keep" >"$dotest/keep"
@@ -283,7 +284,11 @@ if test "$(cat "$dotest/keep")" = t
283284
then
284285
keep=-k
285286
fi
286-
ws=`cat "$dotest/whitespace"`
287+
if test "$(cat "$dotest/threeway")" = t
288+
then
289+
threeway=t
290+
fi
291+
git_apply_opt=$(cat "$dotest/apply-opt")
287292
if test "$(cat "$dotest/sign")" = t
288293
then
289294
SIGNOFF=`git var GIT_COMMITTER_IDENT | sed -e '

t/t4252-am-options.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/sh
2+
3+
test_description='git am not losing options'
4+
. ./test-lib.sh
5+
6+
tm="$TEST_DIRECTORY/t4252"
7+
8+
test_expect_success setup '
9+
cp "$tm/file-1-0" file-1 &&
10+
cp "$tm/file-2-0" file-2 &&
11+
git add file-1 file-2 &&
12+
test_tick &&
13+
git commit -m initial &&
14+
git tag initial
15+
'
16+
17+
test_expect_success 'interrupted am --whitespace=fix' '
18+
rm -rf .git/rebase-apply &&
19+
git reset --hard initial &&
20+
test_must_fail git am --whitespace=fix "$tm"/am-test-1-? &&
21+
git am --skip &&
22+
grep 3 file-1 &&
23+
grep "^Six$" file-2
24+
'
25+
26+
test_expect_success 'interrupted am -C1' '
27+
rm -rf .git/rebase-apply &&
28+
git reset --hard initial &&
29+
test_must_fail git am -C1 "$tm"/am-test-2-? &&
30+
git am --skip &&
31+
grep 3 file-1 &&
32+
grep "^Three$" file-2
33+
'
34+
35+
test_expect_success 'interrupted am -p2' '
36+
rm -rf .git/rebase-apply &&
37+
git reset --hard initial &&
38+
test_must_fail git am -p2 "$tm"/am-test-3-? &&
39+
git am --skip &&
40+
grep 3 file-1 &&
41+
grep "^Three$" file-2
42+
'
43+
44+
test_expect_success 'interrupted am -C1 -p2' '
45+
rm -rf .git/rebase-apply &&
46+
git reset --hard initial &&
47+
test_must_fail git am -p2 -C1 "$tm"/am-test-4-? &&
48+
git am --skip &&
49+
grep 3 file-1 &&
50+
grep "^Three$" file-2
51+
'
52+
53+
test_done

t/t4252/am-test-1-1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
From: A U Thor <au.thor@example.com>
2+
Date: Thu Dec 4 16:00:00 2008 -0800
3+
Subject: Three
4+
5+
Application of this should be rejected because the first line in the
6+
context does not match.
7+
8+
diff --git i/file-1 w/file-1
9+
index 06e567b..10f8342 100644
10+
--- i/file-1
11+
+++ w/file-1
12+
@@ -1,6 +1,6 @@
13+
One
14+
2
15+
-3
16+
+Three
17+
4
18+
5
19+
6

t/t4252/am-test-1-2

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
From: A U Thor <au.thor@example.com>
2+
Date: Thu Dec 4 16:00:00 2008 -0800
3+
Subject: Six
4+
5+
Applying this patch with --whitespace=fix should lose
6+
the trailing whitespace after "Six".
7+
8+
diff --git i/file-2 w/file-2
9+
index 06e567b..b6f3a16 100644
10+
--- i/file-2
11+
+++ w/file-2
12+
@@ -1,7 +1,7 @@
13+
1
14+
2
15+
-3
16+
+Three
17+
4
18+
5
19+
-6
20+
+Six
21+
7

t/t4252/am-test-2-1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
From: A U Thor <au.thor@example.com>
2+
Date: Thu Dec 4 16:00:00 2008 -0800
3+
Subject: Three
4+
5+
Application of this should be rejected even with -C1 because the
6+
preimage line in the context does not match.
7+
8+
diff --git i/file-1 w/file-1
9+
index 06e567b..10f8342 100644
10+
--- i/file-1
11+
+++ w/file-1
12+
@@ -1,6 +1,6 @@
13+
1
14+
2
15+
-Tres
16+
+Three
17+
4
18+
5
19+
6

t/t4252/am-test-2-2

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
From: A U Thor <au.thor@example.com>
2+
Date: Thu Dec 4 16:00:00 2008 -0800
3+
Subject: Six
4+
5+
Applying this patch with -C1 should be successful even though
6+
the first line in the context does not match.
7+
8+
diff --git i/file-2 w/file-2
9+
index 06e567b..b6f3a16 100644
10+
--- i/file-2
11+
+++ w/file-2
12+
@@ -1,7 +1,7 @@
13+
One
14+
2
15+
-3
16+
+Three
17+
4
18+
5
19+
-6
20+
+Six
21+
7

t/t4252/am-test-3-1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
From: A U Thor <au.thor@example.com>
2+
Date: Thu Dec 4 16:00:00 2008 -0800
3+
Subject: Three
4+
5+
Application of this should be rejected even with -p2 because the
6+
preimage line in the context does not match.
7+
8+
diff --git i/junk/file-1 w/junk/file-1
9+
index 06e567b..10f8342 100644
10+
--- i/junk/file-1
11+
+++ w/junk/file-1
12+
@@ -1,6 +1,6 @@
13+
1
14+
2
15+
-Tres
16+
+Three
17+
4
18+
5
19+
6

t/t4252/am-test-3-2

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
From: A U Thor <au.thor@example.com>
2+
Date: Thu Dec 4 16:00:00 2008 -0800
3+
Subject: Six
4+
5+
Applying this patch with -p2 should be successful even though
6+
the patch is against a wrong level.
7+
8+
diff --git i/junk/file-2 w/junk/file-2
9+
index 06e567b..b6f3a16 100644
10+
--- i/junk/file-2
11+
+++ w/junk/file-2
12+
@@ -1,7 +1,7 @@
13+
1
14+
2
15+
-3
16+
+Three
17+
4
18+
5
19+
-6
20+
+Six
21+
7

t/t4252/am-test-4-1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
From: A U Thor <au.thor@example.com>
2+
Date: Thu Dec 4 16:00:00 2008 -0800
3+
Subject: Three
4+
5+
Application of this should be rejected even with -C1 -p2 because
6+
the preimage line in the context does not match.
7+
8+
diff --git i/junk/file-1 w/junk/file-1
9+
index 06e567b..10f8342 100644
10+
--- i/junk/file-1
11+
+++ w/junk/file-1
12+
@@ -1,6 +1,6 @@
13+
1
14+
2
15+
-Tres
16+
+Three
17+
4
18+
5
19+
6

t/t4252/am-test-4-2

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
From: A U Thor <au.thor@example.com>
2+
Date: Thu Dec 4 16:00:00 2008 -0800
3+
Subject: Six
4+
5+
Applying this patch with -C1 -p2 should be successful even though
6+
the patch is against a wrong level and the first context line does
7+
not match.
8+
9+
diff --git i/junk/file-2 w/junk/file-2
10+
index 06e567b..b6f3a16 100644
11+
--- i/junk/file-2
12+
+++ w/junk/file-2
13+
@@ -1,7 +1,7 @@
14+
One
15+
2
16+
-3
17+
+Three
18+
4
19+
5
20+
-6
21+
+Six
22+
7

0 commit comments

Comments
 (0)