Skip to content

Commit b80da42

Browse files
madduckgitster
authored andcommitted
git-am: implement --reject option passed to git-apply
With --reject, git-am simply passes the --reject option to git-apply and thus allows people to work with reject files if they so prefer. Signed-off-by: martin f. krafft <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d930508 commit b80da42

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

Documentation/git-am.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ SYNOPSIS
1212
'git am' [--signoff] [--keep] [--utf8 | --no-utf8]
1313
[--3way] [--interactive]
1414
[--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]
15+
[--reject]
1516
[<mbox> | <Maildir>...]
1617
'git am' (--skip | --resolved | --abort)
1718

@@ -63,6 +64,7 @@ default. You could use `--no-utf8` to override this.
6364
-C<n>::
6465
-p<n>::
6566
--directory=<dir>::
67+
--reject::
6668
These flags are passed to the 'git-apply' (see linkgit:git-apply[1])
6769
program that applies
6870
the patch.

git-am.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ whitespace= pass it through git-apply
1919
directory= pass it through git-apply
2020
C= pass it through git-apply
2121
p= pass it through git-apply
22+
reject pass it through git-apply
2223
resolvemsg= override error message when patch failure occurs
2324
r,resolved to be used after a patch failure
2425
skip skip the current patch
@@ -168,6 +169,8 @@ do
168169
git_apply_opt="$git_apply_opt $(sq "$1=$2")"; shift ;;
169170
-C|-p)
170171
git_apply_opt="$git_apply_opt $(sq "$1$2")"; shift ;;
172+
--reject)
173+
git_apply_opt="$git_apply_opt $1" ;;
171174
--)
172175
shift; break ;;
173176
*)

t/t4252-am-options.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

3-
test_description='git am not losing options'
3+
test_description='git am with options and not losing them'
44
. ./test-lib.sh
55

66
tm="$TEST_DIRECTORY/t4252"
@@ -66,4 +66,13 @@ test_expect_success 'apply to a funny path' '
6666
test -f "$with_sq/file-5"
6767
'
6868

69+
test_expect_success 'am --reject' '
70+
rm -rf .git/rebase-apply &&
71+
git reset --hard initial &&
72+
test_must_fail git am --reject "$tm"/am-test-6-1 &&
73+
grep "@@ -1,3 +1,3 @@" file-2.rej &&
74+
test_must_fail git diff-files --exit-code --quiet file-2 &&
75+
grep "[-]-reject" .git/rebase-apply/apply-opt
76+
'
77+
6978
test_done

t/t4252/am-test-6-1

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
From: A U Thor <[email protected]>
2+
Date: Thu Dec 4 16:00:00 2008 -0800
3+
Subject: Huh
4+
5+
Should fail and leave rejects
6+
7+
diff --git i/file-2 w/file-2
8+
index 06e567b..b6f3a16 100644
9+
--- i/file-2
10+
+++ w/file-2
11+
@@ -1,3 +1,3 @@
12+
-0
13+
+One
14+
2
15+
3
16+
@@ -4,4 +4,4 @@
17+
4
18+
5
19+
-6
20+
+Six
21+
7

0 commit comments

Comments
 (0)