Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-03-17 23:50:26 +0300
committerJunio C Hamano <gitster@pobox.com>2017-03-17 23:50:26 +0300
commit153e0d762c15d8a85f0070cd01aff45f5c232e3f (patch)
treece30e210659f99624eb5af4ffcc53266c0070731 /t/t3701-add-interactive.sh
parent2af882be0181ee29aa3a4fb3181b94e9bca53c51 (diff)
parent7288e12cce5db87216eba16441a2c37206e5dcad (diff)
Merge branch 'jk/add-i-use-pathspecs'
"git add -p <pathspec>" unnecessarily expanded the pathspec to a list of individual files that matches the pathspec by running "git ls-files <pathspec>", 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
Diffstat (limited to 't/t3701-add-interactive.sh')
-rwxr-xr-xt/t3701-add-interactive.sh43
1 files changed, 43 insertions, 0 deletions
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index aaa258daa3..f9528fa00c 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -412,4 +412,47 @@ test_expect_success 'patch-mode via -i prompts for files' '
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