git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Björn Steinbrink" <B.Steinbrink@gmx.de>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Euguess@gmail.com, Mikael Magnusson <mikachu@gmail.com>,
	Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>,
	Jeff King <peff@peff.net>, Jay Soffian <jaysoffian@gmail.com>,
	git@vger.kernel.org
Subject: Re: Re: [PATCH/RFC] builtin-checkout: suggest creating local branch when appropriate to do so
Date: Mon, 12 Oct 2009 20:36:58 +0200	[thread overview]
Message-ID: <20091012183658.GA17857@atjola.homenet> (raw)
In-Reply-To: <alpine.DEB.1.00.0910120941150.4985@pacific.mpi-cbg.de>

On 2009.10.12 09:49:50 +0200, Johannes Schindelin wrote:
> On Tue, 6 Oct 2009, Euguess@gmail.com wrote:
> > I'ma new user of git and I don't think i will ever have a commit in 
> > git.git, because I'm not a programmer (I'm QA).
[...]
> > As for the solution i would choose the "simplest thing that will work" - 
> > so i think that we just have to notify user about his suicide attempt to 
> > checkout nonlocal branch and offer him a correct syntax to go with.
> >
> > Something like below should work:
> > 
> > % git clone git://git.git git
> > % git checkout next
> > You're attempting to checkout to non-local branch. This will lead to your HEAD
> > being detached (our team is on its way!).
> > Do you want to check out local branch 'next' tracking 'origin/next' instead?
> > y/n
> > 
> > if yes, then:
> > Created branch "next" tracking "origin/next"
> > You can update it with 'git pull'.
> > 
> > If no - abort or continue with checkout to nonlocal branch? ('m not sure if
> > detaching HEAD can provide some benefits if done on purpose)
> > 
> > I hope I'm not missing anything...
> 
> No, I think that is something perfectly fine to expect in a software whose 
> UI complexity is unfortunately pretty much in disagreement with its 
> internal complexity.
> 
> One thing one might add for the technically inclined folks (i.e. those who 
> need to implement, and to see that Git is in dear need of some 
> user-friendliness first): "git checkout" is a porcelain (i.e. a program 
> meant for end-user consumption), and as such should not have a problem to 
> react to isatty(0) (i.e. "is the input coming directly from the 
> console?").

So I didn't mean to chime in, but anyway... A few days ago, uau on #git
said that he thinks that "git clone" shouldn't create any branch heads
at all. Instead, git should learn to do something like "svn up", when
the user checked out a remote tracking branch. That was specifically
meant for users that _don't_ commit, like, say, QA guys ;-)

I didn't quite agree on the idea (feel free to tell me that I just blank
out UI problems :-p), but anyway, I felt like coming up with some hack
that achieves said functionality. The result was inspired by "git
checkout -" and looks at HEAD's reflog to figure out whether the user
has checked out a remote tracking branch the last time he used checkout
to switch branches. I dared to call it "git-up" in my $HOME/bin ;-)

#!/bin/bash
MODE=${1:---merge}

RTB=$(git rev-parse --symbolic-full-name $(git reflog | grep 'checkout: moving from .* to' | head -1 | sed -e 's/.* to //'))

if [ ${RTB:0:13} != "refs/remotes/" ]
then
	echo "You're not on a remote tracking branch"
	exit 1
fi

