From: Junio C Hamano <junkio@cox.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: git@vger.kernel.org
Subject: Re: Teach "git checkout" to use git-show-ref
Date: Sat, 16 Sep 2006 02:33:39 -0700 [thread overview]
Message-ID: <7vpsdw9mvg.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <Pine.LNX.4.64.0609151455150.4388@g5.osdl.org> (Linus Torvalds's message of "Fri, 15 Sep 2006 14:56:55 -0700 (PDT)")
Linus Torvalds <torvalds@osdl.org> writes:
> That way, it doesn't care how the refs are stored any more
>
> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
> ---
>
> Just as an example of how to use git-show-ref rather than knowing about
> "$GIT_DIR/refs/..." paths.
>
> This basically replaces my much hackier version that is in the "lt/refs"
> branch, but can go into the master branch independently of the
> refs-packing work.
I kind of liked the rev-parse one better for this particular
command, but only slightly (by using --verify on "$arg^0", you
were also making sure what's in refs/heads/ was a commit object,
but that check is gone with this patch. It is not a loss,
because the original code did not check it, and nobody should be
placing anything but commits under refs/heads anyway).
> diff --git a/git-checkout.sh b/git-checkout.sh
> index 580a9e8..6e4c535 100755
> --- a/git-checkout.sh
> +++ b/git-checkout.sh
>...
> @@ -51,7 +51,7 @@ while [ "$#" != "0" ]; do
> fi
> new="$rev"
> new_name="$arg^0"
> - if [ -f "$GIT_DIR/refs/heads/$arg" ]; then
> + if git-show-ref --verify --quiet -- "refs/heads/$arg" ]; then
> branch="$arg"
> fi
> elif rev=$(git-rev-parse --verify "$arg^{tree}" 2>/dev/null)
prev parent reply other threads:[~2006-09-16 9:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-15 18:19 Add "git show-ref" builtin command Linus Torvalds
2006-09-15 21:00 ` Junio C Hamano
2006-09-15 21:24 ` Jakub Narebski
2006-09-15 22:54 ` Junio C Hamano
2006-09-15 21:56 ` Teach "git checkout" to use git-show-ref Linus Torvalds
2006-09-15 22:11 ` Jakub Narebski
2006-09-16 9:33 ` 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=7vpsdw9mvg.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=torvalds@osdl.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;
as well as URLs for NNTP newsgroup(s).