# notice: pu broken tonight

10 messages from 2009-06-09 to 2009-06-13. Participants: Junio C Hamano, René Scharfe, Uwe Kleine-König, Johannes Sixt.
Thread: https://gitlist.dev/t/19755

## Junio C Hamano, 2009-06-09 08:36

Subject: notice: pu broken tonight
Message-ID: <7vy6s1pzwb.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vy6s1pzwb.fsf%40alter.siamese.dyndns.org

```
I've queued a handful of patches from yesterday on maint and master,
advanced sp/msysgit topic to next, and queued the remaining new patches
along with the old topics on pu.

I added "just in case output from strerror() had % in it" patch to
tr/die_errno topic when I queued it, but I didn't look at the conversion
from die() to die_errno().

Also I didn't queue the show-branch default_arg patch.  Other than that I
do not think I forgot to queue any patch I saw on the list.

I usually make sure all four branches pass the tests before pushing them
out, but in tonight's integration, the tip of 'pu' does not pass test for
me, hence this notice.

```

## René Scharfe, 2009-06-09 17:11

Subject: Re: notice: pu broken tonight
Message-ID: <4A2E97A9.7040906@lsrfire.ath.cx>
URL: https://gitlist.dev/e/4A2E97A9.7040906%40lsrfire.ath.cx
In-Reply-To: <7vy6s1pzwb.fsf@alter.siamese.dyndns.org>

```
Junio C Hamano schrieb:
> I usually make sure all four branches pass the tests before pushing them
> out, but in tonight's integration, the tip of 'pu' does not pass test for
> me, hence this notice.

The following patch makes the tests pass again for me.  Feel free to squash
it into 10c29915.


 Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index 2d36f78..25029a9 100644
--- a/Makefile
+++ b/Makefile
@@ -921,7 +921,7 @@ SANE_TOOL_PATH_SQ = $(subst ','\'',$(SANE_TOOL_PATH))
 BROKEN_PATH_FIX = 's|^\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix $(SANE_TOOL_PATH_SQ)|'
 PATH := $(SANE_TOOL_PATH):${PATH}
 else
-BROKEN_PATH_FIX = d
+BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d'
 endif
 
 ifeq ($(uname_S),Darwin)

```

## Uwe Kleine-König, 2009-06-10 07:44

Subject: Re: notice: pu broken tonight
Message-ID: <20090610074400.GA26020@pengutronix.de>
URL: https://gitlist.dev/e/20090610074400.GA26020%40pengutronix.de
In-Reply-To: <7vy6s1pzwb.fsf@alter.siamese.dyndns.org>

```
Hello Junio,

On Tue, Jun 09, 2009 at 01:36:20AM -0700, Junio C Hamano wrote:
>                                                         Other than that I
> do not think I forgot to queue any patch I saw on the list.
What about

	http://news.gmane.org/find-root.php?group=gmane.comp.version-control.git&article=120990

?  I think it's save, but I didn't get any feed-back by you yet.  (And I
won't believe you when you say you didn't see it, because you took

	http://news.gmane.org/find-root.php?group=gmane.comp.version-control.git&article=117807

from the same thread. :-))

Best regards
Uwe

-- 
Pengutronix e.K.                              | Uwe Kleine-König            |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |

```

## Junio C Hamano, 2009-06-10 07:56

Subject: Re: notice: pu broken tonight
Message-ID: <7vzlcgr088.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vzlcgr088.fsf%40alter.siamese.dyndns.org
In-Reply-To: <20090610074400.GA26020@pengutronix.de>

```
Uwe Kleine-König  <u.kleine-koenig@pengutronix.de> writes:

> Hello Junio,
>
> On Tue, Jun 09, 2009 at 01:36:20AM -0700, Junio C Hamano wrote:
>>                                                         Other than that I
>> do not think I forgot to queue any patch I saw on the list.
> What about
>
> 	http://news.gmane.org/find-root.php?group=gmane.comp.version-control.git&article=120990

> ?  I think it's save, but I didn't get any feed-back by you yet.

Nor anybody else for that matter ;-).

A patch that adds a new feature to a low-level building block without any
in-tree users, especially if there is no test for it, ranks very low in
the priority scale when I am short of time.

```

