git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] builtin/checkout.c: show usage with options on missing argument 'branch'
@ 2011-05-05 16:58 Ralf Thielow
  2011-05-05 18:45 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Ralf Thielow @ 2011-05-05 16:58 UTC (permalink / raw)
  To: git; +Cc: Ralf Thielow

Show the usage with options for 'checkout' command on missing argument 'branch'.

Signed-off-by: Ralf Thielow <ralf.thielow@googlemail.com>
---
 builtin/checkout.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/builtin/checkout.c b/builtin/checkout.c
index 38632fc..4aa613a 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -1086,5 +1086,10 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
 	if (opts.writeout_stage)
 		die(_("--ours/--theirs is incompatible with switching branches."));
 
+	if (new.name == NULL) {
+		usage_with_options(checkout_usage, options);
+		return;
+	}
+
 	return switch_branches(&opts, &new);
 }
-- 
1.7.5.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] builtin/checkout.c: show usage with options on missing argument 'branch'
  2011-05-05 16:58 [PATCH] builtin/checkout.c: show usage with options on missing argument 'branch' Ralf Thielow
@ 2011-05-05 18:45 ` Junio C Hamano
  2011-05-05 19:02   ` Ralf Thielow
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2011-05-05 18:45 UTC (permalink / raw)
  To: Ralf Thielow; +Cc: git

Ralf Thielow <ralf.thielow@googlemail.com> writes:

> Show the usage with options for 'checkout' command on missing argument 'branch'.

Please describe what exact command line you typed, what output and side
effect you got from the command, what you _think_ should have happened
instead, and what the differences between two are.

In other words, what problem you are trying to solve?

> Signed-off-by: Ralf Thielow <ralf.thielow@googlemail.com>
> ---
>  builtin/checkout.c |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/builtin/checkout.c b/builtin/checkout.c
> index 38632fc..4aa613a 100644
> --- a/builtin/checkout.c
> +++ b/builtin/checkout.c
> @@ -1086,5 +1086,10 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
>  	if (opts.writeout_stage)
>  		die(_("--ours/--theirs is incompatible with switching branches."));
>  
> +	if (new.name == NULL) {
> +		usage_with_options(checkout_usage, options);
> +		return;
> +	}
>
>  	return switch_branches(&opts, &new);
>  }

What value are you returning from a function whose return type is int?

If you read the function switch_branches(), you would notice that it is
prepared to handle the case where new.name is NULL (by the way, check
against NULL is typically spelled as "if (!new.name)" as you can see
there), and then would realize that your change by itself cannot be a
correct fix for whatever problem you are trying to solve.

Have you run "make test" at all?

If you are changing this command:

	$ git checkout -b frotz
	Switched to a new branch 'junk'

to error out with a message, then that is a regression.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] builtin/checkout.c: show usage with options on missing argument 'branch'
  2011-05-05 18:45 ` Junio C Hamano
@ 2011-05-05 19:02   ` Ralf Thielow
  2011-05-05 19:49     ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Ralf Thielow @ 2011-05-05 19:02 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Simple "git checkout" or "git checkout " don't tell me that i've done a mistake
on usage. It does nothing. This can be different when using parameters, but in
the end i think it should tell me the usage in this case.

2011/5/5 Junio C Hamano <gitster@pobox.com>:
> Ralf Thielow <ralf.thielow@googlemail.com> writes:
>
>> Show the usage with options for 'checkout' command on missing argument 'branch'.
>
> Please describe what exact command line you typed, what output and side
> effect you got from the command, what you _think_ should have happened
> instead, and what the differences between two are.
>
> In other words, what problem you are trying to solve?
>
>> Signed-off-by: Ralf Thielow <ralf.thielow@googlemail.com>
>> ---
>>  builtin/checkout.c |    5 +++++
>>  1 files changed, 5 insertions(+), 0 deletions(-)
>>
>> diff --git a/builtin/checkout.c b/builtin/checkout.c
>> index 38632fc..4aa613a 100644
>> --- a/builtin/checkout.c
>> +++ b/builtin/checkout.c
>> @@ -1086,5 +1086,10 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
>>       if (opts.writeout_stage)
>>               die(_("--ours/--theirs is incompatible with switching branches."));
>>
>> +     if (new.name == NULL) {
>> +             usage_with_options(checkout_usage, options);
>> +             return;
>> +     }
>>
>>       return switch_branches(&opts, &new);
>>  }
>
> What value are you returning from a function whose return type is int?
>
> If you read the function switch_branches(), you would notice that it is
> prepared to handle the case where new.name is NULL (by the way, check
> against NULL is typically spelled as "if (!new.name)" as you can see
> there), and then would realize that your change by itself cannot be a
> correct fix for whatever problem you are trying to solve.
>
> Have you run "make test" at all?
>
> If you are changing this command:
>
>        $ git checkout -b frotz
>        Switched to a new branch 'junk'
>
> to error out with a message, then that is a regression.
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] builtin/checkout.c: show usage with options on missing argument 'branch'
  2011-05-05 19:02   ` Ralf Thielow
@ 2011-05-05 19:49     ` Junio C Hamano
  0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2011-05-05 19:49 UTC (permalink / raw)
  To: Ralf Thielow; +Cc: git

Ralf Thielow <ralf.thielow@googlemail.com> writes:

> Simple "git checkout" or "git checkout " don't tell me that i've done a mistake
> on usage. It does nothing.

That is a designed behaviour.  You did nothing wrong.

Besides, that is a way people who use "checkout -t -b" to create topic
branches check their branch status.  Pay attention to what the last
command does in the following transcript.

    $ git checkout master
    $ git checkout -t -b side
    Branch side set up to track local branch master.
    Switched to a new branch 'side'
    $ git checkout master
    Switched to branch 'master'
    $ edit ; git commit ;# on 'master'
    $ git checkout side
    Switched to branch 'side'
    Your branch is behind 'master' by 1 commit, ...
    ... time passes ...
    $ git checkout
    Your branch is behind 'master' by 1 commit, ...

   

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-05-05 19:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-05 16:58 [PATCH] builtin/checkout.c: show usage with options on missing argument 'branch' Ralf Thielow
2011-05-05 18:45 ` Junio C Hamano
2011-05-05 19:02   ` Ralf Thielow
2011-05-05 19:49     ` Junio C Hamano

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 NNTP newsgroup(s).