3 test_description='tests for git clone -c key=value'
 
   6 test_expect_success 'clone -c sets config in cloned repo' '
 
   8         git clone -c core.foo=bar . child &&
 
  10         git --git-dir=child/.git config core.foo >actual &&
 
  11         test_cmp expect actual
 
  14 test_expect_success 'clone -c can set multi-keys' '
 
  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
 
  22 test_expect_success 'clone -c can set multi-keys, including some empty' '
 
  24         git clone -c credential.helper= -c credential.helper=hi . child &&
 
  25         printf "%s\n" "" hi >expect &&
 
  26         git --git-dir=child/.git config --get-all credential.helper >actual &&
 
  27         test_cmp expect actual
 
  30 test_expect_success 'clone -c without a value is boolean true' '
 
  32         git clone -c core.foo . child &&
 
  34         git --git-dir=child/.git config --bool core.foo >actual &&
 
  35         test_cmp expect actual
 
  38 test_expect_success 'clone -c config is available during clone' '
 
  43         git clone -c core.autocrlf . child &&
 
  44         printf "content\\r\\n" >expect &&
 
  45         test_cmp expect child/file
 
  48 test_expect_success 'clone -c remote.origin.fetch=<refspec> works' '
 
  50         git update-ref refs/grab/it refs/heads/master &&
 
  51         git update-ref refs/leave/out refs/heads/master &&
 
  52         git clone -c "remote.origin.fetch=+refs/grab/*:refs/grab/*" . child &&
 
  53         git -C child for-each-ref --format="%(refname)" >actual &&
 
  55         cat >expect <<-\EOF &&
 
  58         refs/remotes/origin/HEAD
 
  59         refs/remotes/origin/master
 
  61         test_cmp expect actual
 
  64 test_expect_success 'git -c remote.origin.fetch=<refspec> clone works' '
 
  66         git -c "remote.origin.fetch=+refs/grab/*:refs/grab/*" clone . child &&
 
  67         git -C child for-each-ref --format="%(refname)" >actual &&
 
  69         cat >expect <<-\EOF &&
 
  72         refs/remotes/origin/HEAD
 
  73         refs/remotes/origin/master
 
  75         test_cmp expect actual
 
  78 test_expect_success 'clone -c remote.<remote>.fetch=<refspec> --origin=<name>' '
 
  80         git clone --origin=upstream \
 
  81                   -c "remote.upstream.fetch=+refs/grab/*:refs/grab/*" \
 
  82                   -c "remote.origin.fetch=+refs/leave/*:refs/leave/*" \
 
  84         git -C child for-each-ref --format="%(refname)" >actual &&
 
  86         cat >expect <<-\EOF &&
 
  89         refs/remotes/upstream/HEAD
 
  90         refs/remotes/upstream/master
 
  92         test_cmp expect actual
 
  95 test_expect_success MINGW 'clone -c core.hideDotFiles' '
 
  96         test_commit attributes .gitattributes "" &&
 
  98         git clone -c core.hideDotFiles=false . child &&
 
  99         ! test_path_is_hidden child/.gitattributes &&
 
 101         git clone -c core.hideDotFiles=dotGitOnly . child &&
 
 102         ! test_path_is_hidden child/.gitattributes &&
 
 104         git clone -c core.hideDotFiles=true . child &&
 
 105         test_path_is_hidden child/.gitattributes