SRTB=${RTB#refs/remotes/}
REMOTE=${SRTB%/*}
git fetch $REMOTE
git reset $MODE $RTB


It's obviously basically just "git reset" on crack, happily dropping
local commits. A "real" implementation would likely have to have more
checks to ensure that the user is using it in an expected way (like
checking that refs/remotes/whatever..HEAD is empty). And it could be
made to work with regular branch heads as well then, as a "fast-forward
only" way of updating (think "git merge --ff-only", but in a less
illogical way, as "--ff-only" actually means "don't create a merge",
which is kinda weird, at least to me).

As I said, I don't really agree on the idea of not creating any branch
heads on "clone", but maybe it's because I'm not a "don't commit, just
watch" person. And the theoretical "git up" command might be handy for
guys that just want to follow things, and thus don't really need branch
heads. At the moment, I don't have any intentions to improve the hack
(also due to lack of time), but if it seems worthwhile to anyone, feel
free to pick it up.

Björn, -ENOPATCH ;-)

  reply	other threads:[~2009-10-12 18:50 UTC|newest]

Thread overview: 91+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-05 20:46 [PATCH/RFC] builtin-checkout: suggest creating local branch when appropriate to do so Jay Soffian
2009-10-05 21:03 ` Sverre Rabbelier
2009-10-05 21:17 ` Johannes Schindelin
2009-10-05 21:26   ` Sverre Rabbelier
2009-10-05 21:57     ` Jay Soffian
2009-10-05 22:00   ` Jay Soffian
2009-10-05 22:45     ` Johannes Schindelin
2009-10-05 22:56   ` Jeff King
2009-10-06  7:32     ` Thomas Rast
2009-10-06  9:16       ` Johannes Schindelin
2009-10-06 11:36         ` Junio C Hamano
2009-10-06 12:02           ` Johannes Schindelin
2009-10-06 20:09             ` Junio C Hamano
2009-10-06  9:12     ` Johannes Schindelin
2009-10-06  9:28       ` Matthieu Moy
2009-10-06  9:41         ` Mikael Magnusson
2009-10-06 10:04           ` Johannes Schindelin
     [not found]           ` <0016e68fd0123a175304754694b4@google.com>
2009-10-06 16:43             ` Eugene Sajine
2009-10-06 20:33               ` Junio C Hamano
2009-10-12  7:49             ` Johannes Schindelin
2009-10-12 18:36               ` Björn Steinbrink [this message]
2009-10-12 21:40               ` Thomas Rast
2009-10-12 22:49                 ` Junio C Hamano
2009-10-13  6:36                   ` Thomas Rast
2009-10-13  7:16                     ` Junio C Hamano
2009-10-13  8:44                       ` Junio C Hamano
2009-10-13  8:51                       ` Thomas Rast
2009-10-13  9:24                         ` Junio C Hamano
2009-10-13 21:20                           ` Johannes Schindelin
2009-10-13 21:59                             ` Junio C Hamano
2009-10-13 22:06                             ` Jeff King
2009-10-13 23:22                               ` Johannes Schindelin
2009-10-14  1:05                                 ` Jay Soffian
2009-10-14  3:28                                   ` Junio C Hamano
2009-10-14 12:49                                     ` Jay Soffian
2009-10-14 19:31                                       ` Junio C Hamano
2009-10-25 17:44                                     ` Uri Okrent
2009-10-14  4:31                                 ` Jeff King
2009-10-14  9:56                         ` Thomas Rast
2009-10-14 10:46                           ` Jakub Narebski
2009-10-13  9:32                       ` Johannes Sixt
2009-10-13 18:39                       ` Daniel Barkalow
2009-10-13 20:53                         ` Junio C Hamano
2009-10-13 21:31                           ` Daniel Barkalow
2009-10-13 21:57                             ` Jeff King
2009-10-13 22:46                               ` Junio C Hamano
2009-10-13 23:16                                 ` Johannes Schindelin
2009-10-14  9:33                                   ` Thomas Rast
2009-10-16 11:48                                     ` Johannes Schindelin
2009-10-16 12:07                                       ` Thomas Rast
2009-10-25 17:48                                 ` Uri Okrent
2009-10-26  7:14                                   ` Junio C Hamano
2009-10-13 22:38                             ` Björn Steinbrink
2009-10-18  7:58   ` Junio C Hamano
2009-10-18  8:00     ` [PATCH 1/3] check_filename(): make verify_filename() callable without dying Junio C Hamano
2009-10-18  8:01     ` [PATCH 2/3] DWIM "git checkout frotz" to "git checkout -b frotz origin/frotz" Junio C Hamano
2009-10-18 10:34       ` Nanako Shiraishi
2009-10-18 12:00         ` Björn Steinbrink
2009-10-18 20:20           ` Nanako Shiraishi
2009-10-18 22:50             ` Junio C Hamano
2009-10-19  5:58             ` Björn Steinbrink
2009-10-18  8:01     ` [PATCH 3/3] git checkout --nodwim Junio C Hamano
2009-10-18 12:40       ` Alex Riesen
2009-10-18 19:53         ` Junio C Hamano
2009-10-18 21:02           ` [PATCH] Use "--no-" prefix to switch off some of checkout dwimmery Alex Riesen
2009-10-18 22:49             ` Junio C Hamano
2009-10-19  6:07               ` Alex Riesen
2009-10-19  6:12                 ` Alex Riesen
2009-10-19  6:16                   ` Junio C Hamano
2009-10-19  7:17                     ` Alex Riesen
2009-10-19  7:25                       ` Junio C Hamano
2009-10-21 17:29           ` [PATCH 3/3] git checkout --nodwim Avery Pennarun
2009-10-21 21:21             ` Nanako Shiraishi
2009-10-21 22:14               ` Junio C Hamano
2009-10-21 22:35                 ` [PATCH] git checkout --no-guess Junio C Hamano
2009-10-21 22:51                   ` Avery Pennarun
2009-10-26 18:17                     ` Jay Soffian
2009-10-26 18:25                       ` Avery Pennarun
2009-10-22  0:27               ` [PATCH 3/3] git checkout --nodwim Johannes Schindelin
2009-10-22  7:09                 ` Erik Faye-Lund
2009-10-23  8:57                 ` Michael J Gruber
2009-10-24  6:35                 ` Junio C Hamano
2009-10-24 14:59                   ` David Roundy
2009-10-24 19:25                     ` Junio C Hamano
2009-10-26 20:12                     ` Johannes Schindelin
2009-10-26 20:40                       ` Avery Pennarun
2009-10-26 21:26                         ` Jeff King
2009-10-26 22:01                           ` Avery Pennarun
2009-10-26 22:14                             ` Jeff King
2009-10-26 22:28                               ` Avery Pennarun
2009-10-05 22:52 ` [PATCH/RFC] builtin-checkout: suggest creating local branch when appropriate to do so Jeff King

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091012183658.GA17857@atjola.homenet \
    --to=b.steinbrink@gmx.de \
    --cc=Euguess@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=Matthieu.Moy@grenoble-inp.fr \
    --cc=git@vger.kernel.org \
    --cc=jaysoffian@gmail.com \
    --cc=mikachu@gmail.com \
    --cc=peff@peff.net \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).