• Rafael Ascensão's avatar
    log: add option to choose which refs to decorate · 65516f58
    Rafael Ascensão authored
    When `log --decorate` is used, git will decorate commits with all
    available refs. While in most cases this may give the desired effect,
    under some conditions it can lead to excessively verbose output.
    Introduce two command line options, `--decorate-refs=<pattern>` and
    `--decorate-refs-exclude=<pattern>` to allow the user to select which
    refs are used in decoration.
    When "--decorate-refs=<pattern>" is given, only the refs that match the
    pattern are used in decoration. The refs that match the pattern when
    "--decorate-refs-exclude=<pattern>" is given, are never used in
    These options follow the same convention for mixing negative and
    positive patterns across the system, assuming that the inclusive default
    is to match all refs available.
     (1) if there is no positive pattern given, pretend as if an
         inclusive default positive pattern was given;
     (2) for each candidate, reject it if it matches no positive
         pattern, or if it matches any one of the negative patterns.
    The rules for what is considered a match are slightly different from the
    rules used elsewhere.
    Commands like `log --glob` assume a trailing '/*' when glob chars are
    not present in the pattern. This makes it difficult to specify a single
    ref.  On the other hand, commands like `describe --match --all` allow
    specifying exact refs, but do not have the convenience of allowing
    "shorthand refs" like 'refs/heads' or 'heads' to refer to
    The commands introduced in this patch consider a match if:
      (a) the pattern contains globs chars,
    	and regular pattern matching returns a match.
      (b) the pattern does not contain glob chars,
             and ref '<pattern>' exists, or if ref exists under '<pattern>/'
    This allows both behaviours (allowing single refs and shorthand refs)
    yet remaining compatible with existent commands.
    Helped-by: default avatarKevin Daudt <me@ikke.info>
    Helped-by: default avatarJunio C Hamano <gitster@pobox.com>
    Signed-off-by: default avatarRafael Ascensão <rafa.almas@gmail.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
refs.h 28.9 KB