All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org, Antoine Pelisse <apelisse@gmail.com>
Subject: Re: [PATCH] Fix calling parse_pathspec with no paths nor PATHSPEC_PREFER_* flags
Date: Tue, 22 Oct 2013 10:21:21 -0700	[thread overview]
Message-ID: <xmqq38ntusq6.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1382150484-13207-1-git-send-email-pclouds@gmail.com> ("Nguyễn	Thái Ngọc Duy"'s message of "Sat, 19 Oct 2013 09:41:24 +0700")

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> When parse_pathspec() is called with no paths, the behavior could be
> either return no paths, or return one path that is cwd. Some commands
> do the former, some the latter. parse_pathspec() itself does not make
> either the default and requires the caller to specify either flag if
> it may run into this situation.
>
> I've grep'd through all parse_pathspec() call sites. Some pass
> neither, but those are guaranteed never pass empty path to
> parse_pathspec(). There are two call sites that may pass empty path
> and are fixed with this patch.
>
> Reported-by: Antoine Pelisse <apelisse@gmail.com>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---

Thanks.

>  line-log.c | 3 ++-
>  revision.c | 3 ++-
>  2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/line-log.c b/line-log.c
> index 8b6e497..717638b 100644
> --- a/line-log.c
> +++ b/line-log.c
> @@ -760,7 +760,8 @@ void line_log_init(struct rev_info *rev, const char *prefix, struct string_list
>  			r = r->next;
>  		}
>  		paths[count] = NULL;
> -		parse_pathspec(&rev->diffopt.pathspec, 0, 0, "", paths);
> +		parse_pathspec(&rev->diffopt.pathspec, 0,
> +			       PATHSPEC_PREFER_FULL, "", paths);
>  		free(paths);
>  	}
>  }
> diff --git a/revision.c b/revision.c
> index 0173e01..dd994e9 100644
> --- a/revision.c
> +++ b/revision.c
> @@ -1372,7 +1372,8 @@ static void prepare_show_merge(struct rev_info *revs)
>  			i++;
>  	}
>  	free_pathspec(&revs->prune_data);
> -	parse_pathspec(&revs->prune_data, PATHSPEC_ALL_MAGIC, 0, "", prune);
> +	parse_pathspec(&revs->prune_data, PATHSPEC_ALL_MAGIC,
> +		       PATHSPEC_PREFER_FULL, "", prune);
>  	revs->limited = 1;
>  }

  reply	other threads:[~2013-10-22 17:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-18  9:21 BUG: PATHSPEC_PREFER_CWD requires arguments Antoine Pelisse
2013-10-19  2:41 ` [PATCH] Fix calling parse_pathspec with no paths nor PATHSPEC_PREFER_* flags Nguyễn Thái Ngọc Duy
2013-10-22 17:21   ` Junio C Hamano [this message]
2013-10-22 18:16     ` 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=xmqq38ntusq6.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=apelisse@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.