#!/bin/sh # # Copyright (c) 2006 Junio C Hamano # global test_description := ''quoted output'' source ./test-lib.sh global FN := ''濱野'' global GN := ''純'' global HT := '' '' global DQ := ''"'' test_have_prereq MINGW || echo foo !2 >/dev/null > "Name and an$(HT)HT" if ! test -f "Name and an$(HT)HT" { # FAT/NTFS does not allow tabs in filenames global skip_all := ''Your filesystem does not allow tabs in filenames'' test_done } proc for_each_name { for name in [\ Name "Name and a$(LF)LF" "Name and an$(HT)HT" "Name$(DQ)" \ "$FN$HT$GN" "$FN$LF$GN" "$FN $GN" "$FN$GN" "$FN$DQ$GN" \ "With SP in it" "$FN/file]" { eval $1 } } test_expect_success 'setup' ' mkdir "$FN" && for_each_name "echo initial >\"\$name\"" && git add . && git commit -q -m Initial && for_each_name "echo second >\"\$name\"" && git commit -a -m Second && for_each_name "echo modified >\"\$name\"" ' test_expect_success 'setup expected files' ' cat >expect.quoted <<\EOF && Name "Name and a\nLF" "Name and an\tHT" "Name\"" With SP in it "\346\277\261\351\207\216\t\347\264\224" "\346\277\261\351\207\216\n\347\264\224" "\346\277\261\351\207\216 \347\264\224" "\346\277\261\351\207\216\"\347\264\224" "\346\277\261\351\207\216/file" "\346\277\261\351\207\216\347\264\224" EOF cat >expect.raw <<\EOF Name "Name and a\nLF" "Name and an\tHT" "Name\"" With SP in it "濱野\t純" "濱野\n純" 濱野 純 "濱野\"純" 濱野/file 濱野純 EOF ' test_expect_success 'check fully quoted output from ls-files' ' git ls-files >current && test_cmp expect.quoted current ' test_expect_success 'check fully quoted output from diff-files' ' git diff --name-only >current && test_cmp expect.quoted current ' test_expect_success 'check fully quoted output from diff-index' ' git diff --name-only HEAD >current && test_cmp expect.quoted current ' test_expect_success 'check fully quoted output from diff-tree' ' git diff --name-only HEAD^ HEAD >current && test_cmp expect.quoted current ' test_expect_success 'check fully quoted output from ls-tree' ' git ls-tree --name-only -r HEAD >current && test_cmp expect.quoted current ' test_expect_success 'setting core.quotepath' ' git config --bool core.quotepath false ' test_expect_success 'check fully quoted output from ls-files' ' git ls-files >current && test_cmp expect.raw current ' test_expect_success 'check fully quoted output from diff-files' ' git diff --name-only >current && test_cmp expect.raw current ' test_expect_success 'check fully quoted output from diff-index' ' git diff --name-only HEAD >current && test_cmp expect.raw current ' test_expect_success 'check fully quoted output from diff-tree' ' git diff --name-only HEAD^ HEAD >current && test_cmp expect.raw current ' test_expect_success 'check fully quoted output from ls-tree' ' git ls-tree --name-only -r HEAD >current && test_cmp expect.raw current ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"quoted output">)} spids: [13] ) ] spids: [13] ) (C {(.)} {(./test-lib.sh)}) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:FN) op:Equal rhs:{(SQ <"\u6ff1\u91ce">)} spids:[24])] spids: [24] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:GN) op:Equal rhs:{(SQ <"\u7d14">)} spids:[29])] spids: [29] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:HT) op:Equal rhs:{(SQ <"\t">)} spids:[34])] spids: [34] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:DQ) op:Equal rhs:{(SQ <"\"">)} spids:[39])] spids: [39] ) (AndOr children: [ (C {(test_have_prereq)} {(MINGW)}) (SimpleCommand words: [{(echo)} {(foo)}] redirects: [ (Redir op_id:Redir_Great fd:2 arg_word:{(/dev/null)} spids:[55]) (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ ("Name and an") (${ VSub_Name HT) (HT))} spids: [58] ) ] ) ] op_id: Op_DPipe ) (If arms: [ (if_arm cond: [ (Pipeline children: [(C {(test)} {(-f)} {(DQ ("Name and an") (${ VSub_Name HT) (HT))})] negated: True ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:skip_all) op: Equal rhs: {(SQ <"Your filesystem does not allow tabs in filenames">)} spids: [91] ) ] spids: [91] ) (C {(test_done)}) ] spids: [-1 84] ) ] spids: [-1 99] ) (FuncDef name: for_each_name body: (BraceGroup children: [ (ForEach iter_name: name iter_words: [ {(Name)} {(DQ ("Name and a") (${ VSub_Name LF) (LF))} {(DQ ("Name and an") (${ VSub_Name HT) (HT))} {(DQ (Name) (${ VSub_Name DQ))} {(DQ ($ VSub_Name "$FN") ($ VSub_Name "$HT") ($ VSub_Name "$GN"))} {(DQ ($ VSub_Name "$FN") ($ VSub_Name "$LF") ($ VSub_Name "$GN"))} {(DQ ($ VSub_Name "$FN") (" ") ($ VSub_Name "$GN"))} {(DQ ($ VSub_Name "$FN") ($ VSub_Name "$GN"))} {(DQ ($ VSub_Name "$FN") ($ VSub_Name "$DQ") ($ VSub_Name "$GN"))} {(DQ ("With SP in it"))} {(DQ ($ VSub_Name "$FN") (/file))} ] do_arg_iter: False body: (DoGroup children:[(C {(eval)} {(DQ ($ VSub_Number "$1"))})] spids:[186196]) spids: [115 -1] ) ] spids: [107] ) spids: [102 106] ) (C {(test_expect_success)} {(SQ )} { (SQ <"\n"> <"\n"> <"\tmkdir \"$FN\" &&\n"> <"\tfor_each_name \"echo initial >\\\"\\$name\\\"\" &&\n"> <"\tgit add . &&\n"> <"\tgit commit -q -m Initial &&\n"> <"\n"> <"\tfor_each_name \"echo second >\\\"\\$name\\\"\" &&\n"> <"\tgit commit -a -m Second &&\n"> <"\n"> <"\tfor_each_name \"echo modified >\\\"\\$name\\\"\"\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup expected files">)} { (SQ <"\n"> <"cat >expect.quoted <<\\EOF &&\n"> <"Name\n"> <"\"Name and a\\nLF\"\n"> <"\"Name and an\\tHT\"\n"> <"\"Name\\\"\"\n"> <"With SP in it\n"> <"\"\\346\\277\\261\\351\\207\\216\\t\\347\\264\\224\"\n"> <"\"\\346\\277\\261\\351\\207\\216\\n\\347\\264\\224\"\n"> <"\"\\346\\277\\261\\351\\207\\216 \\347\\264\\224\"\n"> <"\"\\346\\277\\261\\351\\207\\216\\\"\\347\\264\\224\"\n"> <"\"\\346\\277\\261\\351\\207\\216/file\"\n"> <"\"\\346\\277\\261\\351\\207\\216\\347\\264\\224\"\n"> <"EOF\n"> <"\n"> <"cat >expect.raw <<\\EOF\n"> <"Name\n"> <"\"Name and a\\nLF\"\n"> <"\"Name and an\\tHT\"\n"> <"\"Name\\\"\"\n"> <"With SP in it\n"> <"\"\u6ff1\u91ce\\t\u7d14\"\n"> <"\"\u6ff1\u91ce\\n\u7d14\"\n"> <"\u6ff1\u91ce \u7d14\n"> <"\"\u6ff1\u91ce\\\"\u7d14\"\n"> <"\u6ff1\u91ce/file\n"> <"\u6ff1\u91ce\u7d14\n"> <"EOF\n"> ) } ) (C {(test_expect_success)} {(SQ <"check fully quoted output from ls-files">)} {(SQ <"\n"> <"\n"> <"\tgit ls-files >current && test_cmp expect.quoted current\n"> <"\n">)} ) (C {(test_expect_success)} {(SQ <"check fully quoted output from diff-files">)} { (SQ <"\n"> <"\n"> <"\tgit diff --name-only >current &&\n"> <"\ttest_cmp expect.quoted current\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"check fully quoted output from diff-index">)} { (SQ <"\n"> <"\n"> <"\tgit diff --name-only HEAD >current &&\n"> <"\ttest_cmp expect.quoted current\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"check fully quoted output from diff-tree">)} { (SQ <"\n"> <"\n"> <"\tgit diff --name-only HEAD^ HEAD >current &&\n"> <"\ttest_cmp expect.quoted current\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"check fully quoted output from ls-tree">)} { (SQ <"\n"> <"\n"> <"\tgit ls-tree --name-only -r HEAD >current &&\n"> <"\ttest_cmp expect.quoted current\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"setting core.quotepath">)} {(SQ <"\n"> <"\n"> <"\tgit config --bool core.quotepath false\n"> <"\n">)} ) (C {(test_expect_success)} {(SQ <"check fully quoted output from ls-files">)} {(SQ <"\n"> <"\n"> <"\tgit ls-files >current && test_cmp expect.raw current\n"> <"\n">)} ) (C {(test_expect_success)} {(SQ <"check fully quoted output from diff-files">)} { (SQ <"\n"> <"\n"> <"\tgit diff --name-only >current &&\n"> <"\ttest_cmp expect.raw current\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"check fully quoted output from diff-index">)} { (SQ <"\n"> <"\n"> <"\tgit diff --name-only HEAD >current &&\n"> <"\ttest_cmp expect.raw current\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"check fully quoted output from diff-tree">)} { (SQ <"\n"> <"\n"> <"\tgit diff --name-only HEAD^ HEAD >current &&\n"> <"\ttest_cmp expect.raw current\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"check fully quoted output from ls-tree">)} { (SQ <"\n"> <"\n"> <"\tgit ls-tree --name-only -r HEAD >current &&\n"> <"\ttest_cmp expect.raw current\n"> <"\n"> ) } ) (C {(test_done)}) ] )