public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Stefan Beller <stefanbeller@gmail•com>
Cc: git@vger•kernel.org
Subject: Re: [PATCH 2/2] prepare_revision_walk: Check for return value in all places
Date: Mon, 11 Aug 2014 12:09:38 -0700	[thread overview]
Message-ID: <xmqq1tsm7si5.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1407706406-30455-2-git-send-email-stefanbeller@gmail.com> (Stefan Beller's message of "Sun, 10 Aug 2014 23:33:26 +0200")

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;

  reply	other threads:[~2014-08-11 19:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq1tsm7si5.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=stefanbeller@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox