summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-02-25 16:43:31 -0800
committerJunio C Hamano <gitster@pobox.com>2021-02-25 16:43:31 -0800
commit6eea44cee1dc94a7d6f7fa768d5710f9385f22db (patch)
treedc9ac2d574c1ba05912e446cab6400c04c0fd578
parentMerge branch 'cw/pack-config-doc' (diff)
parentdifftool.c: learn a new way start at specified file (diff)
downloadgit-6eea44cee1dc94a7d6f7fa768d5710f9385f22db.tar.xz
git-6eea44cee1dc94a7d6f7fa768d5710f9385f22db.zip
Merge branch 'zh/difftool-skip-to'
"git difftool" learned "--skip-to=<path>" option to restart an interrupted session from an arbitrary path. * zh/difftool-skip-to: difftool.c: learn a new way start at specified file
-rw-r--r--Documentation/git-difftool.txt8
-rwxr-xr-xt/t7800-difftool.sh32
2 files changed, 40 insertions, 0 deletions
diff --git a/Documentation/git-difftool.txt b/Documentation/git-difftool.txt
index 484c485fd06..143b0c49d73 100644
--- a/Documentation/git-difftool.txt
+++ b/Documentation/git-difftool.txt
@@ -34,6 +34,14 @@ OPTIONS
This is the default behaviour; the option is provided to
override any configuration settings.
+--rotate-to=<file>::
+ Start showing the diff for the given path,
+ the paths before it will move to end and output.
+
+--skip-to=<file>::
+ Start showing the diff for the given path, skipping all
+ the paths before it.
+
-t <tool>::
--tool=<tool>::
Use the diff tool specified by <tool>. Valid values include
diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
index 9192c141ffc..3e041e83aed 100755
--- a/t/t7800-difftool.sh
+++ b/t/t7800-difftool.sh
@@ -762,4 +762,36 @@ test_expect_success 'difftool --gui, --tool and --extcmd are mutually exclusive'
test_must_fail git difftool --gui --tool=test-tool --extcmd=cat
'
+test_expect_success 'difftool --rotate-to' '
+ difftool_test_setup &&
+ test_when_finished git reset --hard &&
+ echo 1 >1 &&
+ echo 2 >2 &&
+ echo 4 >4 &&
+ git add 1 2 4 &&
+ git commit -a -m "124" &&
+ git difftool --no-prompt --extcmd=cat --rotate-to="2" HEAD^ >output&&
+ cat >expect <<-\EOF &&
+ 2
+ 4
+ 1
+ EOF
+ test_cmp output expect
+'
+
+test_expect_success 'difftool --skip-to' '
+ difftool_test_setup &&
+ test_when_finished git reset --hard &&
+ git difftool --no-prompt --extcmd=cat --skip-to="2" HEAD^ >output &&
+ cat >expect <<-\EOF &&
+ 2
+ 4
+ EOF
+ test_cmp output expect
+'
+
+test_expect_success 'difftool --rotate/skip-to error condition' '
+ test_must_fail git difftool --no-prompt --extcmd=cat --rotate-to="3" HEAD^ &&
+ test_must_fail git difftool --no-prompt --extcmd=cat --skip-to="3" HEAD^
+'
test_done