t / t5502-quickfetch.shon commit git.el: Always set the current directory in the git-diff buffer. (8fdc397)
   1#!/bin/sh
   2
   3test_description='test quickfetch from local'
   4
   5. ./test-lib.sh
   6
   7test_expect_success setup '
   8
   9        test_tick &&
  10        echo ichi >file &&
  11        git add file &&
  12        git commit -m initial &&
  13
  14        cnt=$( (
  15                git count-objects | sed -e "s/ *objects,.*//"
  16        ) ) &&
  17        test $cnt -eq 3
  18'
  19
  20test_expect_success 'clone without alternate' '
  21
  22        (
  23                mkdir cloned &&
  24                cd cloned &&
  25                git init-db &&
  26                git remote add -f origin ..
  27        ) &&
  28        cnt=$( (
  29                cd cloned &&
  30                git count-objects | sed -e "s/ *objects,.*//"
  31        ) ) &&
  32        test $cnt -eq 3
  33'
  34
  35test_expect_success 'further commits in the original' '
  36
  37        test_tick &&
  38        echo ni >file &&
  39        git commit -a -m second &&
  40
  41        cnt=$( (
  42                git count-objects | sed -e "s/ *objects,.*//"
  43        ) ) &&
  44        test $cnt -eq 6
  45'
  46
  47test_expect_success 'copy commit and tree but not blob by hand' '
  48
  49        git rev-list --objects HEAD |
  50        git pack-objects --stdout |
  51        (
  52                cd cloned &&
  53                git unpack-objects
  54        ) &&
  55
  56        cnt=$( (
  57                cd cloned &&
  58                git count-objects | sed -e "s/ *objects,.*//"
  59        ) ) &&
  60        test $cnt -eq 6
  61
  62        blob=$(git rev-parse HEAD:file | sed -e "s|..|&/|") &&
  63        test -f "cloned/.git/objects/$blob" &&
  64        rm -f "cloned/.git/objects/$blob" &&
  65
  66        cnt=$( (
  67                cd cloned &&
  68                git count-objects | sed -e "s/ *objects,.*//"
  69        ) ) &&
  70        test $cnt -eq 5
  71
  72'
  73
  74test_expect_success 'quickfetch should not leave a corrupted repository' '
  75
  76        (
  77                cd cloned &&
  78                git fetch
  79        ) &&
  80
  81        cnt=$( (
  82                cd cloned &&
  83                git count-objects | sed -e "s/ *objects,.*//"
  84        ) ) &&
  85        test $cnt -eq 6
  86
  87'
  88
  89test_done