t / t3902-quoted.shon commit notes: check number of parameters to "git notes copy" (bbb1b8a)
   1#!/bin/sh
   2#
   3# Copyright (c) 2006 Junio C Hamano
   4#
   5
   6test_description='quoted output'
   7
   8. ./test-lib.sh
   9
  10FN='濱野'
  11GN='純'
  12HT='    '
  13LF='
  14'
  15DQ='"'
  16
  17echo foo 2>/dev/null > "Name and an${HT}HT"
  18test -f "Name and an${HT}HT" || {
  19        # since FAT/NTFS does not allow tabs in filenames, skip this test
  20        say 'Your filesystem does not allow tabs in filenames, test skipped.'
  21        test_done
  22}
  23
  24for_each_name () {
  25        for name in \
  26            Name "Name and a${LF}LF" "Name and an${HT}HT" "Name${DQ}" \
  27            "$FN$HT$GN" "$FN$LF$GN" "$FN $GN" "$FN$GN" "$FN$DQ$GN" \
  28            "With SP in it" "$FN/file"
  29        do
  30                eval "$1"
  31        done
  32}
  33
  34test_expect_success setup '
  35
  36        mkdir "$FN" &&
  37        for_each_name "echo initial >\"\$name\""
  38        git add . &&
  39        git commit -q -m Initial &&
  40
  41        for_each_name "echo second >\"\$name\"" &&
  42        git commit -a -m Second
  43
  44        for_each_name "echo modified >\"\$name\""
  45
  46'
  47
  48cat >expect.quoted <<\EOF
  49Name
  50"Name and a\nLF"
  51"Name and an\tHT"
  52"Name\""
  53With SP in it
  54"\346\277\261\351\207\216\t\347\264\224"
  55"\346\277\261\351\207\216\n\347\264\224"
  56"\346\277\261\351\207\216 \347\264\224"
  57"\346\277\261\351\207\216\"\347\264\224"
  58"\346\277\261\351\207\216/file"
  59"\346\277\261\351\207\216\347\264\224"
  60EOF
  61
  62cat >expect.raw <<\EOF
  63Name
  64"Name and a\nLF"
  65"Name and an\tHT"
  66"Name\""
  67With SP in it
  68"濱野\t純"
  69"濱野\n純"
  70濱野 純
  71"濱野\"純"
  72濱野/file
  73濱野純
  74EOF
  75
  76test_expect_success 'check fully quoted output from ls-files' '
  77
  78        git ls-files >current && test_cmp expect.quoted current
  79
  80'
  81
  82test_expect_success 'check fully quoted output from diff-files' '
  83
  84        git diff --name-only >current &&
  85        test_cmp expect.quoted current
  86
  87'
  88
  89test_expect_success 'check fully quoted output from diff-index' '
  90
  91        git diff --name-only HEAD >current &&
  92        test_cmp expect.quoted current
  93
  94'
  95
  96test_expect_success 'check fully quoted output from diff-tree' '
  97
  98        git diff --name-only HEAD^ HEAD >current &&
  99        test_cmp expect.quoted current
 100
 101'
 102
 103test_expect_success 'check fully quoted output from ls-tree' '
 104
 105        git ls-tree --name-only -r HEAD >current &&
 106        test_cmp expect.quoted current
 107
 108'
 109
 110test_expect_success 'setting core.quotepath' '
 111
 112        git config --bool core.quotepath false
 113
 114'
 115
 116test_expect_success 'check fully quoted output from ls-files' '
 117
 118        git ls-files >current && test_cmp expect.raw current
 119
 120'
 121
 122test_expect_success 'check fully quoted output from diff-files' '
 123
 124        git diff --name-only >current &&
 125        test_cmp expect.raw current
 126
 127'
 128
 129test_expect_success 'check fully quoted output from diff-index' '
 130
 131        git diff --name-only HEAD >current &&
 132        test_cmp expect.raw current
 133
 134'
 135
 136test_expect_success 'check fully quoted output from diff-tree' '
 137
 138        git diff --name-only HEAD^ HEAD >current &&
 139        test_cmp expect.raw current
 140
 141'
 142
 143test_expect_success 'check fully quoted output from ls-tree' '
 144
 145        git ls-tree --name-only -r HEAD >current &&
 146        test_cmp expect.raw current
 147
 148'
 149
 150test_done