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

Re: [PATCH 2/8] convert: permit passing additional metadata to filter processes

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 11, 2020, 20:38 UTC
Message-ID
<xmqq1rpyhbjd.fsf@gitster.c.googlers.com>
In-Reply-To
<20200310182046.748959-3-sandals@crustytoothpaste.net>
"brian m. carlson" <sandals@crustytoothpaste.net> writes:
> From: "brian m. carlson" <bk2204@github.com>

Do you want this name/address associated to your contributions? I am asking because to me you have always been "that toothpaste guy" ;-)

Show 22 quoted lines
> There are a variety of situations where a filter process can make use of
> some additional metadata.  For example, some people find the ident
> filter too limiting and would like to include the commit or the branch
> in their smudged files.  This information isn't available during
> checkout as HEAD hasn't been updated at that point, and it wouldn't be
> available in archives either.
>
> Let's add a way to pass this metadata down to the filter.  We pass the
> blob we're operating on, the treeish (preferring the commit over the
> tree if one exists), and the ref we're operating on.  Note that we won't
> pass this information in all cases, such as when renormalizing or when
> we're performing diffs, since it doesn't make sense in those cases.
>
> This series wires up the code to print this information, but doesn't
> pass any of it at this point.  In a future commit, we'll have various
> code paths pass the actual useful data down.
> ...
> +struct checkout_metadata {
> +	const char *refname;
> +	struct object_id treeish;
> +	struct object_id blob;
> +};

The "filter" you talk about is the clean/smudge kind of thing that works on individual blobs, and the series is about giving a bit more information than the raw contents to be filtered. I am assuming that I got at least that part correctly.

Now, a few questions.

Is "refname" "refs/heads/branch? when I run "git checkout branch" or "git checkout branch -- Makefile"? Is "treeish" the same as the output from "rev-parse branch^{commit}" in such a case?

Assuming they are, what refname and treeish does my filter see, when the user did these things?

    git checkout origin/master
    git checkout v1.2.3
    git checkout v1.2.3~4

As a writer of a filter, do I get different clues when I am munging Documentation/Makefile and t/Makefile, when the user does

    git checkout master -- Makefile Documentation/Makefile

i.e. grab these two files out of the tree of the commit at the tip of the master branch?

Or do I just learn what the "refname" (presumably "refs/heads/master"?) and treeish (presumably "rev-parse master^{commit}") and I cannot tell where in that tree hierarchy the contents come from?

Thanks.
Previous: brian m. carlsonNext: brian m. carlson
Message 11 of 14 in “Additional metadata for filter processes”
  1. 0/8 Additional metadata for filter processesbrian m. carlson, Mar 10, 2020
  2. 1/8 builtin/checkout: pass branch info down to checkout_worktreebrian m. carlson, Mar 10, 2020
  3. 3/8 convert: provide additional metadata to filtersbrian m. carlson, Mar 10, 2020
  4. 5/8 builtin/clone: compute checkout metadata for clonesbrian m. carlson, Mar 10, 2020
  5. SZEDER GáborMar 15, 2020
  6. brian m. carlsonMar 15, 2020
  7. Junio C HamanoMar 15, 2020
  8. 4/8 builtin/checkout: compute checkout metadata for checkoutsbrian m. carlson, Mar 10, 2020
  9. 6/8 builtin/rebase: compute checkout metadata for rebasesbrian m. carlson, Mar 10, 2020
  10. 2/8 convert: permit passing additional metadata to filter processesbrian m. carlson, Mar 10, 2020
  11. Junio C HamanoMar 11, 2020
  12. brian m. carlsonMar 12, 2020
  13. 8/8 t0021: test filter metadata for additional casesbrian m. carlson, Mar 10, 2020
  14. 7/8 builtin/reset: compute checkout metadata for resetbrian m. carlson, Mar 10, 2020

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.