"Johannes Schindelin via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes: > From: Johannes Schindelin <johannes.schindelin@xxxxxx> > > Currently, when called with exactly two arguments, `git range-diff` > tests for a literal `..` in each of the two. Likewise, the argument > provided via `--range-diff` to `git format-patch` is checked in the same > manner. > > However, `<commit>^!` is a perfectly valid commit range, equivalent to > `<commit>^..<commit>` according to the `SPECIFYING RANGES` section of > gitrevisions[7]. > > In preparation for allowing more sophisticated ways to specify commit > ranges, let's refactor the check into its own function. I think the sharing between the two makes sense, but the helper function should make it clear in its name that this is "the kind of commit range range-diff wants to take". Among the commit range "git log" and friends can take, range-diff can take only a subset of it, and only a subset of it is meaningful to range-diff (e.g. HEAD^@ is still a commit range you can give to "git log", but it would not make much sense to give it to range-diff). Perhaps s/specifies_commit_range/is_range_diff_range/ or something. > diff --git a/revision.h b/revision.h Move this to range-diff.h, not revision.h which is about true commit ranges. > index 086ff10280d..66777c8e60f 100644 > --- a/revision.h > +++ b/revision.h > @@ -457,4 +457,11 @@ int rewrite_parents(struct rev_info *revs, > */ > struct commit_list *get_saved_parents(struct rev_info *revs, const struct commit *commit); > > +/* > + * Determine whether the given argument defines a commit range, 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. > + */ And s/defines a commit range/is usable as a range to range-diff/ Thanks. > +int specifies_commit_range(const char *range); > + > #endif