Re: [PATCH] checkout: allow full refnames for local branches
- From
Shawn O. Pearce <spearce@spearce.org>
- Date
- May 9, 2007, 18:54 UTC
- Message-ID
- <20070509185440.GB3141@spearce.org>
- In-Reply-To
- <8c5c35580705090207y2979aaa5u7ce9de5fa1dfe658@mail.gmail.com>
Lars Hjemli <hjemli@gmail.com> wrote:
Show 6 quoted lines
> 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.