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

Re: [PATCH 2/3] [GSOC] ref-filter: support %(contents) for blob, tree

From
Junio C Hamano <gitster@pobox.com>
Date
May 25, 2021, 05:03 UTC
Message-ID
<xmqqfsybh0bn.fsf@gitster.g>
In-Reply-To
<19413cfdb1ea50de401ab958b954a550b6514688.1621763612.git.gitgitgadget@gmail.com>
"ZheNing Hu via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 5 quoted lines
> @@ -1292,7 +1326,8 @@ static void append_lines(struct strbuf *out, const char *buf, unsigned long size
>  }
>  
>  /* See grab_values */
> -static void grab_sub_body_contents(struct atom_value *val, int deref, void *buf)

As I already said, I do not think %(contents) mixes well with this use for trees and blobs where you give the raw bytes, since %(contents) for commit and tag objects was never about the full byte sequence of the object. It was to give the unstructured part meant for human consumption, stripping the structured "header" part of the object.

Nevertheless, since queuing this topic breaks the build and gets in the way to find issues in other proposed regression fixes of higher importance,...

Show 12 quoted lines
> +static void grab_contents(struct atom_value *val, int deref, void *buf,
> +			  unsigned long buf_size, enum object_type object_type)
>  {
> ...
> +		switch (object_type) {
> +		case OBJ_TAG:
> +		case OBJ_COMMIT: {
> ...
> +				v->s = xmemdupz(bodypos, bodylen);
> +			else if (atom->u.contents.option == C_LENGTH)
> +				v->s = xstrfmt("%"PRIuMAX, (uintmax_t)strlen(subpos));
> ...

Note that this part inherits from the original and knows how to feed a value to PRIuMAX with correct cast ...

Show 11 quoted lines
> +				v->s = xmemdupz(bodypos, nonsiglen);
> +			else if (atom->u.contents.option == C_SIG)
> ...
> +		}
> +		case OBJ_BLOB:
> +		case OBJ_TREE: {
> +			if (atom->u.contents.option == C_BARE) {
> +				v->s_size = buf_size;
> +				v->s = xmemdupz(buf, buf_size);
> +			} else if (atom->u.contents.option == C_LENGTH)
> +				v->s = xstrfmt("%"PRIuMAX, buf_size);

... but this one gets sloppy, and breaks the windows-build of 'seen'. Fix is simple:

+				v->s = xstrfmt("%"PRIuMAX, (uintmax_t)buf_size);
I'll squash it in before rebuilding 'seen'.
Previous: ZheNing Hu via GitGitGadgetNext: Junio C Hamano
Message 4 of 18 in “[GSOC][RFC] ref-filter: add contents:raw atom”
  1. 0/3 [GSOC][RFC] ref-filter: add contents:raw atomZheNing Hu via GitGitGadget, May 23, 2021
  2. 1/3 [GSOC] quote: add *.quote_buf_with_size functionsZheNing Hu via GitGitGadget, May 23, 2021
  3. 2/3 [GSOC] ref-filter: support %(contents) for blob, treeZheNing Hu via GitGitGadget, May 23, 2021
  4. Junio C HamanoMay 25, 2021
  5. Junio C HamanoMay 25, 2021
  6. ZheNing HuMay 25, 2021
  7. Junio C HamanoMay 25, 2021
  8. ZheNing HuMay 26, 2021
  9. 3/3 [GSOC] ref-filter: add contents:raw atomZheNing Hu via GitGitGadget, May 23, 2021
  10. Junio C HamanoMay 24, 2021
  11. Felipe ContrerasMay 24, 2021
  12. Bagas SanjayaMay 24, 2021
  13. Junio C HamanoMay 24, 2021
  14. ZheNing HuMay 24, 2021
  15. Junio C HamanoMay 26, 2021
  16. ZheNing HuMay 26, 2021
  17. Junio C HamanoMay 26, 2021
  18. ZheNing HuMay 26, 2021

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.