From: Junio C Hamano <gitster@pobox.com>
To: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: Duy Nguyen <pclouds@gmail.com>, Git List <git@vger.kernel.org>
Subject: Re: [PATCH 7/7] sha1_name: implement finding @{push}
Date: Fri, 24 May 2013 12:12:40 -0700 [thread overview]
Message-ID: <7vsj1c8a53.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <CALkWK0mmJE3Q2WU3pmhWdcrxv=jFXb8oVhPCRW+Zc6yLdDmfUg@mail.gmail.com> (Ramkumar Ramachandra's message of "Fri, 24 May 2013 23:51:32 +0530")
Ramkumar Ramachandra <artagnon@gmail.com> writes:
> Junio C Hamano wrote:
>>>> rev-parse (with an option, maybe) may be a better place for
>>>> this.
>>>
>>> Er, no. I actually want things like diff @{p}..HEAD. I want it to be
>>> a first-class revision, just like @{u}.
>>
>> I think Duy's suggestion makes perfect sense; rev-parse already has
>> a mechanism to expand @{u} to the full name, so if you are hooking
>> into the same codepath as @{u} to implement the "I publish there"
>> information, which I think you should, you already should have it
>> for free.
>
> *scratches head*
>
> Okay, I'm not understanding this.
> ... How do I get "I publish
> there" information for free?
That is not what I said.
Let's step back a bit and think what it means that @{u} can be used
to name "The latest, as best of my knowledge, of the possibly moving
ref that my work is based on". You can do so by
(1) having a ref that points at such commit and having a mechanism
to keep the ref up to date;
(2) having a mechansim to turn @{u} to such a ref; and
(3) letting get_sha1() machinery to read from that ref when an
object name is needed for @{u}.
None of the above is what rev-parse does, but because you have (2),
rev-parse --symbolic-full-name can just ask (2) for a refname.
That is what I meant by "for free", and "which I think you should"
refers to all of these three things you would do to keep track of
"The latest, as best of my knowledge, of the possibly moving ref
that points at the commit I pushed the last time" for your @{p} in a
way similar to how @{u} works.
If I understand correctly the discussion so far, for a given branch
B, "git push" (no arguments to specify to which repository to push
nor what branch to update) would decide what the user did not say by
looking at:
- branch.B.pushremote (and using remote.pushdefault and
branch.B.remote as fallbacks) to find what repository R to
push to;
- branch.B.push (or mapping B through remote.R.push refspecs as
a fallback logic) to find what destination branch D at R is
updated by B.
Then after "git push" succeeds, it would look at remote.R.fetch
refspecs to pretend as if we fetched immediately from R, which is
how we keep track of the "last pushed" state, which is (1) of the
necessary three.
It follows that for B@{p} to be "The last pushed" for B, it has to
resolve to a remote tracking branch for D from R. That (i.e. find R
and D and then map it through R's fetch refspec) is the logic we
need for (2). That is very similar for B@{u}, which should be to
find the repository O it comes from by looking at branch.B.remote
(or 'origin'), and then where branch.B.merge from O is stored in our
ref namespace (e.g. refs/remotes/origin/topic) by mapping it through
the remote.O.fetch refspec.
Once you have (2), the implementation of (3) is quite obvious. We
know where in the codeflow @{u} is turned into a ref; we can do the
same for @{p} by calling the logic (2) from the same place to turn
@{p} into a ref.
It is worth noting that @{p} has one error case that @{u} does not,
whose only error case is essentially that the branch you are asking
for @{u} does not have "upstream" configured.
For "git push" to work, you only need to be able to compute R and D
for B. But R does not necessarily need to have fetch refspec for a
triangular pushing to work, hence we may not be recording what we
pushed the last time, violating (1), which in turn means (2) may not
have an answer.
prev parent reply other threads:[~2013-05-24 19:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-23 15:12 [PATCH 0/7] Let's get that @{push}! Ramkumar Ramachandra
2013-05-23 15:12 ` [PATCH 1/7] sha1_name: abstract upstream_mark() logic Ramkumar Ramachandra
2013-05-23 15:12 ` [PATCH 2/7] sha1_name: factor out die_no_upstream() Ramkumar Ramachandra
2013-05-23 15:12 ` [PATCH 3/7] sha1_name: remove upstream_mark() Ramkumar Ramachandra
2013-05-23 15:12 ` [PATCH 4/7] remote: expose parse_push_refspec() Ramkumar Ramachandra
2013-05-23 15:12 ` [PATCH 5/7] remote: expose get_ref_match() Ramkumar Ramachandra
2013-05-23 15:12 ` [PATCH 6/7] sha1_name: prepare to introduce AT_KIND_PUSH Ramkumar Ramachandra
2013-05-24 13:22 ` Felipe Contreras
2013-05-24 13:27 ` Ramkumar Ramachandra
2013-05-23 15:12 ` [PATCH 7/7] sha1_name: implement finding @{push} Ramkumar Ramachandra
2013-05-24 16:09 ` Duy Nguyen
2013-05-24 16:15 ` Ramkumar Ramachandra
2013-05-24 16:21 ` Duy Nguyen
2013-05-24 16:29 ` Ramkumar Ramachandra
2013-05-24 18:01 ` Junio C Hamano
2013-05-24 18:21 ` Ramkumar Ramachandra
2013-05-24 19:12 ` Junio C Hamano [this message]
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=7vsj1c8a53.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=artagnon@gmail.com \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).