## Uwe Kleine-König, 2009-06-10 09:42

Subject: [PATCH 1/2] more tests for git rev-parse --parse-opt
Message-ID: <1244626926-19841-1-git-send-email-u.kleine-koenig@pengutronix.de>
URL: https://gitlist.dev/e/1244626926-19841-1-git-send-email-u.kleine-koenig%40pengutronix.de
In-Reply-To: <7vzlcgr088.fsf@alter.siamese.dyndns.org>

```
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
Hello,

I'm not completely sure that it's portable to use input redirection and
&& together---at least it looks a bit ugly.  Probably you know better.

Best regards
Uwe

 t/t1502-rev-parse-parseopt.sh |   48 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/t/t1502-rev-parse-parseopt.sh b/t/t1502-rev-parse-parseopt.sh
index 997002d..081812b 100755
--- a/t/t1502-rev-parse-parseopt.sh
+++ b/t/t1502-rev-parse-parseopt.sh
@@ -20,8 +20,7 @@ Extras
 
 EOF
 
-test_expect_success 'test --parseopt help output' '
-	git rev-parse --parseopt -- -h 2> output.err <<EOF
+OPTION_SPEC="\
 some-command [options] <args>...
 
 some-command does foo and bar!
@@ -36,8 +35,53 @@ C?        option C with an optional argument
 
 Extras
 extra1    line above used to cause a segfault but no longer does
+"
+
+test_expect_success 'test --parseopt help output' '
+	git rev-parse --parseopt -- -h 2> output.err <<EOF
+$OPTION_SPEC
 EOF
 	test_cmp expect.err output.err
 '
 
+cat > expect <<EOF
+set -- --foo --bar 'ham' -- 'arg'
+EOF
+
+test_expect_success 'test --parseopt' '
+	git rev-parse --parseopt -- --foo --bar=ham arg << EOF > output &&
+$OPTION_SPEC
+EOF
+	test_cmp expect output
+'
+
+test_expect_success 'test --parseopt with mixed options and arguments' '
+	git rev-parse --parseopt -- --foo arg --bar=ham << EOF > output &&
+$OPTION_SPEC
+EOF
+	test_cmp expect output
+'
+
+cat > expect <<EOF
+set -- --foo -- 'arg' '--bar=ham'
+EOF
+
+test_expect_success 'test --parseopt with --' '
+	git rev-parse --parseopt -- --foo -- arg --bar=ham << EOF > output &&
+$OPTION_SPEC
+EOF
+	test_cmp expect output
+'
+
+cat > expect <<EOF
+set -- --foo -- '--' 'arg' '--bar=ham'
+EOF
+
+test_expect_success 'test --parseopt --keep-dashdash' '
+	git rev-parse --parseopt --keep-dashdash -- --foo -- arg --bar=ham << EOF > output &&
+$OPTION_SPEC
+EOF
+	test_cmp expect output
+'
+
 test_done
-- 
1.6.3.1

```

## Uwe Kleine-König, 2009-06-10 09:42

Subject: [PATCH 2/2] parse-opt: make PARSE_OPT_STOP_AT_NON_OPTION available to git rev-parse
Message-ID: <1244626926-19841-2-git-send-email-u.kleine-koenig@pengutronix.de>
URL: https://gitlist.dev/e/1244626926-19841-2-git-send-email-u.kleine-koenig%40pengutronix.de
In-Reply-To: <1244626926-19841-1-git-send-email-u.kleine-koenig@pengutronix.de>

