From: Junio C Hamano <gitster@pobox.com>
To: Son Luong Ngoc <sluongng@gmail.com>
Cc: git@vger.kernel.org, "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: Re: [PATCH v2] fsmonitor: query watchman with right valid json
Date: Tue, 07 Jun 2022 10:00:18 -0700 [thread overview]
Message-ID: <xmqqmteoz9wd.fsf@gitster.g> (raw)
In-Reply-To: <20220607111419.15753-1-sluongng@gmail.com> (Son Luong Ngoc's message of "Tue, 7 Jun 2022 13:14:19 +0200")
Son Luong Ngoc <sluongng@gmail.com> writes:
> In rare circumstances where the current git index does not carry the
> last_update_token, the fsmonitor v2 hook will be invoked with an
> empty string which would caused the final rendered json to be invalid.
>
> ["query", "/path/to/my/git/repository/", {
> "since": ,
> "fields": ["name"],
> "expression": ["not", ["dirname", ".git"]]
> }]
>
> Which will left user with the following error message
"left" -> "leave" (or "give")
> > git status
> failed to parse command from stdin: line 2, column 13, position 67: unexpected token near ','
> Watchman: command returned no output.
> Falling back to scanning...
>
> Hide the "since" field in json query when "last_update_token" is empty.
>
> Co-authored-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
It looked more like Helped-by to me, but I dunno.
> Signed-off-by: Son Luong Ngoc <sluongng@gmail.com>
> ---
> templates/hooks--fsmonitor-watchman.sample | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/templates/hooks--fsmonitor-watchman.sample b/templates/hooks--fsmonitor-watchman.sample
> index 14ed0aa42d..23e856f5de 100755
> --- a/templates/hooks--fsmonitor-watchman.sample
> +++ b/templates/hooks--fsmonitor-watchman.sample
> @@ -86,12 +86,13 @@ sub watchman_query {
> # recency index to select candidate nodes and "fields" to limit the
> # output to file names only. Then we're using the "expression" term to
> # further constrain the results.
> + my $last_update_line = "";
> if (substr($last_update_token, 0, 1) eq "c") {
> $last_update_token = "\"$last_update_token\"";
> + $last_update_line = qq[\n"since": $last_update_token,];
> }
> my $query = <<" END";
> - ["query", "$git_work_tree", {
> - "since": $last_update_token,
> + ["query", "$git_work_tree", {$last_update_line
> "fields": ["name"],
> "expression": ["not", ["dirname", ".git"]]
> }]
OK. Compared to v1, this looks much more reasonable.
This is totally unrelated to the "hide invalid since" topic, but I
wonder if $git_work_tree needs a bit more careful quoting. It comes
directly from get_working_dir() but can it contain say a double quote
character, to make the resulting string in the variable $query not
quite well formed?
prev parent reply other threads:[~2022-06-07 17:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-07 7:54 [PATCH] fsmonitor: query watchman with right valid json Son Luong Ngoc
2022-06-07 8:40 ` Ævar Arnfjörð Bjarmason
2022-06-07 10:56 ` Son Luong Ngoc
2022-06-07 11:14 ` [PATCH v2] " Son Luong Ngoc
2022-06-07 14:39 ` Ævar Arnfjörð Bjarmason
2022-06-07 17:00 ` Junio C Hamano [this message]
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=xmqqmteoz9wd.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=sluongng@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 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).