]> git.ipfire.org Git - thirdparty/git.git/commit
fsmonitor: query watchman with right valid json
authorSon Luong Ngoc <sluongng@gmail.com>
Tue, 7 Jun 2022 11:14:19 +0000 (13:14 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 7 Jun 2022 17:00:49 +0000 (10:00 -0700)
commit134047b500fd6da079c4aad72c456cd76afe6771
tree550e7d3c7a274fcb644391147ed0c8227b738b53
parente54793a95afeea1e10de1e5ad7eab914e7416250
fsmonitor: query watchman with right valid json

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

  > 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>
Signed-off-by: Son Luong Ngoc <sluongng@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
templates/hooks--fsmonitor-watchman.sample