All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Riesen <raa.lkml@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Daniel Barkalow <barkalow@iabervon.org>
Subject: Re: [funny] "git checkout -t origin/xyzzy" seems to misbehave
Date: Sun, 21 Sep 2008 19:44:38 +0200	[thread overview]
Message-ID: <20080921174438.GB3877@blimp.localhost> (raw)
In-Reply-To: <7v1vzd29i3.fsf@gitster.siamese.dyndns.org>

Junio C Hamano, Sun, Sep 21, 2008 10:23:00 +0200:
> When you
> 
>  * are on a branch "foo" that is not "bar",
>  * have "origin/bar",
>  * and already have a local branch "bar",
> 
> "git checkout -t origin/bar" seems to misbehave.
> 
>     $ git clone -s git.junio victim-002
>     $ cd victim-002
>     $ git branch
>     * master
>     $ git checkout -t origin/next
>     Branch next set up to track remote branch refs/remotes/origin/next.
>     Switched to a new branch "next"
>     $ git checkout -t origin/master
>     fatal: A branch named 'master' already exists.
>     $ git branch
>       master
>     * next
>     $ git diff --cached --shortstat
>      60 files changed, 2378 insertions(+), 3412 deletions(-)
>     $ git diff --cached master
>     $ exit
> 
> The first "checkout -t" is fine.  The failed one seems to have already
> updated the index and the work tree when it notices that it cannot create
> a new branch.

Precisely this (branch already exists) case is easy to handle with a
resolve_ref in builtin-checkout.c:switch_branches.

The other errors will still leave index and working tree in this
state: branch.c:create_branch does not cleanup in case of errors,
it just dies.

  reply	other threads:[~2008-09-22 17:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-21  8:23 [funny] "git checkout -t origin/xyzzy" seems to misbehave Junio C Hamano
2008-09-21 17:44 ` Alex Riesen [this message]
2008-09-21 18:36 ` Daniel Barkalow

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=20080921174438.GB3877@blimp.localhost \
    --to=raa.lkml@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=barkalow@iabervon.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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.