summaryrefslogtreecommitdiff
path: root/t/t2016-checkout-patch.sh
diff options
context:
space:
mode:
authorLibravatar Denton Liu <liu.denton@gmail.com>2020-10-07 00:56:15 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-10-07 09:49:05 -0700
commit5602b500c3cd9ac308bf9af0d5f0a79bd2195346 (patch)
treef16567fb4a2d796614bc267ce59f53a0dbdb7dae /t/t2016-checkout-patch.sh
parentGit 2.28 (diff)
downloadtgif-5602b500c3cd9ac308bf9af0d5f0a79bd2195346.tar.xz
builtin/checkout: fix `git checkout -p HEAD...` bug
Running `git checkout -p` with a merge-base rev results in an error: $ git checkout -p HEAD... usage: git diff-index [-m] [--cached] [<common-diff-options>] <tree-ish> [<path>...] common diff options: -z output diff-raw with lines terminated with NUL. -p output patch format. -u synonym for -p. --patch-with-raw output both a patch and the diff-raw format. --stat show diffstat instead of patch. --numstat show numeric diffstat instead of patch. --patch-with-stat output a patch and prepend its diffstat. --name-only show only names of changed files. --name-status show names and status of changed files. --full-index show full object name on index lines. --abbrev=<n> abbreviate object names in diff-tree header and diff-raw. -R swap input file pairs. -B detect complete rewrites. -M detect renames. -C detect copies. --find-copies-harder try unchanged files as candidate for copy detection. -l<n> limit rename attempts up to <n> paths. -O<file> reorder diffs according to the <file>. -S<string> find filepair whose only one side contains the string. --pickaxe-all show all files diff when -S is used and hit is found. -a --text treat all files as text. Cannot close git diff-index --cached --numstat --summary HEAD... -- () at <redacted>/libexec/git-core/git-add--interactive line 183. This happens because checkout passes the literal argument (in the example, `HEAD...`) to diff-index which does not recognise merge-base revs. Fix this by using the hex of the found commit instead of the given name. Note that "HEAD" is handled specially in run_add_interactive() so it's explicitly not changed. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t2016-checkout-patch.sh')
-rwxr-xr-xt/t2016-checkout-patch.sh7
1 files changed, 7 insertions, 0 deletions
diff --git a/t/t2016-checkout-patch.sh b/t/t2016-checkout-patch.sh
index 47aeb0b167..999620e507 100755
--- a/t/t2016-checkout-patch.sh
+++ b/t/t2016-checkout-patch.sh
@@ -59,6 +59,13 @@ test_expect_success PERL 'git checkout -p HEAD with change already staged' '
verify_state dir/foo head head
'
+test_expect_success PERL 'git checkout -p HEAD^...' '
+ # the third n is to get out in case it mistakenly does not apply
+ test_write_lines n y n | git checkout -p HEAD^... &&
+ verify_saved_state bar &&
+ verify_state dir/foo parent parent
+'
+
test_expect_success PERL 'git checkout -p HEAD^' '
# the third n is to get out in case it mistakenly does not apply
test_write_lines n y n | git checkout -p HEAD^ &&