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