All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] demonstrate git-commit --dry-run exit code behaviour
@ 2014-02-21 19:16 Tay Ray Chuan
  2014-02-21 20:21 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Tay Ray Chuan @ 2014-02-21 19:16 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Tay Ray Chuan

In particular, show that --short and --porcelain, while implying
--dry-run, do not return the same exit code as --dry-run. This is due to
the wt_status.commitable flag being set only when a long status is
requested.

No fix is provided here; with [1], it should be trivial to fix though -
just a matter of calling wt_status_mark_commitable().

[1] http://article.gmane.org/gmane.comp.version-control.git/242489

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
 t/t7501-commit.sh | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index 94eec83..d58b097 100755
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
@@ -61,11 +61,47 @@ test_expect_success 'nothing to commit' '
 	test_must_fail git commit -m initial
 '
 
+test_expect_success '--dry-run fails with nothing to commit' '
+	test_must_fail git commit -m initial --dry-run
+'
+
+test_expect_success '--short fails with nothing to commit' '
+	test_must_fail git commit -m initial --short
+'
+
+test_expect_success '--porcelain fails with nothing to commit' '
+	test_must_fail git commit -m initial --porcelain
+'
+
+test_expect_success '--long fails with nothing to commit' '
+	test_must_fail git commit -m initial --long
+'
+
 test_expect_success 'setup: non-initial commit' '
 	echo bongo bongo bongo >file &&
 	git commit -m next -a
 '
 
+test_expect_success '--dry-run with stuff to commit returns ok' '
+	echo bongo bongo bongo >>file &&
+	git commit -m next -a --dry-run
+'
+
+test_expect_failure '--short with stuff to commit returns ok' '
+	echo bongo bongo bongo >>file &&
+	git commit -m next -a --short
+'
+
+test_expect_failure '--porcelain with stuff to commit returns ok' '
+	echo bongo bongo bongo >>file &&
+	git commit -m next -a --porcelain
+'
+
+test_expect_success '--long with stuff to commit returns ok' '
+	echo bongo bongo bongo >>file &&
+	git commit -m next -a --long
+'
+
 test_expect_success 'commit message from non-existing file' '
 	echo more bongo: bongo bongo bongo bongo >file &&
 	test_must_fail git commit -F gah -a
-- 
1.9.0.291.g027825b

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

* Re: [PATCH] demonstrate git-commit --dry-run exit code behaviour
  2014-02-21 19:16 [PATCH] demonstrate git-commit --dry-run exit code behaviour Tay Ray Chuan
@ 2014-02-21 20:21 ` Junio C Hamano
  2014-02-22  8:34   ` Jeff King
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2014-02-21 20:21 UTC (permalink / raw)
  To: Tay Ray Chuan; +Cc: Git Mailing List

Tay Ray Chuan <rctay89@gmail.com> writes:

> In particular, show that --short and --porcelain, while implying
> --dry-run, do not return the same exit code as --dry-run. This is due to
> the wt_status.commitable flag being set only when a long status is
> requested.

I am not sure if --short/--porcelain should even be accepted by "git
commit" in the first place.  It used to be that "git status" and
"git commit" were the same program in a different guise and "git
status <anything>" were merely a "git commit --dry-run <anything>",
but the recent push is in the direction of making them totally
separate in the end-user's minds.  So if we want a proper fix, I
would actually think that these options should *error out* at the
command line parser level, way before checking if there is anything
to commit.

> No fix is provided here; with [1], it should be trivial to fix though -
> just a matter of calling wt_status_mark_commitable().
>
> [1] http://article.gmane.org/gmane.comp.version-control.git/242489
>
> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
> ---
>  t/t7501-commit.sh | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
>
> diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
> index 94eec83..d58b097 100755
> --- a/t/t7501-commit.sh
> +++ b/t/t7501-commit.sh
> @@ -61,11 +61,47 @@ test_expect_success 'nothing to commit' '
>  	test_must_fail git commit -m initial
>  '
>  
> +test_expect_success '--dry-run fails with nothing to commit' '
> +	test_must_fail git commit -m initial --dry-run
> +'
> +
> +test_expect_success '--short fails with nothing to commit' '
> +	test_must_fail git commit -m initial --short
> +'
> +
> +test_expect_success '--porcelain fails with nothing to commit' '
> +	test_must_fail git commit -m initial --porcelain
> +'
> +
> +test_expect_success '--long fails with nothing to commit' '
> +	test_must_fail git commit -m initial --long
> +'
> +
>  test_expect_success 'setup: non-initial commit' '
>  	echo bongo bongo bongo >file &&
>  	git commit -m next -a
>  '
>  
> +test_expect_success '--dry-run with stuff to commit returns ok' '
> +	echo bongo bongo bongo >>file &&
> +	git commit -m next -a --dry-run
> +'
> +
> +test_expect_failure '--short with stuff to commit returns ok' '
> +	echo bongo bongo bongo >>file &&
> +	git commit -m next -a --short
> +'
> +
> +test_expect_failure '--porcelain with stuff to commit returns ok' '
> +	echo bongo bongo bongo >>file &&
> +	git commit -m next -a --porcelain
> +'
> +
> +test_expect_success '--long with stuff to commit returns ok' '
> +	echo bongo bongo bongo >>file &&
> +	git commit -m next -a --long
> +'
> +
>  test_expect_success 'commit message from non-existing file' '
>  	echo more bongo: bongo bongo bongo bongo >file &&
>  	test_must_fail git commit -F gah -a

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

