t / t5530-upload-pack-error.shon commit Merge branch 'rs/pretty-safety' (49e6be5)
   1#!/bin/sh
   2
   3test_description='errors in upload-pack'
   4
   5. ./test-lib.sh
   6
   7D=`pwd`
   8
   9corrupt_repo () {
  10        object_sha1=$(git rev-parse "$1") &&
  11        ob=$(expr "$object_sha1" : "\(..\)") &&
  12        ject=$(expr "$object_sha1" : "..\(..*\)") &&
  13        rm -f ".git/objects/$ob/$ject"
  14}
  15
  16test_expect_success 'setup and corrupt repository' '
  17
  18        echo file >file &&
  19        git add file &&
  20        git rev-parse :file &&
  21        git commit -a -m original &&
  22        test_tick &&
  23        echo changed >file &&
  24        git commit -a -m changed &&
  25        corrupt_repo HEAD:file
  26
  27'
  28
  29test_expect_failure 'fsck fails' '
  30
  31        git fsck
  32'
  33
  34test_expect_success 'upload-pack fails due to error in pack-objects' '
  35
  36        ! echo "0032want $(git rev-parse HEAD)
  3700000009done
  380000" | git-upload-pack . > /dev/null 2> output.err &&
  39        grep "pack-objects died" output.err
  40'
  41
  42test_expect_success 'corrupt repo differently' '
  43
  44        git hash-object -w file &&
  45        corrupt_repo HEAD^^{tree}
  46
  47'
  48
  49test_expect_failure 'fsck fails' '
  50
  51        git fsck
  52'
  53test_expect_success 'upload-pack fails due to error in rev-list' '
  54
  55        ! echo "0032want $(git rev-parse HEAD)
  5600000009done
  570000" | git-upload-pack . > /dev/null 2> output.err &&
  58        grep "waitpid (async) failed" output.err
  59'
  60
  61test_expect_success 'create empty repository' '
  62
  63        mkdir foo &&
  64        cd foo &&
  65        git init
  66
  67'
  68
  69test_expect_failure 'fetch fails' '
  70
  71        git fetch .. master
  72
  73'
  74
  75test_done