[PATCH v2 02/12] t4150: am fails if index is dirty
- From
Paul Tan <pyokagan@gmail.com>
- Date
- Jul 7, 2015, 14:08 UTC
- Message-ID
- <1436278114-28057-3-git-send-email-pyokagan@gmail.com>
- In-Reply-To
- <1436278114-28057-1-git-send-email-pyokagan@gmail.com>
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.
Signed-off-by: Paul Tan <pyokagan@gmail.com> ---
Notes:
v2
* Should be "rm -f dirtyfile" instead of "rm -rf dirtyfile"
* Don't use "git checkout -f" -- it does not discard unmerged entries.
Use git reset --hard instead.t/t4150-am.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/t/t4150-am.sh b/t/t4150-am.sh index 264f53f..a85e06a 100755 --- a/t/t4150-am.sh +++ b/t/t4150-am.sh @@ -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 &&
-- 2.5.0.rc1.76.gf60a929