threads / patch / 14576

patchcheckout without arguments does not make sense

Subject: [PATCH] checkout without arguments does not make sense

## tl;dr

6 messages between Jul 21, 2008 and Jul 22, 2008. Diffs are folded; open one to read it.

replies: 5people: 4as markdown or json

Johannes Sixt· Jul 21, 2008, 20:06 UTC · lore
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
 builtin-checkout.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
Show changes to builtin-checkout.c +2 −1
diff --git a/builtin-checkout.c b/builtin-checkout.c
index fbd5105..669be0e 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -487,7 +487,8 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
 		}
 
 		return checkout_paths(source_tree, pathspec);
-	}
+	} else if (!new.name && !opts.new_branch)
+		usage_with_options(checkout_usage, options);
 
 	if (new.name && !new.commit) {
 		die("Cannot switch branch to a non-commit.");
-- 
1.6.0.rc0.18.g6aef2
Miklos Vajna· Jul 21, 2008, 20:49 UTC · re: Johannes Sixt · lore

Re: [PATCH] checkout without arguments does not make sense

On Mon, Jul 21, 2008 at 10:06:32PM +0200, Johannes Sixt <johannes.sixt@telecom.at> wrote:
Show 10 quoted lines
> @@ -487,7 +487,8 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
>  		}
>  
>  		return checkout_paths(source_tree, pathspec);
> -	}
> +	} else if (!new.name && !opts.new_branch)
> +		usage_with_options(checkout_usage, options);
>  
>  	if (new.name && !new.commit) {
>  		die("Cannot switch branch to a non-commit.");
Actually I think it _is_ useful, like this:

$ git checkout Your branch is ahead of the tracked remote branch 'junio/next' by 1 commit.

How will it be possible to get that info easily after your patch?
Thanks.
Johannes Sixt· Jul 21, 2008, 21:11 UTC · re: Miklos Vajna · lore

Re: [PATCH] checkout without arguments does not make sense

On Montag, 21. Juli 2008, Miklos Vajna wrote:
> Actually I think it _is_ useful, like this:
>
> $ git checkout
> Your branch is ahead of the tracked remote branch 'junio/next' by 1 commit.
Ah, yes, indeed; that makes sense. Scrap the patch.
-- Hannes
Avery Pennarun· Jul 21, 2008, 21:36 UTC · re: Miklos Vajna · lore

Re: [PATCH] checkout without arguments does not make sense

On 7/21/08, Miklos Vajna <vmiklos@frugalware.org> wrote:
Show 6 quoted lines
> Actually I think it _is_ useful, like this:
>
>  $ git checkout
>  Your branch is ahead of the tracked remote branch 'junio/next' by 1 commit.
>
>  How will it be possible to get that info easily after your patch?

Eek, are we using "checkout" to get status information now? If that goes wrong, you could be blowing away your locally modified data by accident.

I think "git status" reports this information in recent versions, doesn't it?
Thanks,
Avery
Miklos Vajna· Jul 21, 2008, 21:44 UTC · re: Avery Pennarun · lore

Re: [PATCH] checkout without arguments does not make sense

On Mon, Jul 21, 2008 at 05:36:59PM -0400, Avery Pennarun <apenwarr@gmail.com> wrote:
> Eek, are we using "checkout" to get status information now?  If that
> goes wrong, you could be blowing away your locally modified data by
> accident.
Hm, let's say I have uncommitted changes to Makefile, then I'll get:

$ git checkout M Makefile Your branch is ahead of the tracked remote branch 'junio/next' by 1 commit.

But it will not drop my local changes.
> I think "git status" reports this information in recent versions, doesn't it?

Right. But that shows other infos as well, for example the untracked files, etc. So there are cases when git checkout is just better.

However, you are right about it may not be the best habit from my side to use git checkout to get that info. ;-)

Johannes Schindelin· Jul 22, 2008, 00:57 UTC · re: Miklos Vajna · lore

Re: [PATCH] checkout without arguments does not make sense

Hi,
On Mon, 21 Jul 2008, Miklos Vajna wrote:
Show 10 quoted lines
> On Mon, Jul 21, 2008 at 05:36:59PM -0400, Avery Pennarun <apenwarr@gmail.com> wrote:
>
> > I think "git status" reports this information in recent versions, 
> > doesn't it?
> 
> Right. But that shows other infos as well, for example the untracked 
> files, etc. So there are cases when git checkout is just better.
> 
> However, you are right about it may not be the best habit from my side 
> to use git checkout to get that info. ;-)

I usually call "git status" for that information. But Junio suggested checkout recently on #git, for exactly that information, so you are not alone at all.

Ciao, Dscho

← back to recent threads