From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Jeff Whiteside <jeff.m.whiteside@gmail.com>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: get upstream branch
Date: Mon, 08 Dec 2008 22:43:02 -0800 [thread overview]
Message-ID: <7v8wqp6e89.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <20081209055629.GB2972@coredump.intra.peff.net> (Jeff King's message of "Tue, 9 Dec 2008 00:56:29 -0500")
Jeff King <peff@peff.net> writes:
> In one of my scripts I do something like this (actually this is not
> straight from my script, as the operation there is "find all pairs of
> local/remote branches" and this is "find the current upstream"):
>
> ref=`git symbolic-ref HEAD`
> head=${ref#refs/heads/}
> remote=`git config branch.$head.remote`
> branch=`git config branch.$head.merge`
> echo refs/remote/$remote/${branch#refs/heads/}
>
> And obviously this is missing error checking for the detached HEAD
> (symbolic-ref should fail) and no tracking branch ($remote and/or $branch
> will be empty) cases.
Yeah, add any nonstandard layout to that set of things that are missing,
but in practice it should not matter.
next prev parent reply other threads:[~2008-12-09 6:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-09 4:52 get upstream branch Jeff Whiteside
2008-12-09 5:35 ` Junio C Hamano
2008-12-09 5:56 ` Jeff King
2008-12-09 6:43 ` Junio C Hamano [this message]
2008-12-09 15:51 ` Santi Béjar
2008-12-09 6:46 ` Sverre Rabbelier
2008-12-09 15:25 ` Peter Harris
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=7v8wqp6e89.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=jeff.m.whiteside@gmail.com \
--cc=peff@peff.net \
/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).