From: Junio C Hamano Date: Fri, 17 Mar 2017 20:50:26 +0000 (-0700) Subject: Merge branch 'jk/add-i-use-pathspecs' X-Git-Tag: v2.13.0-rc0~103 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=153e0d762c15d8a85f0070cd01aff45f5c232e3f;p=git-core%2Fgit.git Merge branch 'jk/add-i-use-pathspecs' "git add -p " unnecessarily expanded the pathspec to a list of individual files that matches the pathspec by running "git ls-files ", before feeding it to "git diff-index" to see which paths have changes, because historically the pathspec language supported by "diff-index" was weaker. These days they are equivalent and there is no reason to internally expand it. This helps both performance and avoids command line argument limit on some platforms. * jk/add-i-use-pathspecs: add--interactive: do not expand pathspecs with ls-files --- 153e0d762c15d8a85f0070cd01aff45f5c232e3f diff --cc t/t3701-add-interactive.sh index aaa258daa,d8dcc977f..f9528fa00 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@@ -394,22 -394,47 +394,65 @@@ test_expect_success 'diffs can be color grep "$(printf "\\033")" output ' +test_expect_success 'patch-mode via -i prompts for files' ' + git reset --hard && + + echo one >file && + echo two >test && + git add -i <<-\EOF && + patch + test + + y + quit + EOF + + echo test >expect && + git diff --cached --name-only >actual && + test_cmp expect actual +' + + test_expect_success 'add -p handles globs' ' + git reset --hard && + + mkdir -p subdir && + echo base >one.c && + echo base >subdir/two.c && + git add "*.c" && + git commit -m base && + + echo change >one.c && + echo change >subdir/two.c && + git add -p "*.c" <<-\EOF && + y + y + EOF + + cat >expect <<-\EOF && + one.c + subdir/two.c + EOF + git diff --cached --name-only >actual && + test_cmp expect actual + ' + + test_expect_success 'add -p does not expand argument lists' ' + git reset --hard && + + echo content >not-changed && + git add not-changed && + git commit -m "add not-changed file" && + + echo change >file && + GIT_TRACE=$(pwd)/trace.out git add -p . <<-\EOF && + y + EOF + + # we know that "file" must be mentioned since we actually + # update it, but we want to be sure that our "." pathspec + # was not expanded into the argument list of any command. + # So look only for "not-changed". + ! grep not-changed trace.out + ' + test_done