git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] t5541-http-push: make grep expression check for one line only
@ 2010-01-25  7:42 Tay Ray Chuan
  2010-01-25 17:47 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Tay Ray Chuan @ 2010-01-25  7:42 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

Simplify the grep expressions in the non-fast-forward tests to check
only for the first line of the non-fast-forward warning - having that
line should be enough assurance that the full warning is printed.

In the first place, grep can't deal with expressions for multiple
lines.

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
 t/t5541-http-push.sh |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/t/t5541-http-push.sh b/t/t5541-http-push.sh
index 83a8e14..53f54a2 100755
--- a/t/t5541-http-push.sh
+++ b/t/t5541-http-push.sh
@@ -105,10 +105,8 @@ test_expect_success 'non-fast-forward push show ref status' '
 '
 
 test_expect_success 'non-fast-forward push shows help message' '
-	grep \
-"To prevent you from losing history, non-fast-forward updates were rejected
-Merge the remote changes before pushing again.  See the '"'non-fast-forward'"'
-section of '"'git push --help'"' for details." output
+	grep "To prevent you from losing history, non-fast-forward updates were rejected" \
+		output
 '
 
 test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper' '
@@ -126,10 +124,8 @@ test_expect_success 'push fails for non-fast-forward refs unmatched by remote he
 	grep "^ + [a-f0-9]*\.\.\.[a-f0-9]* *master -> master (forced update)$" output &&
 	grep "^ ! \[rejected\] *master -> retsam (non-fast-forward)$" output &&
 
-	grep \
-"To prevent you from losing history, non-fast-forward updates were rejected
-Merge the remote changes before pushing again.  See the '"'non-fast-forward'"'
-section of '"'git push --help'"' for details." output
+	grep "To prevent you from losing history, non-fast-forward updates were rejected" \
+		output
 '
 
 stop_httpd
-- 
1.6.6

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

* Re: [PATCH] t5541-http-push: make grep expression check for one line only
  2010-01-25  7:42 [PATCH] t5541-http-push: make grep expression check for one line only Tay Ray Chuan
@ 2010-01-25 17:47 ` Junio C Hamano
  2010-01-25 17:52   ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2010-01-25 17:47 UTC (permalink / raw)
  To: Tay Ray Chuan; +Cc: git, Junio C Hamano

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

> Simplify the grep expressions in the non-fast-forward tests to check
> only for the first line of the non-fast-forward warning - having that
> line should be enough assurance that the full warning is printed.
>
> In the first place, grep can't deal with expressions for multiple
> lines.

This shows that nobody has ever run this test since January 8th, not even
the original author?

Hmmm.

Thanks.

>
> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
> ---
>  t/t5541-http-push.sh |   12 ++++--------
>  1 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/t/t5541-http-push.sh b/t/t5541-http-push.sh
> index 83a8e14..53f54a2 100755
> --- a/t/t5541-http-push.sh
> +++ b/t/t5541-http-push.sh
> @@ -105,10 +105,8 @@ test_expect_success 'non-fast-forward push show ref status' '
>  '
>  
>  test_expect_success 'non-fast-forward push shows help message' '
> -	grep \
> -"To prevent you from losing history, non-fast-forward updates were rejected
> -Merge the remote changes before pushing again.  See the '"'non-fast-forward'"'
> -section of '"'git push --help'"' for details." output
> +	grep "To prevent you from losing history, non-fast-forward updates were rejected" \
> +		output
>  '
>  
>  test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper' '
> @@ -126,10 +124,8 @@ test_expect_success 'push fails for non-fast-forward refs unmatched by remote he
>  	grep "^ + [a-f0-9]*\.\.\.[a-f0-9]* *master -> master (forced update)$" output &&
>  	grep "^ ! \[rejected\] *master -> retsam (non-fast-forward)$" output &&
>  
> -	grep \
> -"To prevent you from losing history, non-fast-forward updates were rejected
> -Merge the remote changes before pushing again.  See the '"'non-fast-forward'"'
> -section of '"'git push --help'"' for details." output
> +	grep "To prevent you from losing history, non-fast-forward updates were rejected" \
> +		output
>  '
>  
>  stop_httpd
> -- 
> 1.6.6

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

* Re: [PATCH] t5541-http-push: make grep expression check for one line only
  2010-01-25 17:47 ` Junio C Hamano
@ 2010-01-25 17:52   ` Junio C Hamano
  2010-01-26  1:33     ` Tay Ray Chuan
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2010-01-25 17:52 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Tay Ray Chuan, git

Junio C Hamano <gitster@pobox.com> writes:

> Tay Ray Chuan <rctay89@gmail.com> writes:
>
>> Simplify the grep expressions in the non-fast-forward tests to check
>> only for the first line of the non-fast-forward warning - having that
>> line should be enough assurance that the full warning is printed.
>>
>> In the first place, grep can't deal with expressions for multiple
>> lines.
>
> This shows that nobody has ever run this test since January 8th, not even
> the original author?
>
> Hmmm.

