Thread (6 messages) flat view 6 messages, 3 authors, 2016-06-15

Re: [PATCH] for-each-ref: `:short` format for `refname`

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:45:16

Possibly related (same subject, not in this thread)

Bert Wesarg [off-list ref] wrote:
IMHO the goal of this new format for refname should be, that it can be
used as an ref on the command line. This isn't given with my current
:short proposal (which I call :strip as of now), as Gábor showed. What
we need is the reverse of what happened with refnames given on the
command line to commands like checkout/merge/... The only thing that
comes near to this is this from refs.c:

    const char *ref_rev_parse_rules[] = {
            "%.*s",
            "refs/%.*s",
            "refs/tags/%.*s",
            "refs/heads/%.*s",
            "refs/remotes/%.*s",
            "refs/remotes/%.*s/HEAD",
            NULL
    };

Which doesn't look very useful, because every ref from for_each_ref
would match rule one. So we probably need to try the reverse of this
list.
Yup.  If you search the list backwards and extract the part of the
ref that matches %.*s you'll get a name that other tools can find,
and which is the shortest name possible.

You can still get ambiguous names.  Avoiding them requires going
through all refs and building their short forms, then using the
full ref name for any ref which had more than one name shorten to
the same string.  Ugly, but implementable, and probably something
that should be considered.

-- 
Shawn.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help