]> git.ipfire.org Git - thirdparty/git.git/commit - builtin/rev-parse.c
rev-parse: simplify parsing of ref options
authorJeff King <peff@peff.net>
Wed, 15 Mar 2017 20:08:02 +0000 (16:08 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 15 Mar 2017 21:02:36 +0000 (14:02 -0700)
commitffddfc6328fd3c8b0e8ee69144ec2dda5c766364
tree215aacba5a36d3b2ba8885dbd433b2e16890092e
parent9d16ca65bbe45d4a28cbb37c3299b544c81ff2e8
rev-parse: simplify parsing of ref options

All of these options do the same thing "--foo" iterates over
the "foo" refs, and "--foo=<glob>" does the same with a
glob. We can factor this into its own function to avoid
repeating ourselves.

There are two subtleties to note:

  - the original called for_each_branch_ref(), etc, in the
    non-glob case. Now we will call for_each_ref_in("refs/heads/")
    which is exactly what for_each_branch_ref() did under
    the hood.

  - for --glob, we'll call for_each_glob_ref_in() with a
    NULL "prefix" argument. Which is exactly what
    for_each_glob_ref() was doing already.

So both cases should behave identically, and it seems
reasonable to assume that this will remain the same. The
functions we are calling now are the more-generic ones, and
the ones we are dropping are just convenience wrappers.

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