Actually, if you grep with a pattern with multiple lines, it is equivalent
to giving each of these lines as a separate pattern from the command line.
So it is understandable that the tests passed.  They were checking if
these match, but it doesn't check (and grep is not designed to) if the
first pattern matched the first line, the second to second, etc.

So I'd say something like...

    Don't feed multiple-line pattern to grep and expect them to match with
    lines in order.

    Simplify the grep expressions in the non-fast-forward tests to check
    only for the first line of the non-fast-forward warning - having that
    line should be enough assurance that the full warning is printed.

    Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>

instead.

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

* Re: [PATCH] t5541-http-push: make grep expression check for one line  only
  2010-01-25 17:52   ` Junio C Hamano
@ 2010-01-26  1:33     ` Tay Ray Chuan
  2010-01-26  1:37       ` Tay Ray Chuan
  0 siblings, 1 reply; 5+ messages in thread
From: Tay Ray Chuan @ 2010-01-26  1:33 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Hi,

On Tue, Jan 26, 2010 at 1:52 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Tay Ray Chuan <rctay89@gmail.com> writes:
>>
>>> Simplify the grep expressions in the non-fast-forward tests to check
>>> only for the first line of the non-fast-forward warning - having that
>>> line should be enough assurance that the full warning is printed.
>>>
>>> In the first place, grep can't deal with expressions for multiple
>>> lines.
>>
>> This shows that nobody has ever run this test since January 8th, not even
>> the original author?
>>
>> Hmmm.
>
> Actually, if you grep with a pattern with multiple lines, it is equivalent
> to giving each of these lines as a separate pattern from the command line.
> So it is understandable that the tests passed.  They were checking if
> these match, but it doesn't check (and grep is not designed to) if the
> first pattern matched the first line, the second to second, etc.

that was why the tests passed then and passed now - I just happened to
run them, and I noticed grep reported success, yet only matched 2 of
the 3 lines. Then I remembered recently there had been a rewording of
the fast-forward warning was reworded (c0eb604 "push: spell 'Note
about fast-forwards'")...

> So I'd say something like...
>
>    Don't feed multiple-line pattern to grep and expect them to match with
>    lines in order.
>
>    Simplify the grep expressions in the non-fast-forward tests to check
>    only for the first line of the non-fast-forward warning - having that
>    line should be enough assurance that the full warning is printed.
>
>    Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
>
> instead.

No problem.

-- 
Cheers,
Ray Chuan

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

* [PATCH] t5541-http-push: make grep expression check for one line only
  2010-01-26  1:33     ` Tay Ray Chuan
@ 2010-01-26  1:37       ` Tay Ray Chuan
  0 siblings, 0 replies; 5+ messages in thread
From: Tay Ray Chuan @ 2010-01-26  1:37 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

Don't feed multiple-line pattern to grep and expect them to match with
lines in order.

Simplify the grep expressions in the non-fast-forward tests to check
only for the first line of the non-fast-forward warning - having that
line should be enough assurance that the full warning is printed.

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
 t/t5541-http-push.sh |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/t/t5541-http-push.sh b/t/t5541-http-push.sh
index 83a8e14..53f54a2 100755
--- a/t/t5541-http-push.sh
+++ b/t/t5541-http-push.sh
@@ -105,10 +105,8 @@ test_expect_success 'non-fast-forward push show ref status' '
 '
 
 test_expect_success 'non-fast-forward push shows help message' '
-	grep \
-"To prevent you from losing history, non-fast-forward updates were rejected
-Merge the remote changes before pushing again.  See the '"'non-fast-forward'"'
-section of '"'git push --help'"' for details." output
+	grep "To prevent you from losing history, non-fast-forward updates were rejected" \
+		output
 '
 
 test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper' '
@@ -126,10 +124,8 @@ test_expect_success 'push fails for non-fast-forward refs unmatched by remote he
 	grep "^ + [a-f0-9]*\.\.\.[a-f0-9]* *master -> master (forced update)$" output &&
 	grep "^ ! \[rejected\] *master -> retsam (non-fast-forward)$" output &&
 
-	grep \
-"To prevent you from losing history, non-fast-forward updates were rejected
-Merge the remote changes before pushing again.  See the '"'non-fast-forward'"'
-section of '"'git push --help'"' for details." output
+	grep "To prevent you from losing history, non-fast-forward updates were rejected" \
+		output
 '
 
 stop_httpd
-- 
1.6.6.1.436.gaba7d

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

end of thread, other threads:[~2010-01-26  1:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-25  7:42 [PATCH] t5541-http-push: make grep expression check for one line only Tay Ray Chuan
2010-01-25 17:47 ` Junio C Hamano
2010-01-25 17:52   ` Junio C Hamano
2010-01-26  1:33     ` Tay Ray Chuan
2010-01-26  1:37       ` Tay Ray Chuan

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).