```
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
Hi Junio,

> Nor anybody else for that matter ;-).
I just didn't want to upset Peff as he answered to my inital patch.

> A patch that adds a new feature to a low-level building block without any
> in-tree users, especially if there is no test for it, ranks very low in
> the priority scale when I am short of time.
OK for me.  While waiting for you to have more time I added a few tests,
for the new and old code. :-)

Best regards
Uwe

 Documentation/git-rev-parse.txt |    5 +++++
 builtin-rev-parse.c             |    8 ++++++--
 t/t1502-rev-parse-parseopt.sh   |    7 +++++++
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index 4bbdd05..82045a2 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -30,6 +30,11 @@ OPTIONS
 	Only meaningful in `--parseopt` mode. Tells the option parser to echo
 	out the first `--` met instead of skipping it.
 
+--stop-at-non-option::
+	Only meaningful in `--parseopt` mode.  Lets the option parser stop at
+	the first non-option argument.  This can be used to parse sub-commands
+	that take options themself.
+
 --sq-quote::
 	Use 'git-rev-parse' in shell quoting mode (see SQ-QUOTE
 	section below). In contrast to the `--sq` option below, this
diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index 112d622..5ea7518 100644
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
@@ -301,7 +301,7 @@ static const char *skipspaces(const char *s)
 
 static int cmd_parseopt(int argc, const char **argv, const char *prefix)
 {
-	static int keep_dashdash = 0;
+	static int keep_dashdash = 0, stop_at_non_option = 0;
 	static char const * const parseopt_usage[] = {
 		"git rev-parse --parseopt [options] -- [<args>...]",
 		NULL
@@ -309,6 +309,9 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
 	static struct option parseopt_opts[] = {
 		OPT_BOOLEAN(0, "keep-dashdash", &keep_dashdash,
 					"keep the `--` passed as an arg"),
+		OPT_BOOLEAN(0, "stop-at-non-option", &stop_at_non_option,
+					"stop parsing after the "
+					"first non-option argument"),
 		OPT_END(),
 	};
 
@@ -394,7 +397,8 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
 	ALLOC_GROW(opts, onb + 1, osz);
 	memset(opts + onb, 0, sizeof(opts[onb]));
 	argc = parse_options(argc, argv, prefix, opts, usage,
-	                     keep_dashdash ? PARSE_OPT_KEEP_DASHDASH : 0);
+			keep_dashdash ? PARSE_OPT_KEEP_DASHDASH : 0 |
+			stop_at_non_option ? PARSE_OPT_STOP_AT_NON_OPTION : 0);
 
 	strbuf_addf(&parsed, " --");
 	sq_quote_argv(&parsed, argv, 0);
diff --git a/t/t1502-rev-parse-parseopt.sh b/t/t1502-rev-parse-parseopt.sh
index 081812b..93f2cd1 100755
--- a/t/t1502-rev-parse-parseopt.sh
+++ b/t/t1502-rev-parse-parseopt.sh
@@ -73,6 +73,13 @@ EOF
 	test_cmp expect output
 '
 
+test_expect_success 'test --parseopt --stop-at-non-option' '
+	git rev-parse --parseopt --stop-at-non-option -- --foo arg --bar=ham << EOF > output &&
+$OPTION_SPEC
+EOF
+	test_cmp expect output
+'
+
 cat > expect <<EOF
 set -- --foo -- '--' 'arg' '--bar=ham'
 EOF
-- 
1.6.3.1

```

## Johannes Sixt, 2009-06-10 10:37

Subject: Re: [PATCH 1/2] more tests for git rev-parse --parse-opt
Message-ID: <4A2F8CEC.4080600@viscovery.net>
URL: https://gitlist.dev/e/4A2F8CEC.4080600%40viscovery.net
In-Reply-To: <1244626926-19841-1-git-send-email-u.kleine-koenig@pengutronix.de>

```
Uwe Kleine-König schrieb:
> I'm not completely sure that it's portable to use input redirection and
> && together---at least it looks a bit ugly.  Probably you know better.

The problem is more likely that there are shells that dislike heredocs in
eval'ed expressions. But we use such constructs already in other tests, so
it should not matter a lot. Since you are modifying the code anyway, you
can "do it right".

> -test_expect_success 'test --parseopt help output' '
> -	git rev-parse --parseopt -- -h 2> output.err <<EOF
> +OPTION_SPEC="\
>  some-command [options] <args>...
>  
>  some-command does foo and bar!
> @@ -36,8 +35,53 @@ C?        option C with an optional argument
>  
>  Extras
>  extra1    line above used to cause a segfault but no longer does
> +"
> +
> +test_expect_success 'test --parseopt help output' '
> +	git rev-parse --parseopt -- -h 2> output.err <<EOF
> +$OPTION_SPEC
>  EOF
>  	test_cmp expect.err output.err
>  '

You use the same input in this and all new tests; make this:

cat > optionspec <<EOF
...
EOF

test_expect_success 'test --parseopt help output' '
	git rev-parse --parseopt -- -h 2> output.err < optionspec &&
	test_cmp expect.err output.err

(note the added &&).

-- Hannes

```

