t1300-config-set.shon commit Client side support for user-relative paths. (faea9cc)
   1#!/bin/sh
   2#
   3# Copyright (c) 2005 Johannes Schindelin
   4#
   5
   6test_description='Test git-config-set in different settings'
   7
   8. ./test-lib.sh
   9
  10test -f .git/config && rm .git/config
  11
  12git-config-set core.penguin "little blue"
  13
  14cat > expect << EOF
  15#
  16# This is the config file
  17#
  18
  19[core]
  20        penguin = little blue
  21EOF
  22
  23test_expect_success 'initial' 'cmp .git/config expect'
  24
  25git-config-set Core.Movie BadPhysics
  26
  27cat > expect << EOF
  28#
  29# This is the config file
  30#
  31
  32[core]
  33        penguin = little blue
  34        Movie = BadPhysics
  35EOF
  36
  37test_expect_success 'mixed case' 'cmp .git/config expect'
  38
  39git-config-set Cores.WhatEver Second
  40
  41cat > expect << EOF
  42#
  43# This is the config file
  44#
  45
  46[core]
  47        penguin = little blue
  48        Movie = BadPhysics
  49[Cores]
  50        WhatEver = Second
  51EOF
  52
  53test_expect_success 'similar section' 'cmp .git/config expect'
  54
  55git-config-set CORE.UPPERCASE true
  56
  57cat > expect << EOF
  58#
  59# This is the config file
  60#
  61
  62[core]
  63        penguin = little blue
  64        Movie = BadPhysics
  65        UPPERCASE = true
  66[Cores]
  67        WhatEver = Second
  68EOF
  69
  70test_expect_success 'similar section' 'cmp .git/config expect'
  71
  72cat > .git/config << EOF
  73[beta] ; silly comment # another comment
  74noIndent= sillyValue ; 'nother silly comment
  75
  76# empty line
  77                ; comment
  78                haha   ="beta" # last silly comment
  79[nextSection] noNewline = ouch
  80EOF
  81
  82git-config-set beta.haha alpha
  83
  84cat > expect << EOF
  85[beta] ; silly comment # another comment
  86noIndent= sillyValue ; 'nother silly comment
  87
  88# empty line
  89                ; comment
  90        haha = alpha
  91[nextSection] noNewline = ouch
  92EOF
  93
  94test_expect_success 'really mean test' 'cmp .git/config expect'
  95
  96git-config-set nextsection.nonewline wow
  97
  98cat > expect << EOF
  99[beta] ; silly comment # another comment
 100noIndent= sillyValue ; 'nother silly comment
 101
 102# empty line
 103                ; comment
 104        haha = alpha
 105[nextSection]
 106        nonewline = wow
 107EOF
 108
 109test_expect_success 'really really mean test' 'cmp .git/config expect'
 110
 111git-config-set beta.haha
 112
 113cat > expect << EOF
 114[beta] ; silly comment # another comment
 115noIndent= sillyValue ; 'nother silly comment
 116
 117# empty line
 118                ; comment
 119[nextSection]
 120        nonewline = wow
 121EOF
 122
 123test_expect_success 'unset' 'cmp .git/config expect'
 124
 125git-config-set nextsection.NoNewLine "wow2 for me" "for me$"
 126
 127cat > expect << EOF
 128[beta] ; silly comment # another comment
 129noIndent= sillyValue ; 'nother silly comment
 130
 131# empty line
 132                ; comment
 133[nextSection]
 134        nonewline = wow
 135        NoNewLine = wow2 for me
 136EOF
 137
 138test_expect_success 'multivar' 'cmp .git/config expect'
 139
 140git-config-set nextsection.nonewline "wow3" "wow$"
 141
 142cat > expect << EOF
 143[beta] ; silly comment # another comment
 144noIndent= sillyValue ; 'nother silly comment
 145
 146# empty line
 147                ; comment
 148[nextSection]
 149        nonewline = wow3
 150        NoNewLine = wow2 for me
 151EOF
 152
 153test_expect_success 'multivar replace' 'cmp .git/config expect'
 154
 155test_expect_failure 'ambiguous unset' \
 156        'git-config-set --unset nextsection.nonewline'
 157
 158test_expect_failure 'invalid unset' \
 159        'git-config-set --unset somesection.nonewline'
 160
 161git-config-set --unset nextsection.nonewline "wow3$"
 162
 163cat > expect << EOF
 164[beta] ; silly comment # another comment
 165noIndent= sillyValue ; 'nother silly comment
 166
 167# empty line
 168                ; comment
 169[nextSection]
 170        NoNewLine = wow2 for me
 171EOF
 172
 173test_expect_success 'multivar unset' 'cmp .git/config expect'
 174
 175test_expect_failure 'invalid key' 'git-config-set inval.2key blabla'
 176
 177test_expect_success 'correct key' 'git-config-set 123456.a123 987'
 178
 179test_done
 180