git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] blame.c: Add translation to warning about failed revision walk
@ 2014-08-10 21:33 Stefan Beller
  2014-08-10 21:33 ` [PATCH 2/2] prepare_revision_walk: Check for return value in all places Stefan Beller
  2014-08-12 16:57 ` [PATCH 1/2] blame.c: Add translation to warning about failed revision walk Junio C Hamano
  0 siblings, 2 replies; 5+ messages in thread
From: Stefan Beller @ 2014-08-10 21:33 UTC (permalink / raw)
  To: gitster, git; +Cc: Stefan Beller

blame belonging to the group of
ancillaryinterrogators and not to plumbinginterrogators
should have localized error messages?

Signed-off-by: Stefan Beller <stefanbeller@gmail.com>
---
 builtin/blame.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/blame.c b/builtin/blame.c
index 17d30d0..ca4ba6f 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -2700,7 +2700,7 @@ parse_done:
 	 * uninteresting.
 	 */
 	if (prepare_revision_walk(&revs))
-		die("revision walk setup failed");
+		die(_("revision walk setup failed"));
 
 	if (is_null_sha1(sb.final->object.sha1)) {
 		o = sb.final->util;
-- 
2.1.0.rc2

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

* [PATCH 2/2] prepare_revision_walk: Check for return value in all places
  2014-08-10 21:33 [PATCH 1/2] blame.c: Add translation to warning about failed revision walk Stefan Beller
@ 2014-08-10 21:33 ` Stefan Beller
  2014-08-11 19:09   ` Junio C Hamano
  2014-08-12 16:57 ` [PATCH 1/2] blame.c: Add translation to warning about failed revision walk Junio C Hamano
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Beller @ 2014-08-10 21:33 UTC (permalink / raw)
  To: gitster, git; +Cc: Stefan Beller

Even the documentation tells us:
	You should check if it
	returns any error (non-zero return code) and if it does not, you can
	start using get_revision() to do the iteration.

In preparation for this commit, I grepped all occurrences of
prepare_revision_walk and added error messages, when there were none.

Signed-off-by: Stefan Beller <stefanbeller@gmail.com>
---
 builtin/branch.c | 4 +++-
 builtin/commit.c | 3 ++-
 remote.c         | 3 ++-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/builtin/branch.c b/builtin/branch.c
index 0591b22..ced422b 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -653,7 +653,9 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru
 		add_pending_object(&ref_list.revs,
 				   (struct object *) filter, "");
 		ref_list.revs.limited = 1;
-		prepare_revision_walk(&ref_list.revs);
+
+		if (prepare_revision_walk(&ref_list.revs))
+			die(_("revision walk setup failed"));
 		if (verbose)
 			ref_list.maxwidth = calc_maxwidth(&ref_list);
 	}
diff --git a/builtin/commit.c b/builtin/commit.c
index 7867768..bb84e1d 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1055,7 +1055,8 @@ static const char *find_author_by_nickname(const char *name)
 	revs.mailmap = &mailmap;
 	read_mailmap(revs.mailmap, NULL);
 
-	prepare_revision_walk(&revs);
+	if (prepare_revision_walk(&revs))
+		die("revision walk setup failed");
 	commit = get_revision(&revs);
 	if (commit) {
 		struct pretty_print_context ctx = {0};
diff --git a/remote.c b/remote.c
index 894db09..112e4d5 100644
--- a/remote.c
+++ b/remote.c
@@ -1893,7 +1893,8 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
 
 	init_revisions(&revs, NULL);
 	setup_revisions(rev_argc, rev_argv, &revs, NULL);
-	prepare_revision_walk(&revs);
+	if (prepare_revision_walk(&revs))
+		die("revision walk setup failed");
 
 	/* ... and count the commits on each side. */
 	*num_ours = 0;
-- 
2.1.0.rc2

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

* Re: [PATCH 2/2] prepare_revision_walk: Check for return value in all places
  2014-08-10 21:33 ` [PATCH 2/2] prepare_revision_walk: Check for return value in all places Stefan Beller
@ 2014-08-11 19:09   ` Junio C Hamano
  2014-08-11 19:23     ` Stefan Beller
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2014-08-11 19:09 UTC (permalink / raw)
  To: Stefan Beller; +Cc: git

Stefan Beller <stefanbeller@gmail.com> writes:

> Even the documentation tells us:
> 	You should check if it
> 	returns any error (non-zero return code) and if it does not, you can
> 	start using get_revision() to do the iteration.
>
> In preparation for this commit, I grepped all occurrences of
> prepare_revision_walk and added error messages, when there were none.

Thanks.  One niggling thing is that I do not seem to find a way for
the function to actually return an error without dying in it, but
these are independently good changes.

>
> Signed-off-by: Stefan Beller <stefanbeller@gmail.com>
> ---
>  builtin/branch.c | 4 +++-
>  builtin/commit.c | 3 ++-
>  remote.c         | 3 ++-
>  3 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/builtin/branch.c b/builtin/branch.c
> index 0591b22..ced422b 100644
> --- a/builtin/branch.c
> +++ b/builtin/branch.c
> @@ -653,7 +653,9 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru
>  		add_pending_object(&ref_list.revs,
>  				   (struct object *) filter, "");
>  		ref_list.revs.limited = 1;
> -		prepare_revision_walk(&ref_list.revs);
> +
> +		if (prepare_revision_walk(&ref_list.revs))
> +			die(_("revision walk setup failed"));
>  		if (verbose)
>  			ref_list.maxwidth = calc_maxwidth(&ref_list);
>  	}
> diff --git a/builtin/commit.c b/builtin/commit.c
> index 7867768..bb84e1d 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -1055,7 +1055,8 @@ static const char *find_author_by_nickname(const char *name)
>  	revs.mailmap = &mailmap;
>  	read_mailmap(revs.mailmap, NULL);
>  
> -	prepare_revision_walk(&revs);
> +	if (prepare_revision_walk(&revs))
> +		die("revision walk setup failed");
>  	commit = get_revision(&revs);
>  	if (commit) {
>  		struct pretty_print_context ctx = {0};
> diff --git a/remote.c b/remote.c
> index 894db09..112e4d5 100644
> --- a/remote.c
> +++ b/remote.c
> @@ -1893,7 +1893,8 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
>  
>  	init_revisions(&revs, NULL);
>  	setup_revisions(rev_argc, rev_argv, &revs, NULL);
> -	prepare_revision_walk(&revs);
> +	if (prepare_revision_walk(&revs))
> +		die("revision walk setup failed");
>  
>  	/* ... and count the commits on each side. */
>  	*num_ours = 0;

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

* Re: [PATCH 2/2] prepare_revision_walk: Check for return value in all places
  2014-08-11 19:09   ` Junio C Hamano
@ 2014-08-11 19:23     ` Stefan Beller
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Beller @ 2014-08-11 19:23 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On 11.08.2014 21:09, Junio C Hamano wrote:
> Stefan Beller <stefanbeller@gmail.com> writes:
> 
>> Even the documentation tells us:
>> 	You should check if it
>> 	returns any error (non-zero return code) and if it does not, you can
>> 	start using get_revision() to do the iteration.
>>
>> In preparation for this commit, I grepped all occurrences of
>> prepare_revision_walk and added error messages, when there were none.
> 
> Thanks.  One niggling thing is that I do not seem to find a way for
> the function to actually return an error without dying in it, but
> these are independently good changes.
> 
>>
>> Signed-off-by: Stefan Beller <stefanbeller@gmail.com>
>> ---
>>  builtin/branch.c | 4 +++-
>>  builtin/commit.c | 3 ++-
>>  remote.c         | 3 ++-
>>  3 files changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/builtin/branch.c b/builtin/branch.c
>> index 0591b22..ced422b 100644
>> --- a/builtin/branch.c
>> +++ b/builtin/branch.c
>> @@ -653,7 +653,9 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru
>>  		add_pending_object(&ref_list.revs,
>>  				   (struct object *) filter, "");
>>  		ref_list.revs.limited = 1;
>> -		prepare_revision_walk(&ref_list.revs);
>> +
>> +		if (prepare_revision_walk(&ref_list.revs))
>> +			die(_("revision walk setup failed"));
>>  		if (verbose)
>>  			ref_list.maxwidth = calc_maxwidth(&ref_list);
>>  	}
>> diff --git a/builtin/commit.c b/builtin/commit.c
>> index 7867768..bb84e1d 100644
>> --- a/builtin/commit.c
>> +++ b/builtin/commit.c
>> @@ -1055,7 +1055,8 @@ static const char *find_author_by_nickname(const char *name)
>>  	revs.mailmap = &mailmap;
>>  	read_mailmap(revs.mailmap, NULL);
>>  
>> -	prepare_revision_walk(&revs);
>> +	if (prepare_revision_walk(&revs))
>> +		die("revision walk setup failed");

