t / t4254-am-corrupt.shon commit Merge branch 'rl/maint-stash-i18n-save-error' (cd58b71)
   1#!/bin/sh
   2
   3test_description='git am with corrupt input'
   4. ./test-lib.sh
   5
   6# Note the missing "+++" line:
   7cat > bad-patch.diff <<'EOF'
   8From: A U Thor <au.thor@example.com>
   9diff --git a/f b/f
  10index 7898192..6178079 100644
  11--- a/f
  12@@ -1 +1 @@
  13-a
  14+b
  15EOF
  16
  17test_expect_success setup '
  18        test $? = 0 &&
  19        echo a > f &&
  20        git add f &&
  21        test_tick &&
  22        git commit -m initial
  23'
  24
  25# This used to fail before, too, but with a different diagnostic.
  26#   fatal: unable to write file '(null)' mode 100644: Bad address
  27# Also, it had the unwanted side-effect of deleting f.
  28test_expect_success 'try to apply corrupted patch' '
  29        git am bad-patch.diff 2> actual
  30        test $? = 1
  31'
  32
  33cat > expected <<EOF
  34fatal: git diff header lacks filename information (line 4)
  35EOF
  36
  37test_expect_success 'compare diagnostic; ensure file is still here' '
  38        test $? = 0 &&
  39        test -f f &&
  40        test_cmp expected actual
  41'
  42
  43test_done