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

Re: [PATCH 2/2] attr: add flag `-r|--revisions` to work with revisions

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Dec 7, 2022, 11:53 UTC
Message-ID
<221207.86h6y7a0l7.gmgdl@evledraar.gmail.com>
In-Reply-To
<CAOLa=ZS5k=s98Bo9GE+RRa3jtanehL35y-hhLhy1DoM7GyO0cQ@mail.gmail.com>
On Wed, Dec 07 2022, Karthik Nayak wrote:
Show 19 quoted lines
> On Wed, Dec 7, 2022 at 1:12 AM Junio C Hamano <gitster@pobox.com> wrote:
> [...]
>> Also, at the C API level, I suspect that we strongly prefer to pass
>> around either the "struct object_id *" or "struct tree *", not working
>> with end-user supplied character strings without any sanity-checking
>> or parsing.
>>
>
> I must admit, I did take the path of least resistance here. So we finally need
> to parse the `revision:<pathname>` where the `<pathname>` is generated
> dynamically as we move through the check-attr stack.
>
> My question is, if I generate an `object_id` at the start (in
> builtin/check-attr.c)
> with only the `revision`, is there a way to traverse to find the blob
> for each of
> the different <pathnames>? I haven't looked at Git code for a while now, and
> I'm not sure what the best way to do this. Maybe I've missed some API which
> would make this simple, any help is appreciated.

The get_oid() that you're doing now happens in a loop, and should be pulled out of it.

I suggested making that a feature in https://lore.kernel.org/git/221207.86lenja0zi.gmgdl@evledraar.gmail.com/; but if you keep the interface you've got where you only support a single <rev> it would make the most sense to do that get_oid() in the builtin/ code at the start, and then pass the oid/path pair down.

You'd still need to call read_object_file() or equivalent for each <rev>:<path> pair though.

Previous: Karthik NayakNext: Karthik Nayak
Message 10 of 17 in “check-attr: add support to work with revisions”
  1. 0/2 check-attr: add support to work with revisionsKarthik Nayak, Dec 6, 2022
  2. 1/2 t0003: move setup for `--all` into new blockKarthik Nayak, Dec 6, 2022
  3. 2/2 attr: add flag `-r|--revisions` to work with revisionsKarthik Nayak, Dec 6, 2022
  4. Ævar Arnfjörð BjarmasonDec 6, 2022
  5. Karthik NayakDec 6, 2022
  6. Junio C HamanoDec 7, 2022
  7. Eric SunshineDec 7, 2022
  8. Karthik NayakDec 7, 2022
  9. Karthik NayakDec 7, 2022
  10. Ævar Arnfjörð BjarmasonDec 7, 2022
  11. Karthik NayakDec 7, 2022
  12. Ævar Arnfjörð BjarmasonDec 7, 2022
  13. Karthik NayakDec 7, 2022
  14. Philip OakleyDec 6, 2022
  15. Karthik NayakDec 6, 2022
  16. Taylor BlauDec 7, 2022
  17. brian m. carlsonDec 7, 2022

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.