blame: allow user to specify rev arguments to blame
commit58ca811a5d63b93ab2007a5899f82e546cb24813
authorJeff King <peff@peff.net>
Tue, 15 Sep 2015 08:06:20 +0000 (15 04:06 -0400)
committerJeff King <peff@peff.net>
Tue, 15 Sep 2015 09:26:39 +0000 (15 05:26 -0400)
treeee83bb015f7bf046198513c1e7c5ab6846f65b0d
parent4951c2e50edae06dc20224c6ad1fe1eba0f46b44
blame: allow user to specify rev arguments to blame

The options parser for blame is currently quite strict, and
can handle only a single positive revision in opt_rev_args.
But there are several parsing problems with this:

 1. If you run "tig blame --reverse foo.c", the "--reverse"
    flag ends up in opt_rev_args (filter_options knows it's a
    flag, but since it is a revision flag, it gets put
    there).

    We try to access "--reverse.c:foo.c", which is
    nonsensical. Moreover, if you did specify a start-point
    like "HEAD foo.c", tig will complain that you have more
    than one revision arg.

 2. If you run "tig blame --since=123", this is converted by
    "rev-parse --revs-only" to "--max-age=123", and is
    included in opt_rev_args, and you run into the same
    problems as above.

 3. If you run "tig blame HEAD~20..HEAD", the commit range
    is split into two arguments, "HEAD" and "^HEAD~20", both
    of which end up in opt_rev_args. Similarly, the user can
    specify this "split" form themselves.

We can fix this by further parsing opt_rev_args. Instead of
assuming that it must contain zero or one arguments, we can
pick out the "positive" ref as our starting point (and
complain if there is more than one).

The rest of the rev-args we add to %(blameargs), so that
git-blame can act on them.
src/blame.c
test/blame/revargs-test [new file with mode: 0755]