Just reviewed the patch myself and here in commit.c we should have a
localized version, right?
Should I resend the patch with the localisation or could you just amend
that?

>>  	commit = get_revision(&revs);
>>  	if (commit) {
>>  		struct pretty_print_context ctx = {0};
>> diff --git a/remote.c b/remote.c
>> index 894db09..112e4d5 100644
>> --- a/remote.c
>> +++ b/remote.c
>> @@ -1893,7 +1893,8 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
>>  
>>  	init_revisions(&revs, NULL);
>>  	setup_revisions(rev_argc, rev_argv, &revs, NULL);
>> -	prepare_revision_walk(&revs);
>> +	if (prepare_revision_walk(&revs))
>> +		die("revision walk setup failed");
>>  
>>  	/* ... and count the commits on each side. */
>>  	*num_ours = 0;

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

* Re: [PATCH 1/2] blame.c: Add translation to warning about failed revision walk
  2014-08-10 21:33 [PATCH 1/2] blame.c: Add translation to warning about failed revision walk Stefan Beller
  2014-08-10 21:33 ` [PATCH 2/2] prepare_revision_walk: Check for return value in all places Stefan Beller
@ 2014-08-12 16:57 ` Junio C Hamano
  1 sibling, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2014-08-12 16:57 UTC (permalink / raw)
  To: Stefan Beller; +Cc: git

Stefan Beller <stefanbeller@gmail.com> writes:

> blame belonging to the group of
> ancillaryinterrogators and not to plumbinginterrogators
> should have localized error messages?

Unless running under --porcelain option to be driven by scripts, we
expect that we are talking to a human user, so using "_(msg)" is very
much appropriate for that case.

A possibly problematic script might do something like this:

	git blame --porcelain "$1" 2>&1 |
        awk "$awkScript"

and the $awkScript may check the input lines that do not match the
expected pattern the output lines from the command follow and act on
them, though.  _(msg) is unwelcome to such a script [*1*].

I suspect the above problem is likely to be theoretical.  People
would be more sloppy and write this instead:

	git blame --porcelain "$1" |
        awk "$awkScript"

and let the problem pass unnoticed, affecting the later parts of
their processing ;-).  And "_(msg)", not "msg", would help.


