Skip to content

Commit 6eea44c

Browse files
committed
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
2 parents ccf6861 + 1c88102 commit 6eea44c

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

Documentation/git-difftool.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ OPTIONS
3434
This is the default behaviour; the option is provided to
3535
override any configuration settings.
3636

37+
--rotate-to=<file>::
38+
Start showing the diff for the given path,
39+
the paths before it will move to end and output.
40+
41+
--skip-to=<file>::
42+
Start showing the diff for the given path, skipping all
43+
the paths before it.
44+
3745
-t <tool>::
3846
--tool=<tool>::
3947
Use the diff tool specified by <tool>. Valid values include

t/t7800-difftool.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,4 +762,36 @@ test_expect_success 'difftool --gui, --tool and --extcmd are mutually exclusive'
762762
test_must_fail git difftool --gui --tool=test-tool --extcmd=cat
763763
'
764764

765+
test_expect_success 'difftool --rotate-to' '
766+
difftool_test_setup &&
767+
test_when_finished git reset --hard &&
768+
echo 1 >1 &&
769+
echo 2 >2 &&
770+
echo 4 >4 &&
771+
git add 1 2 4 &&
772+
git commit -a -m "124" &&
773+
git difftool --no-prompt --extcmd=cat --rotate-to="2" HEAD^ >output&&
774+
cat >expect <<-\EOF &&
775+
2
776+
4
777+
1
778+
EOF
779+
test_cmp output expect
780+
'
781+
782+
test_expect_success 'difftool --skip-to' '
783+
difftool_test_setup &&
784+
test_when_finished git reset --hard &&
785+
git difftool --no-prompt --extcmd=cat --skip-to="2" HEAD^ >output &&
786+
cat >expect <<-\EOF &&
787+
2
788+
4
789+
EOF
790+
test_cmp output expect
791+
'
792+
793+
test_expect_success 'difftool --rotate/skip-to error condition' '
794+
test_must_fail git difftool --no-prompt --extcmd=cat --rotate-to="3" HEAD^ &&
795+
test_must_fail git difftool --no-prompt --extcmd=cat --skip-to="3" HEAD^
796+
'
765797
test_done

0 commit comments

Comments
 (0)