## Uwe Kleine-König, 2009-06-10 14:16

Subject: Re: [PATCH 1/2] more tests for git rev-parse --parse-opt
Message-ID: <20090610141614.GA20299@pengutronix.de>
URL: https://gitlist.dev/e/20090610141614.GA20299%40pengutronix.de
In-Reply-To: <4A2F8CEC.4080600@viscovery.net>

```
Hello Johannes,

On Wed, Jun 10, 2009 at 12:37:32PM +0200, Johannes Sixt wrote:
> Uwe Kleine-König schrieb:
> > -test_expect_success 'test --parseopt help output' '
> > -	git rev-parse --parseopt -- -h 2> output.err <<EOF
> > +OPTION_SPEC="\
> >  some-command [options] <args>...
> >  
> >  some-command does foo and bar!
> > @@ -36,8 +35,53 @@ C?        option C with an optional argument
> >  
> >  Extras
> >  extra1    line above used to cause a segfault but no longer does
> > +"
> > +
> > +test_expect_success 'test --parseopt help output' '
> > +	git rev-parse --parseopt -- -h 2> output.err <<EOF
> > +$OPTION_SPEC
> >  EOF
> >  	test_cmp expect.err output.err
> >  '
> 
> You use the same input in this and all new tests; make this:
> 
> cat > optionspec <<EOF
> ...
> EOF
> 
> test_expect_success 'test --parseopt help output' '
> 	git rev-parse --parseopt -- -h 2> output.err < optionspec &&
> 	test_cmp expect.err output.err
> 
> (note the added &&).
OK, this should work.  I will rework it later today.

BTW: I wonder why

	git rev-parse --parseopt -- -h 2> output.err < optionspec

fills output.err, is there some magic that detects that the help should
be printed?  *read some source*  ah, -h is hardcoded to print the help.
This is a bit surprising, still more as -h is a valid option in the
specified optionspec.  Thoughts?

Thanks
Uwe

-- 
Pengutronix e.K.                              | Uwe Kleine-König            |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |

```

## Uwe Kleine-König, 2009-06-13 23:58

Subject: [PATCH 1/2] more tests for git rev-parse --parse-opt
Message-ID: <1244937523-6194-1-git-send-email-u.kleine-koenig@pengutronix.de>
URL: https://gitlist.dev/e/1244937523-6194-1-git-send-email-u.kleine-koenig%40pengutronix.de
In-Reply-To: <20090610141614.GA20299@pengutronix.de>

```
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 t/t1502-rev-parse-parseopt.sh |   38 ++++++++++++++++++++++++++++++++++++--
 1 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/t/t1502-rev-parse-parseopt.sh b/t/t1502-rev-parse-parseopt.sh
index 997002d..be0959e 100755
--- a/t/t1502-rev-parse-parseopt.sh
+++ b/t/t1502-rev-parse-parseopt.sh
@@ -20,8 +20,7 @@ Extras
 
 EOF
 
-test_expect_success 'test --parseopt help output' '
-	git rev-parse --parseopt -- -h 2> output.err <<EOF
+cat > optionspec << EOF
 some-command [options] <args>...
 
 some-command does foo and bar!
@@ -37,7 +36,42 @@ C?        option C with an optional argument
 Extras
 extra1    line above used to cause a segfault but no longer does
 EOF
+
+test_expect_success 'test --parseopt help output' '
+	git rev-parse --parseopt -- -h 2> output.err < optionspec
 	test_cmp expect.err output.err
 '
 
+cat > expect <<EOF
+set -- --foo --bar 'ham' -- 'arg'
+EOF
+
+test_expect_success 'test --parseopt' '
+	git rev-parse --parseopt -- --foo --bar=ham arg < optionspec > output &&
+	test_cmp expect output
+'
+
+test_expect_success 'test --parseopt with mixed options and arguments' '
+	git rev-parse --parseopt -- --foo arg --bar=ham < optionspec > output &&
+	test_cmp expect output
+'
+
+cat > expect <<EOF
+set -- --foo -- 'arg' '--bar=ham'
+EOF
+
+test_expect_success 'test --parseopt with --' '
+	git rev-parse --parseopt -- --foo -- arg --bar=ham < optionspec > output &&
+	test_cmp expect output
+'
+
+cat > expect <<EOF
+set -- --foo -- '--' 'arg' '--bar=ham'
+EOF
+
+test_expect_success 'test --parseopt --keep-dashdash' '
+	git rev-parse --parseopt --keep-dashdash -- --foo -- arg --bar=ham < optionspec > output &&
+	test_cmp expect output
+'
+
 test_done
-- 
1.6.3.1

```

