range-diff/format-patch: handle commit ranges other than A..B

In the `SPECIFYING RANGES` section of gitrevisions[7], two ways are
described to specify commit ranges that `range-diff` does not yet
accept: "<commit>^!" and "<commit>^-<n>".

Let's accept them, by parsing them via the revision machinery and
looking for at least one interesting and one uninteresting revision in
the resulting `pending` array.

This also finally lets us reject arguments that _do_ contain `..` but
are not actually ranges, e.g. `HEAD^{/do.. match this}`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Johannes Schindelin
2021-02-05 14:44:48 +00:00
committed by Junio C Hamano
parent 679b5916cd
commit 359f0d754a
3 changed files with 39 additions and 4 deletions

View File

@@ -18,9 +18,7 @@ int show_range_diff(const char *range1, const char *range2,
/*
* Determine whether the given argument is usable as a range argument of `git
* range-diff`, e.g. A..B. Note that this only validates the format but does
* _not_ parse it, i.e. it does _not_ look up the specified commits in the
* local repository.
* range-diff`, e.g. A..B.
*/
int is_range_diff_range(const char *arg);