public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Sergei Organov <osv@javad•com>
To: "Karl Hasselström" <kha@treskal•com>
Cc: <vanicat@debian•org>,
	git@vger•kernel.org, Alexandre Julliard <julliard@winehq•org>
Subject: Re: [PATCH] Add function to checkout a branch in git.el
Date: Wed, 13 Feb 2008 21:23:52 +0300	[thread overview]
Message-ID: <87zlu4vhon.fsf@osv.gnss.ru> (raw)
In-Reply-To: <20080213164356.GA5828@diana.vm.bytemark.co.uk> ("Karl Hasselström"'s message of "Wed\, 13 Feb 2008 17\:43\:56 +0100")

Karl Hasselström <kha@treskal•com> writes:

> On 2008-02-13 17:30:02 +0100, Karl Hasselström wrote:
>
>> Why the prefix? Wouldn't it be easier to just have one "switch
>> branch" prompt that would tab complete existing branch names, and
>>
>>   * if the user enters the name of an existing branch, just switch to
>>     it;
>>
>>   * if the user enters a name that's not the name of an existing
>>     branch, ask for confirmation, and then create the new branch and
>>     switch to it.
>
> Reading your code a bit more carefully, I realize that my suggestion
> doesn't give you the opportunity to base the new branch on anything
> but HEAD. So change the second bullet to
>
>   * if the user enters a name that's not the name of an existing
>     branch, display a prompt like this
>
>       Creating new branch "foo". Where should it start?
>
>     Tab complete on existing tags and branches, but accept any
>     committish. Create the new branch and switch to it.

It still doesn't allow to detach HEAD at arbitrary tag/committish, as
far as I can see.

I believe the interface should be designed more carefully. Here are some
thoughts/suggestions:

1. Let `git-checkout' switch HEAD. It will never create new branches but
   will be able to detach HEAD. Use tab-completion on branch names and
   maybe tags (maybe by inserting tags/ into completion list, and
   switching completion list to tags after tags/ is enterd by user), but
   allow any commitish. Ideally, it will also revert Emacs buffers for
   which working copy files are changed during checkout.

2. Let `git-create-branch' create new branches. It will prompt for a branch
   name, then prompt for starting point with default set to HEAD, and
   create the branch. As it doesn't switch HEAD, it won't touch working
   files.

3. Let `git-branch' create new branch at HEAD and switch to it. This
   will be just a short-cut for common and simple case. Note that this
   will never change working files as newly created branch will match
   HEAD.

4. Reserve C-u prefix for ability to provide arbitrary options to
   underlying GIT commands. For example, it's useful to be able to give
   -m or -f option to "git checkout"; or --track or -f to "git branch".

The "create new branch at arbitrary point and then switch to it" will
then be a two-step operation: either "

((git-create-branch <name> <point>) (git-checkout <name>)

or

((git-checkout <point>) (git-branch <name>))

but that is IMHO reasonable trade-off for interface simplicity, though
yet another function could be defined to do it in one step.

-- Sergei.

  parent reply	other threads:[~2008-02-13 18:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-13 15:53 [PATCH] Add function to checkout a branch in git.el =?utf-8?q?R=C3=A9mi=20Vanicat?=
2008-02-13 16:30 ` Karl Hasselström
2008-02-13 16:43   ` Karl Hasselström
2008-02-13 18:09     ` Remi Vanicat
2008-02-13 18:23     ` Sergei Organov [this message]
2008-02-13 21:04       ` Karl Hasselström
2008-02-14 11:47         ` Sergei Organov
2008-02-16 19:17       ` [patch v2] switching and creating branch, merging and rebasing with Emacs =?utf-8?q?R=C3=A9mi=20Vanicat?=
2008-02-16 19:27         ` [PATCH 01/03] Add helper function for branch tag and commitish to git.el Rémi Vanicat
2008-02-17 18:30           ` Alexandre Julliard
2008-02-16 19:30         ` [PATCH 02/03] Adding checkout function for commitish in git.el Rémi Vanicat
2008-02-17 18:27           ` Alexandre Julliard
2008-02-16 19:35         ` [PATCH 03/03] Adding command for merging " Rémi Vanicat
2008-02-13 18:29 ` [PATCH] Add function to checkout a branch " Sergei Organov

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=87zlu4vhon.fsf@osv.gnss.ru \
    --to=osv@javad$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=julliard@winehq$(echo .)org \
    --cc=kha@treskal$(echo .)com \
    --cc=vanicat@debian$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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