t / t1090-sparse-checkout-scope.shon commit rebase --abort/--quit: cleanup refs/rewritten (d559f50)
   1#!/bin/sh
   2
   3test_description='sparse checkout scope tests'
   4
   5. ./test-lib.sh
   6
   7test_expect_success 'setup' '
   8        echo "initial" >a &&
   9        echo "initial" >b &&
  10        echo "initial" >c &&
  11        git add a b c &&
  12        git commit -m "initial commit"
  13'
  14
  15test_expect_success 'create feature branch' '
  16        git checkout -b feature &&
  17        echo "modified" >b &&
  18        echo "modified" >c &&
  19        git add b c &&
  20        git commit -m "modification"
  21'
  22
  23test_expect_success 'perform sparse checkout of master' '
  24        git config --local --bool core.sparsecheckout true &&
  25        echo "!/*" >.git/info/sparse-checkout &&
  26        echo "/a" >>.git/info/sparse-checkout &&
  27        echo "/c" >>.git/info/sparse-checkout &&
  28        git checkout master &&
  29        test_path_is_file a &&
  30        test_path_is_missing b &&
  31        test_path_is_file c
  32'
  33
  34test_expect_success 'checkout -b checkout.optimizeNewBranch interaction' '
  35        cp .git/info/sparse-checkout .git/info/sparse-checkout.bak &&
  36        test_when_finished "
  37                mv -f .git/info/sparse-checkout.bak .git/info/sparse-checkout
  38                git checkout master
  39        " &&
  40        echo "/b" >>.git/info/sparse-checkout &&
  41        test "$(git ls-files -t b)" = "S b" &&
  42        git -c checkout.optimizeNewBranch=true checkout -b fast &&
  43        test "$(git ls-files -t b)" = "S b" &&
  44        git checkout -b slow &&
  45        test "$(git ls-files -t b)" = "H b"
  46'
  47
  48test_expect_success 'merge feature branch into sparse checkout of master' '
  49        git merge feature &&
  50        test_path_is_file a &&
  51        test_path_is_missing b &&
  52        test_path_is_file c &&
  53        test "$(cat c)" = "modified"
  54'
  55
  56test_expect_success 'return to full checkout of master' '
  57        git checkout feature &&
  58        echo "/*" >.git/info/sparse-checkout &&
  59        git checkout master &&
  60        test_path_is_file a &&
  61        test_path_is_file b &&
  62        test_path_is_file c &&
  63        test "$(cat b)" = "modified"
  64'
  65
  66test_expect_success 'in partial clone, sparse checkout only fetches needed blobs' '
  67        test_create_repo server &&
  68        git clone "file://$(pwd)/server" client &&
  69
  70        test_config -C server uploadpack.allowfilter 1 &&
  71        test_config -C server uploadpack.allowanysha1inwant 1 &&
  72        echo a >server/a &&
  73        echo bb >server/b &&
  74        mkdir server/c &&
  75        echo ccc >server/c/c &&
  76        git -C server add a b c/c &&
  77        git -C server commit -m message &&
  78
  79        test_config -C client core.sparsecheckout 1 &&
  80        test_config -C client extensions.partialclone origin &&
  81        echo "!/*" >client/.git/info/sparse-checkout &&
  82        echo "/a" >>client/.git/info/sparse-checkout &&
  83        git -C client fetch --filter=blob:none origin &&
  84        git -C client checkout FETCH_HEAD &&
  85
  86        git -C client rev-list HEAD \
  87                --quiet --objects --missing=print >unsorted_actual &&
  88        (
  89                printf "?" &&
  90                git hash-object server/b &&
  91                printf "?" &&
  92                git hash-object server/c/c
  93        ) >unsorted_expect &&
  94        sort unsorted_actual >actual &&
  95        sort unsorted_expect >expect &&
  96        test_cmp expect actual
  97'
  98
  99test_done