Re: Re* [PATCH] Fix `git fetch --tags` in repo with no configured remote

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <gitster@xxxxxxxxx> writes:

> +static int uses_remote_tracking(struct transport *transport, struct refspec *rs)
> +{
> +	if (!remote_is_configured(transport->remote, 0))
> +		return 0;
> +
> +	if (!rs->nr)
> +		rs = &transport->remote->fetch;
> +
> +	for (int i = 0; i < rs->nr; i++)
> +		if (rs->items[i].dst)
> +			return 1;
> +
> +	return 0;
> +}

For the purpose of adjusting refs/remotes/<name>/HEAD, which is
expected to point at something that we copy from their refs/heads/,
it may be tempting to tighten the above logic to say, instead of "we
have a refspec item that stores to somewhere", do something like

	for (int i = 0; i < rs->nr; i++) {
		struct refspec_item *item = &rs->items[i];

		if (item->dst &&
		    item->src && starts_with(item->src, "refs/heads/"))
			return 1;
	}

to make sure that we are tracking their branch refs, not some random
hierarchy for which refs/remotes/<name>/HEAD does not matter.

I will leave the simplest "just check we have .dst" version (in
other words, without any additional check on the .src side) in my
tree, but if anybody wants to pursue "let's make sure that .src
copies from somewhere in refs/heads/", please make sure that you
consider "--mirror", where an equivalent of "refs/*:refs/*" is used
as the refspec, i.e. there is a case where .src does not begin with
"refs/heads/" but does cover the hierarchy and wants to learn about
"HEAD".

Thanks.







[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux