From: "Shawn O. Pearce" <spearce@spearce.org>
To: Lars Hjemli <hjemli@gmail.com>
Cc: Junio C Hamano <junkio@cox.net>, git@vger.kernel.org
Subject: Re: [PATCH] checkout: allow full refnames for local branches
Date: Wed, 9 May 2007 14:54:40 -0400 [thread overview]
Message-ID: <20070509185440.GB3141@spearce.org> (raw)
In-Reply-To: <8c5c35580705090207y2979aaa5u7ce9de5fa1dfe658@mail.gmail.com>
Lars Hjemli <hjemli@gmail.com> wrote:
> I'm playing around with a gui frontend, and there I use
> git-for-each-ref to obtain possible arguments for git-checkout. That's
> how I discovered the 'problem', and solved it by stripping
> 'refs/heads/' in my frontend. But then I thought it would be nice if
> 'git-checkout' did the stripping on my behalf, since this might bite
> others too :)
If you are building "porcelain" to sit over Git and offer up a pretty
view of things, I would encourage you to avoid the stock porcelain.
Don't use git-checkout, its stock porcelain. Instead go right to
the plumbing. The plumbing doesn't really change behavior as often
(if ever).
You can see in git-checkout.sh what actions you need to perform,
but its really quite simple if there's no file-level merge involved.
Here's the relevent bits from git-gui:
set cmd [list git read-tree]
lappend cmd -m
lappend cmd -u
lappend cmd --exclude-per-directory=.gitignore
lappend cmd $HEAD
lappend cmd $new_branch
set fd_rt [open "| $cmd" r]
fconfigure $fd_rt -blocking 0 -translation binary
fileevent $fd_rt readable \
[list switch_branch_readtree_wait $fd_rt $new_branch]
...
git symbolic-ref HEAD "refs/heads/$new_branch"
Really all I'm doing is building up an argument list for git
read-tree, passing it the commit that is currently in HEAD and the
commit I want to switch to ($new_branch), and then I wait for it
to finish its job. When its done, I run git symbolic-ref to update
the current branch name.
--
Shawn.
next prev parent reply other threads:[~2007-05-09 18:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-09 8:40 [PATCH] checkout: allow full refnames for local branches Lars Hjemli
2007-05-09 8:48 ` Junio C Hamano
2007-05-09 9:07 ` Lars Hjemli
2007-05-09 18:54 ` Shawn O. Pearce [this message]
2007-05-09 20:01 ` Lars Hjemli
2007-05-09 20:11 ` Shawn O. Pearce
2007-05-09 20:38 ` Lars Hjemli
2007-05-09 19:37 ` Junio C Hamano
2007-05-09 19:55 ` Lars Hjemli
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=20070509185440.GB3141@spearce.org \
--to=spearce@spearce.org \
--cc=git@vger.kernel.org \
--cc=hjemli@gmail.com \
--cc=junkio@cox.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).