]> git.ipfire.org Git - thirdparty/git.git/commit - revision.c
handle_revision_arg: add handle_dotdot() helper
authorJeff King <peff@peff.net>
Fri, 19 May 2017 12:52:00 +0000 (08:52 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 24 May 2017 01:59:27 +0000 (10:59 +0900)
commit62faad5aa5441942c333c15f3afa03a6e2dd994d
tree21f47d8f1c7c5a134f38c26fb0a8050223b9f09f
parentd89797feff053bba939b62ee442f56e3fc98062b
handle_revision_arg: add handle_dotdot() helper

The handle_revision_arg function is rather long, and a big
chunk of it is handling the range operators. Let's pull that
out to a separate helper. While we're doing so, we can clean
up a few of the rough edges that made the flow hard to
follow:

  - instead of manually restoring *dotdot (that we overwrote
    with a NUL), do the real work in a sub-helper, which
    makes it clear that the munge/restore lines are a
    matched pair

  - eliminate a goto which wasn't actually used for control
    flow, but only to avoid duplicating a few lines
    (instead, those lines are pushed into another helper
    function)

  - use early returns instead of deep nesting

  - consistently name all variables for the left-hand side
    of the range as "a" (rather than "this" or "from") and
    the right-hand side as "b" (rather than "next", or using
    the unadorned "sha1" or "flags" from the main function).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
revision.c