1#!/bin/sh
   2#
   3# Copyright (c) 2006 Junio C Hamano
   4#
   5test_description='quoted output'
   7. ./test-lib.sh
   9FN='濱野'
  11GN='純'
  12HT='    '
  13DQ='"'
  14echo foo 2>/dev/null > "Name and an${HT}HT"
  16if ! test -f "Name and an${HT}HT"
  17then
  18        # FAT/NTFS does not allow tabs in filenames
  19        skip_all='Your filesystem does not allow tabs in filenames'
  20        test_done
  21fi
  22for_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" "$FN/file"
  28        do
  29                eval "$1"
  30        done
  31}
  32test_expect_success 'setup' '
  34        mkdir "$FN" &&
  36        for_each_name "echo initial >\"\$name\"" &&
  37        git add . &&
  38        git commit -q -m Initial &&
  39        for_each_name "echo second >\"\$name\"" &&
  41        git commit -a -m Second &&
  42        for_each_name "echo modified >\"\$name\""
  44'
  46test_expect_success 'setup expected files' '
  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
  61cat >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' '
  78        git ls-files >current && test_cmp expect.quoted current
  80'
  82test_expect_success 'check fully quoted output from diff-files' '
  84        git diff --name-only >current &&
  86        test_cmp expect.quoted current
  87'
  89test_expect_success 'check fully quoted output from diff-index' '
  91        git diff --name-only HEAD >current &&
  93        test_cmp expect.quoted current
  94'
  96test_expect_success 'check fully quoted output from diff-tree' '
  98        git diff --name-only HEAD^ HEAD >current &&
 100        test_cmp expect.quoted current
 101'
 103test_expect_success 'check fully quoted output from ls-tree' '
 105        git ls-tree --name-only -r HEAD >current &&
 107        test_cmp expect.quoted current
 108'
 110test_expect_success 'setting core.quotepath' '
 112        git config --bool core.quotepath false
 114'
 116test_expect_success 'check fully quoted output from ls-files' '
 118        git ls-files >current && test_cmp expect.raw current
 120'
 122test_expect_success 'check fully quoted output from diff-files' '
 124        git diff --name-only >current &&
 126        test_cmp expect.raw current
 127'
 129test_expect_success 'check fully quoted output from diff-index' '
 131        git diff --name-only HEAD >current &&
 133        test_cmp expect.raw current
 134'
 136test_expect_success 'check fully quoted output from diff-tree' '
 138        git diff --name-only HEAD^ HEAD >current &&
 140        test_cmp expect.raw current
 141'
 143test_expect_success 'check fully quoted output from ls-tree' '
 145        git ls-tree --name-only -r HEAD >current &&
 147        test_cmp expect.raw current
 148'
 150test_done