* Re: [PATCH] demonstrate git-commit --dry-run exit code behaviour
  2014-02-21 20:21 ` Junio C Hamano
@ 2014-02-22  8:34   ` Jeff King
  2014-02-24 17:16     ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff King @ 2014-02-22  8:34 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Tay Ray Chuan, Git Mailing List

On Fri, Feb 21, 2014 at 12:21:13PM -0800, Junio C Hamano wrote:

> Tay Ray Chuan <rctay89@gmail.com> writes:
> 
> > In particular, show that --short and --porcelain, while implying
> > --dry-run, do not return the same exit code as --dry-run. This is due to
> > the wt_status.commitable flag being set only when a long status is
> > requested.
> 
> I am not sure if --short/--porcelain should even be accepted by "git
> commit" in the first place.  It used to be that "git status" and
> "git commit" were the same program in a different guise and "git
> status <anything>" were merely a "git commit --dry-run <anything>",
> but the recent push is in the direction of making them totally
> separate in the end-user's minds.  So if we want a proper fix, I
> would actually think that these options should *error out* at the
> command line parser level, way before checking if there is anything
> to commit.

I do not think they are any less useful than "git commit --dry-run" in
the first place. If you want to ask "what would happen if I ran commit
with these arguments", you can get the answer in any of several formats
(and --porcelain is the only machine-readable one).

I have never found "commit --dry-run" to be useful, but I assumed that
somebody does.

-Peff

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

* Re: [PATCH] demonstrate git-commit --dry-run exit code behaviour
  2014-02-22  8:34   ` Jeff King
@ 2014-02-24 17:16     ` Junio C Hamano
  0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2014-02-24 17:16 UTC (permalink / raw)
  To: Jeff King; +Cc: Tay Ray Chuan, Git Mailing List

Jeff King <peff@peff.net> writes:

> On Fri, Feb 21, 2014 at 12:21:13PM -0800, Junio C Hamano wrote:
>
>> Tay Ray Chuan <rctay89@gmail.com> writes:
>> 
>> > In particular, show that --short and --porcelain, while implying
>> > --dry-run, do not return the same exit code as --dry-run. This is due to
>> > the wt_status.commitable flag being set only when a long status is
>> > requested.
>> 
>> I am not sure if --short/--porcelain should even be accepted by "git
>> commit" in the first place.  It used to be that "git status" and
>> "git commit" were the same program in a different guise and "git
>> status <anything>" were merely a "git commit --dry-run <anything>",
>> but the recent push is in the direction of making them totally
>> separate in the end-user's minds.  So if we want a proper fix, I
>> would actually think that these options should *error out* at the
>> command line parser level, way before checking if there is anything
>> to commit.
>
> I do not think they are any less useful than "git commit --dry-run" in
> the first place. If you want to ask "what would happen if I ran commit
> with these arguments", you can get the answer in any of several formats
> (and --porcelain is the only machine-readable one).

Hmph.

> I have never found "commit --dry-run" to be useful, but I assumed that
> somebody does.

Same here, and I did not really consider "commit --short" was
intentionally a valid short-hand for "commit --dry-run --short", but
its working as such was an accident, hence my comment.

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

end of thread, other threads:[~2014-02-24 17:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-21 19:16 [PATCH] demonstrate git-commit --dry-run exit code behaviour Tay Ray Chuan
2014-02-21 20:21 ` Junio C Hamano
2014-02-22  8:34   ` Jeff King
2014-02-24 17:16     ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.