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>
Paul Tan committed
Jul 19, 2015 at 23:49 UTC
ab156128fa0e3fc70a40f367abdf3f601c3ba611
1 file changed
+12
t/t4150-am.sh
+12
@@ -154,6 +154,18 @@ test_expect_success 'am applies patch correctly' '
154
test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
155
'
156
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
+
169
test_expect_success 'am applies patch e-mail not in a mbox' '
170
rm -fr .git/rebase-apply &&
171
git reset --hard &&