Merge branch 'js/range-diff-with-pathspec'

Allow passing a pathspec to "git range-diff".

* js/range-diff-with-pathspec:
  range-diff: optionally accept pathspecs
  range-diff: consistently validate the arguments
  range-diff: reorder argument handling
This commit is contained in:
Junio C Hamano
2022-09-09 12:02:24 -07:00
4 changed files with 94 additions and 26 deletions

View File

@ -162,7 +162,7 @@ test_expect_success 'A^! and A^-<n> (unmodified)' '
'
test_expect_success 'A^{/..} is not mistaken for a range' '
test_must_fail git range-diff topic^.. topic^{/..} 2>error &&
test_must_fail git range-diff topic^.. topic^{/..} -- 2>error &&
test_i18ngrep "not a commit range" error
'
@ -772,6 +772,17 @@ test_expect_success '--left-only/--right-only' '
test_cmp expect actual
'
test_expect_success 'ranges with pathspecs' '
git range-diff topic...mode-only-change -- other-file >actual &&
test_line_count = 2 actual &&
topic_oid=$(git rev-parse --short topic) &&
mode_change_oid=$(git rev-parse --short mode-only-change^) &&
file_change_oid=$(git rev-parse --short mode-only-change) &&
grep "$mode_change_oid" actual &&
! grep "$file_change_oid" actual &&
! grep "$topic_oid" actual
'
test_expect_success 'submodule changes are shown irrespective of diff.submodule' '
git init sub-repo &&
test_commit -C sub-repo sub-first &&