[Footnote]

*1* ... and with possible interleaving of output that came to the
standard output and the standard error, such parsing by $awkScript
would not be a reliable way to do this anyway.  A truly careful one
has to be written along the lines of:

	git blame --porcelain "$1" >"$tmp" &&
        awk "$awkScript" <"$tmp"

anyway.

> Signed-off-by: Stefan Beller <stefanbeller@gmail.com>
> ---
>  builtin/blame.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/builtin/blame.c b/builtin/blame.c
> index 17d30d0..ca4ba6f 100644
> --- a/builtin/blame.c
> +++ b/builtin/blame.c
> @@ -2700,7 +2700,7 @@ parse_done:
>  	 * uninteresting.
>  	 */
>  	if (prepare_revision_walk(&revs))
> -		die("revision walk setup failed");
> +		die(_("revision walk setup failed"));
>  
>  	if (is_null_sha1(sb.final->object.sha1)) {
>  		o = sb.final->util;

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

end of thread, other threads:[~2014-08-12 16:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-10 21:33 [PATCH 1/2] blame.c: Add translation to warning about failed revision walk Stefan Beller
2014-08-10 21:33 ` [PATCH 2/2] prepare_revision_walk: Check for return value in all places Stefan Beller
2014-08-11 19:09   ` Junio C Hamano
2014-08-11 19:23     ` Stefan Beller
2014-08-12 16:57 ` [PATCH 1/2] blame.c: Add translation to warning about failed revision walk 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).