Re: [PATCH] ls-remote: add "--diff" option to show only refs that differ

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

 



Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> writes:

> My main use of "git ls-remote" tends to be to check what the other end
> has when some pull request goes wrong (they forgot to push, or they used
> the wrong ref name or whatever), and it ends up being hard to see all
> the relevant data from the noise of people just having the same basic
> tags etc from upstream.
>
> So this adds a "--diff" option that shows only the refs that are
> different from the local repository.  So when somebody asks me to pull,
> I can now just trivially look at what they have that isn't already my
> basic branches and tags.

Most downstream folks seem to care about refs/remotes/origin/$branch
and I think in that context "git ls-remote --diff [origin]" that
compares their refs/heads/* and refs/remotes/origin/* would make
sense.  Your has_ref_locally() seems to return true by comparing
their value with the value of the local ref without any the fetch
refspec mapping.

When one contributor asks you to pull refs/heads/master you want to
go and see if it is different from refs/heads/master you have?

> Comments?
>
> +static int has_ref_locally(const struct ref *ref)
> +{
> +	unsigned char sha1[20];
> +
> +	if (!resolve_ref_unsafe(ref->name, RESOLVE_REF_READING, sha1, NULL))
> +		return 0;
> +
> +	return !hashcmp(ref->old_oid.hash, sha1);
> +}
> +
> @@ -105,6 +121,8 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
>  			continue;
>  		if (!tail_match(pattern, ref->name))
>  			continue;
> +		if (diff && has_ref_locally(ref))
> +			continue;
>  		if (show_symref_target && ref->symref)
>  			printf("ref: %s\t%s\n", ref->symref, ref->name);
>  		printf("%s\t%s\n", oid_to_hex(&ref->old_oid), ref->name);



[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]