# [PATCH] checkout without arguments does not make sense

6 messages from 2008-07-21 to 2008-07-22. Participants: Johannes Sixt, Miklos Vajna, Avery Pennarun, Johannes Schindelin.
Thread: https://gitlist.dev/t/14576

## Johannes Sixt, 2008-07-21 20:06

Subject: [PATCH] checkout without arguments does not make sense
Message-ID: <200807212206.32818.johannes.sixt@telecom.at>
URL: https://gitlist.dev/e/200807212206.32818.johannes.sixt%40telecom.at

```
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
 builtin-checkout.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

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, 2008-07-21 20:49

Subject: Re: [PATCH] checkout without arguments does not make sense
Message-ID: <20080721204955.GI32057@genesis.frugalware.org>
URL: https://gitlist.dev/e/20080721204955.GI32057%40genesis.frugalware.org
In-Reply-To: <200807212206.32818.johannes.sixt@telecom.at>

```
On Mon, Jul 21, 2008 at 10:06:32PM +0200, Johannes Sixt <johannes.sixt@telecom.at> wrote:
> @@ -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, 2008-07-21 21:11

Subject: Re: [PATCH] checkout without arguments does not make sense
Message-ID: <200807212311.17612.johannes.sixt@telecom.at>
URL: https://gitlist.dev/e/200807212311.17612.johannes.sixt%40telecom.at
In-Reply-To: <20080721204955.GI32057@genesis.frugalware.org>

```
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, 2008-07-21 21:36

Subject: Re: [PATCH] checkout without arguments does not make sense
Message-ID: <32541b130807211436h77bf5985xa61ed7b4941c47dc@mail.gmail.com>
URL: https://gitlist.dev/e/32541b130807211436h77bf5985xa61ed7b4941c47dc%40mail.gmail.com
In-Reply-To: <20080721204955.GI32057@genesis.frugalware.org>

```
On 7/21/08, Miklos Vajna <vmiklos@frugalware.org> 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.
>
>  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, 2008-07-21 21:44

Subject: Re: [PATCH] checkout without arguments does not make sense
Message-ID: <20080721214459.GJ32057@genesis.frugalware.org>
URL: https://gitlist.dev/e/20080721214459.GJ32057%40genesis.frugalware.org
In-Reply-To: <32541b130807211436h77bf5985xa61ed7b4941c47dc@mail.gmail.com>

```
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, 2008-07-22 00:57

Subject: Re: [PATCH] checkout without arguments does not make sense
Message-ID: <alpine.DEB.1.00.0807220256270.3407@eeepc-johanness>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0807220256270.3407%40eeepc-johanness
In-Reply-To: <20080721214459.GJ32057@genesis.frugalware.org>

```
Hi,

On Mon, 21 Jul 2008, Miklos Vajna wrote:

> 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

```
