All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Robert Dailey <rcdailey.lists@gmail.com>
Cc: Git <git@vger.kernel.org>
Subject: Re: How to use @{-1} with push?
Date: Fri, 25 Mar 2016 11:58:15 -0700	[thread overview]
Message-ID: <xmqqoaa22xmg.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <CAHd499BCciG5Udd_sj550jPKg_ahZmWOi-zUOU-cr_wYmri=Rg@mail.gmail.com> (Robert Dailey's message of "Fri, 25 Mar 2016 13:11:36 -0500")

Robert Dailey <rcdailey.lists@gmail.com> writes:

> So the push works with the fully-qualified ref, but not git branch:

I thought these are clear from their documentation.  "push" works on
refnames, "branch" works on branch names.  "push" takes an branch
name as a short-hand and adds refs/heads/ when it makes sense, but
because it does not make any sense for "git branch" to create a
"branch" in a random place in refs/ (e.g. "refs/tags/foo" is not a
branch), it takes "foo" (i.e. the name of the branch, whose
underlying ref is "refs/heads/foo").

So

	ref=$(git rev-parse --symbolic-full-name "$2") &&
        case "$ref" in
        '') echo >&2 "No such thing $2"; exit 1 ;;
        refs/heads/*) ref=${ref#refs/heads/} ;;
        *) echo >&2 "That's not a branch $2"; exit 2 ;;
	esac &&
	git push "$1" "refs/heads/$ref" &&
        git branch -D "$ref"

or something?

>
> $ git rev-parse --symbolic-full-name foo
> refs/heads/foo
>
> $ git branch -d refs/heads/foo
> error: branch 'refs/heads/foo' not found.
>
> Any reason for this? I'm using git 2.7.4 on windows

  reply	other threads:[~2016-03-25 18:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-25 14:40 How to use @{-1} with push? Robert Dailey
2016-03-25 17:45 ` Junio C Hamano
2016-03-25 18:02   ` Robert Dailey
2016-03-25 18:11     ` Robert Dailey
2016-03-25 18:58       ` Junio C Hamano [this message]
2016-03-28 14:53         ` Robert Dailey

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=xmqqoaa22xmg.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=rcdailey.lists@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.