Skip to content

Commit

Permalink
t4150: am fails if index is dirty
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Paul Tan authored and Junio C Hamano committed Jul 20, 2015
1 parent 8528bf4 commit ab15612
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions t/t4150-am.sh
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,18 @@ test_expect_success 'am applies patch correctly' '
test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
'

test_expect_success 'am fails if index is dirty' '
test_when_finished "rm -f dirtyfile" &&
rm -fr .git/rebase-apply &&
git reset --hard &&
git checkout first &&
echo dirtyfile >dirtyfile &&
git add dirtyfile &&
test_must_fail git am patch1 &&
test_path_is_dir .git/rebase-apply &&
test_cmp_rev first HEAD
'

test_expect_success 'am applies patch e-mail not in a mbox' '
rm -fr .git/rebase-apply &&
git reset --hard &&
Expand Down

0 comments on commit ab15612

Please sign in to comment.