Re: [PATCHv3] fetch: Use the remote's ref name to decide how to describe new refs.
Apologies - this breaks quite a few tests!
For example, t1507-rev-parse-upstream.sh test 5 segfaults.
I'll take another stab at it...
M.
On 12-04-16 11:52 AM, marcnarc@xiplink.com wrote:
Show 54 quoted lines
> From: Marc Branchaud <marcnarc@xiplink.com>
>
> Also, only call a new ref a "branch" if it's under refs/heads/.
>
> Signed-off-by: Marc Branchaud <marcnarc@xiplink.com>
> ---
>
> Re-rolled to work with the remote's ref names.
>
> As before, this is atop of Jens's submodule-recursion fix.
>
> Technically there are now 3 different changes in this patch:
> 1. Switch to using remote ref names.
> 2. Use prefixcomp() consistently.
> 3. Only call a new ref a "branch" if its' under refs/heads.
>
> Should I split this up?
>
> M.
>
>
> builtin/fetch.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/fetch.c b/builtin/fetch.c
> index cfb43df..063c63b 100644
> --- a/builtin/fetch.c
> +++ b/builtin/fetch.c
> @@ -293,14 +293,23 @@ static int update_local_ref(struct ref *ref,
> const char *msg;
> const char *what;
> int r;
> - if (!strncmp(ref->name, "refs/tags/", 10)) {
> + /*
> + * Nicely describe what we're fetching.
> + * Base this on the remote's ref names, as they're
> + * more likely to follow a standard layout.
> + */
> + if (!prefixcmp(ref->peer_ref->name, "refs/tags/")) {
> msg = "storing tag";
> what = _("[new tag]");
> }
> - else {
> + else if (!prefixcmp(ref->peer_ref->name, "refs/heads/")) {
> msg = "storing head";
> what = _("[new branch]");
> }
> + else {
> + msg = "storing ref";
> + what = _("[new ref]");
> + }
>
> if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
> (recurse_submodules != RECURSE_SUBMODULES_ON))