t / t7416-submodule-dash-url.shon commit t4000: make hash size independent (8cc5ff8)
   1#!/bin/sh
   2
   3test_description='check handling of .gitmodule url with dash'
   4. ./test-lib.sh
   5
   6test_expect_success 'create submodule with protected dash in url' '
   7        git init upstream &&
   8        git -C upstream commit --allow-empty -m base &&
   9        mv upstream ./-upstream &&
  10        git submodule add ./-upstream sub &&
  11        git add sub .gitmodules &&
  12        git commit -m submodule
  13'
  14
  15test_expect_success 'clone can recurse submodule' '
  16        test_when_finished "rm -rf dst" &&
  17        git clone --recurse-submodules . dst &&
  18        echo base >expect &&
  19        git -C dst/sub log -1 --format=%s >actual &&
  20        test_cmp expect actual
  21'
  22
  23test_expect_success 'fsck accepts protected dash' '
  24        test_when_finished "rm -rf dst" &&
  25        git init --bare dst &&
  26        git -C dst config transfer.fsckObjects true &&
  27        git push dst HEAD
  28'
  29
  30test_expect_success 'remove ./ protection from .gitmodules url' '
  31        perl -i -pe "s{\./}{}" .gitmodules &&
  32        git commit -am "drop protection"
  33'
  34
  35test_expect_success 'clone rejects unprotected dash' '
  36        test_when_finished "rm -rf dst" &&
  37        test_must_fail git clone --recurse-submodules . dst 2>err &&
  38        test_i18ngrep ignoring err
  39'
  40
  41test_expect_success 'fsck rejects unprotected dash' '
  42        test_when_finished "rm -rf dst" &&
  43        git init --bare dst &&
  44        git -C dst config transfer.fsckObjects true &&
  45        test_must_fail git push dst HEAD 2>err &&
  46        grep gitmodulesUrl err
  47'
  48
  49test_done