t / t5611-clone-config.shon commit Merge branch 'jk/ident-ai-canonname-could-be-null' into maint (11738dd)
   1#!/bin/sh
   2
   3test_description='tests for git clone -c key=value'
   4. ./test-lib.sh
   5
   6test_expect_success 'clone -c sets config in cloned repo' '
   7        rm -rf child &&
   8        git clone -c core.foo=bar . child &&
   9        echo bar >expect &&
  10        git --git-dir=child/.git config core.foo >actual &&
  11        test_cmp expect actual
  12'
  13
  14test_expect_success 'clone -c can set multi-keys' '
  15        rm -rf child &&
  16        git clone -c core.foo=bar -c core.foo=baz . child &&
  17        { echo bar; echo baz; } >expect &&
  18        git --git-dir=child/.git config --get-all core.foo >actual &&
  19        test_cmp expect actual
  20'
  21
  22test_expect_success 'clone -c without a value is boolean true' '
  23        rm -rf child &&
  24        git clone -c core.foo . child &&
  25        echo true >expect &&
  26        git --git-dir=child/.git config --bool core.foo >actual &&
  27        test_cmp expect actual
  28'
  29
  30test_expect_success 'clone -c config is available during clone' '
  31        echo content >file &&
  32        git add file &&
  33        git commit -m one &&
  34        rm -rf child &&
  35        git clone -c core.autocrlf . child &&
  36        printf "content\\r\\n" >expect &&
  37        test_cmp expect child/file
  38'
  39
  40# Tests for the hidden file attribute on windows
  41is_hidden () {
  42        # Use the output of `attrib`, ignore the absolute path
  43        case "$(attrib "$1")" in *H*?:*) return 0;; esac
  44        return 1
  45}
  46
  47test_expect_success MINGW 'clone -c core.hideDotFiles' '
  48        test_commit attributes .gitattributes "" &&
  49        rm -rf child &&
  50        git clone -c core.hideDotFiles=false . child &&
  51        ! is_hidden child/.gitattributes &&
  52        rm -rf child &&
  53        git clone -c core.hideDotFiles=dotGitOnly . child &&
  54        ! is_hidden child/.gitattributes &&
  55        rm -rf child &&
  56        git clone -c core.hideDotFiles=true . child &&
  57        is_hidden child/.gitattributes
  58'
  59
  60test_done