From: Junio C Hamano <gitster@pobox.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] ls-remote: add "--diff" option to show only refs that differ
Date: Thu, 02 Feb 2017 12:03:09 -0800 [thread overview]
Message-ID: <xmqqshnws6ma.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <alpine.LFD.2.20.1702021143470.21619@i7.lan> (Linus Torvalds's message of "Thu, 2 Feb 2017 11:49:50 -0800 (PST)")
Linus Torvalds <torvalds@linux-foundation.org> 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);
next prev parent reply other threads:[~2017-02-02 20:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-02 19:49 [PATCH] ls-remote: add "--diff" option to show only refs that differ Linus Torvalds
2017-02-02 20:03 ` Junio C Hamano [this message]
2017-02-02 20:32 ` Linus Torvalds
2017-02-02 21:05 ` Junio C Hamano
2017-02-02 21:19 ` Linus Torvalds
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqshnws6ma.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox