1#!/bin/sh
   2#
   3# Copyright (c) 2006 Junio C Hamano
   4#
   5test_description='quoted output'
   7. ./test-lib.sh
   9FN='濱野'
  11GN='純'
  12HT='    '
  13DQ='"'
  14test_have_prereq MINGW ||
  16echo foo 2>/dev/null > "Name and an${HT}HT"
  17if ! test -f "Name and an${HT}HT"
  18then
  19        # FAT/NTFS does not allow tabs in filenames
  20        skip_all='Your filesystem does not allow tabs in filenames'
  21        test_done
  22fi
  23for_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}
  33test_expect_success 'setup' '
  35        mkdir "$FN" &&
  37        for_each_name "echo initial >\"\$name\"" &&
  38        git add . &&
  39        git commit -q -m Initial &&
  40        for_each_name "echo second >\"\$name\"" &&
  42        git commit -a -m Second &&
  43        for_each_name "echo modified >\"\$name\""
  45'
  47test_expect_success 'setup expected files' '
  49cat >expect.quoted <<\EOF &&
  50Name
  51"Name and a\nLF"
  52"Name and an\tHT"
  53"Name\""
  54With SP in it
  55"\346\277\261\351\207\216\t\347\264\224"
  56"\346\277\261\351\207\216\n\347\264\224"
  57"\346\277\261\351\207\216 \347\264\224"
  58"\346\277\261\351\207\216\"\347\264\224"
  59"\346\277\261\351\207\216/file"
  60"\346\277\261\351\207\216\347\264\224"
  61EOF
  62cat >expect.raw <<\EOF
  64Name
  65"Name and a\nLF"
  66"Name and an\tHT"
  67"Name\""
  68With SP in it
  69"濱野\t純"
  70"濱野\n純"
  71濱野 純
  72"濱野\"純"
  73濱野/file
  74濱野純
  75EOF
  76'
  77test_expect_success 'check fully quoted output from ls-files' '
  79        git ls-files >current && test_cmp expect.quoted current
  81'
  83test_expect_success 'check fully quoted output from diff-files' '
  85        git diff --name-only >current &&
  87        test_cmp expect.quoted current
  88'
  90test_expect_success 'check fully quoted output from diff-index' '
  92        git diff --name-only HEAD >current &&
  94        test_cmp expect.quoted current
  95'
  97test_expect_success 'check fully quoted output from diff-tree' '
  99        git diff --name-only HEAD^ HEAD >current &&
 101        test_cmp expect.quoted current
 102'
 104test_expect_success 'check fully quoted output from ls-tree' '
 106        git ls-tree --name-only -r HEAD >current &&
 108        test_cmp expect.quoted current
 109'
 111test_expect_success 'setting core.quotepath' '
 113        git config --bool core.quotepath false
 115'
 117test_expect_success 'check fully quoted output from ls-files' '
 119        git ls-files >current && test_cmp expect.raw current
 121'
 123test_expect_success 'check fully quoted output from diff-files' '
 125        git diff --name-only >current &&
 127        test_cmp expect.raw current
 128'
 130test_expect_success 'check fully quoted output from diff-index' '
 132        git diff --name-only HEAD >current &&
 134        test_cmp expect.raw current
 135'
 137test_expect_success 'check fully quoted output from diff-tree' '
 139        git diff --name-only HEAD^ HEAD >current &&
 141        test_cmp expect.raw current
 142'
 144test_expect_success 'check fully quoted output from ls-tree' '
 146        git ls-tree --name-only -r HEAD >current &&
 148        test_cmp expect.raw current
 149'
 151test_done