## Uwe Kleine-König, 2009-06-13 23:58

Subject: [PATCH 2/2] parse-opt: make PARSE_OPT_STOP_AT_NON_OPTION available to git rev-parse
Message-ID: <1244937523-6194-2-git-send-email-u.kleine-koenig@pengutronix.de>
URL: https://gitlist.dev/e/1244937523-6194-2-git-send-email-u.kleine-koenig%40pengutronix.de
In-Reply-To: <1244937523-6194-1-git-send-email-u.kleine-koenig@pengutronix.de>

```
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 Documentation/git-rev-parse.txt |    5 +++++
 builtin-rev-parse.c             |    8 ++++++--
 t/t1502-rev-parse-parseopt.sh   |    5 +++++
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index 4bbdd05..82045a2 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -30,6 +30,11 @@ OPTIONS
 	Only meaningful in `--parseopt` mode. Tells the option parser to echo
 	out the first `--` met instead of skipping it.
 
+--stop-at-non-option::
+	Only meaningful in `--parseopt` mode.  Lets the option parser stop at
+	the first non-option argument.  This can be used to parse sub-commands
+	that take options themself.
+
 --sq-quote::
 	Use 'git-rev-parse' in shell quoting mode (see SQ-QUOTE
 	section below). In contrast to the `--sq` option below, this
diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index 112d622..5ea7518 100644
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
@@ -301,7 +301,7 @@ static const char *skipspaces(const char *s)
 
 static int cmd_parseopt(int argc, const char **argv, const char *prefix)
 {
-	static int keep_dashdash = 0;
+	static int keep_dashdash = 0, stop_at_non_option = 0;
 	static char const * const parseopt_usage[] = {
 		"git rev-parse --parseopt [options] -- [<args>...]",
 		NULL
@@ -309,6 +309,9 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
 	static struct option parseopt_opts[] = {
 		OPT_BOOLEAN(0, "keep-dashdash", &keep_dashdash,
 					"keep the `--` passed as an arg"),
+		OPT_BOOLEAN(0, "stop-at-non-option", &stop_at_non_option,
+					"stop parsing after the "
+					"first non-option argument"),
 		OPT_END(),
 	};
 
@@ -394,7 +397,8 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
 	ALLOC_GROW(opts, onb + 1, osz);
 	memset(opts + onb, 0, sizeof(opts[onb]));
 	argc = parse_options(argc, argv, prefix, opts, usage,
-	                     keep_dashdash ? PARSE_OPT_KEEP_DASHDASH : 0);
+			keep_dashdash ? PARSE_OPT_KEEP_DASHDASH : 0 |
+			stop_at_non_option ? PARSE_OPT_STOP_AT_NON_OPTION : 0);
 
 	strbuf_addf(&parsed, " --");
 	sq_quote_argv(&parsed, argv, 0);
diff --git a/t/t1502-rev-parse-parseopt.sh b/t/t1502-rev-parse-parseopt.sh
index be0959e..e504058 100755
--- a/t/t1502-rev-parse-parseopt.sh
+++ b/t/t1502-rev-parse-parseopt.sh
@@ -65,6 +65,11 @@ test_expect_success 'test --parseopt with --' '
 	test_cmp expect output
 '
 
+test_expect_success 'test --parseopt --stop-at-non-option' '
+	git rev-parse --parseopt --stop-at-non-option -- --foo arg --bar=ham < optionspec > output &&
+	test_cmp expect output
+'
+
 cat > expect <<EOF
 set -- --foo -- '--' 'arg' '--bar=ham'
 EOF
-- 
1.6.3.1

```
