range-diff: optionally accept pathspecs
The `git range-diff` command can be quite expensive, which is not a surprise given that the underlying algorithm to match up pairs of commits between the provided two commit ranges has a cubic runtime. Therefore it makes sense to restrict the commit ranges as much as possible, to reduce the amount of input to that O(N^3) algorithm. In chatty repositories with wide trees, this is not necessarily possible merely by choosing commit ranges wisely. Let's give users another option to restrict the commit ranges: by providing a pathspec. That helps in repositories with wide trees because it is likely that the user has a good idea which subset of the tree they are actually interested in. Example: git range-diff upstream/main upstream/seen HEAD -- range-diff.c This shows commits that are either in the local branch or in `seen`, but not in `main`, skipping all commits that do not touch `range-diff.c`. Note: Since we piggy-back the pathspecs onto the `other_arg` mechanism that was introduced to be able to pass through the `--notes` option to the revision machinery, we must now ensure that the `other_arg` array is appended at the end (the revision range must come before the pathspecs, if any). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
0087d7dfbe
commit
b75747829f
@ -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 &&
|
||||
|
Reference in New Issue
Block a user