git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/8] ls-files: add --json to dump the index

From
Duy Nguyen <pclouds@gmail.com>
Date
Jun 24, 2019, 12:50 UTC
Message-ID
<CACsJy8B7j=G2VdYPU8W4eoGJhmJ=7r5gK0FV2QQ8twjzNQQzuQ@mail.gmail.com>
In-Reply-To
<e3b8d7bf-486d-d52f-9a33-6a7ff837552e@gmail.com>
On Wed, Jun 19, 2019 at 8:03 PM Derrick Stolee <stolee@gmail.com> wrote:
Show 34 quoted lines
> > -     show_files(the_repository, &dir);
> > -
> > -     if (show_resolve_undo)
> > -             show_ru_info(the_repository->index);
> > +     if (!show_json) {
> > +             show_files(the_repository, &dir);
> > +
> > +             if (show_resolve_undo)
> > +                     show_ru_info(the_repository->index);
> > +     } else {
> > +             struct json_writer jw = JSON_WRITER_INIT;
> > +
> > +             discard_index(the_repository->index);
> > +             the_repository->index->jw = &jw;
> > +             if (repo_read_index(the_repository) < 0)
> > +                     die("index file corrupt");
> > +             puts(jw.json.buf);
> > +             the_repository->index->jw = NULL;
> > +             jw_release(&jw);
> > +     }
> >
> >       if (ps_matched) {
> >               int bad;
>
> I see this 'ps_matched' condition at the end, which is related to
> the '--error-unmatch' option. I added "--error-unmatch foo" to my
> command and got the appropriate error message:
>
>   error: pathspec 'foo' did not match any file(s) known to git
>   Did you forget to 'git add'?
>
> This was sent to stderr while the JSON was in stdout, so this should
> be appropriate to allow both options. Just pointing it out to make
> sure this is intended.

--error-unmatch only makes sense when you specify pathspec (like "foo") but that does not work well with --json at all because we don't do filtering (how do we even filter in extensions?). I'll just make sure that "ls-files --json <pathspec>" is rejected. That'll cover --error-unmatch.

-- 
Duy
Previous: Johannes SchindelinNext: Nguyễn Thái Ngọc Duy
Message 6 of 36 in “Add 'ls-files --json' to dump the index in json”
  1. 0/8 Add 'ls-files --json' to dump the index in jsonNguyễn Thái Ngọc Duy, Jun 19, 2019
  2. 1/8 ls-files: add --json to dump the indexNguyễn Thái Ngọc Duy, Jun 19, 2019
  3. Ævar Arnfjörð BjarmasonJun 19, 2019
  4. Derrick StoleeJun 19, 2019
  5. Johannes SchindelinJun 21, 2019
  6. Duy NguyenJun 24, 2019
  7. 2/8 split-index.c: dump "link" extension as jsonNguyễn Thái Ngọc Duy, Jun 19, 2019
  8. 3/8 fsmonitor.c: dump "FSMN" extension as jsonNguyễn Thái Ngọc Duy, Jun 19, 2019
  9. 4/8 resolve-undo.c: dump "REUC" extension as jsonNguyễn Thái Ngọc Duy, Jun 19, 2019
  10. Derrick StoleeJun 19, 2019
  11. 5/8 read-cache.c: dump "EOIE" extension as jsonNguyễn Thái Ngọc Duy, Jun 19, 2019
  12. 6/8 read-cache.c: dump "IEOT" extension as jsonNguyễn Thái Ngọc Duy, Jun 19, 2019
  13. Derrick StoleeJun 19, 2019
  14. Duy NguyenJun 19, 2019
  15. Derrick StoleeJun 19, 2019
  16. 7/8 cache-tree.c: dump "TREE" extension as jsonNguyễn Thái Ngọc Duy, Jun 19, 2019
  17. 8/8 dir.c: dump "UNTR" extension as jsonNguyễn Thái Ngọc Duy, Jun 19, 2019
  18. Derrick StoleeJun 19, 2019
  19. Duy NguyenJun 19, 2019
  20. Derrick StoleeJun 19, 2019
  21. Jeff KingJun 19, 2019
  22. Duy NguyenJun 21, 2019
  23. Jeff KingJun 21, 2019
  24. Johannes SchindelinJun 21, 2019
  25. Duy NguyenJun 21, 2019
  26. Junio C HamanoJun 21, 2019
  27. Jeff KingJun 21, 2019
  28. Johannes SchindelinJun 24, 2019
  29. Johannes SchindelinJun 24, 2019
  30. Duy NguyenJun 24, 2019
  31. Jeff KingJun 21, 2019
  32. Johannes SchindelinJun 24, 2019
  33. Junio C HamanoJun 20, 2019
  34. Jeff HostetlerJun 20, 2019
  35. brian m. carlsonJun 21, 2019
  36. Duy NguyenJun 22, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.