Skip to content

Commit ab15612

Browse files
pyokagangitster
authored andcommitted
t4150: am fails if index is dirty
Since d1c5f2a (Add git-am, applymbox replacement., 2005-10-07), git-am will ensure that the index is clean before applying the patch. This is to prevent changes unrelated to the patch from being committed. Add a test for this check. Reviewed-by: Stefan Beller <sbeller@google.com> Reviewed-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Paul Tan <pyokagan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 8528bf4 commit ab15612

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

t/t4150-am.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,18 @@ test_expect_success 'am applies patch correctly' '
154154
test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
155155
'
156156

157+
test_expect_success 'am fails if index is dirty' '
158+
test_when_finished "rm -f dirtyfile" &&
159+
rm -fr .git/rebase-apply &&
160+
git reset --hard &&
161+
git checkout first &&
162+
echo dirtyfile >dirtyfile &&
163+
git add dirtyfile &&
164+
test_must_fail git am patch1 &&
165+
test_path_is_dir .git/rebase-apply &&
166+
test_cmp_rev first HEAD
167+
'
168+
157169
test_expect_success 'am applies patch e-mail not in a mbox' '
158170
rm -fr .git/rebase-apply &&
159171
git reset --hard &&

0 commit comments

Comments
 (0)