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

Re: [PATCH v2 2/4] textconv: support for cat_file

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Jun 8, 2010, 18:12 UTC
Message-ID
<vpq7hm95r7h.fsf@bauges.imag.fr>
In-Reply-To
<1276004958-13540-3-git-send-email-clement.poulain@ensimag.imag.fr>
Clément Poulain <clement.poulain@ensimag.imag.fr> writes:
Show 7 quoted lines
> --- a/builtin/cat-file.c
> +++ b/builtin/cat-file.c
> @@ -9,6 +9,7 @@
> +	struct object_context obj_context = OBJECT_CONTEXT_INIT;
>  
> -	if (get_sha1(obj_name, sha1))
> +	if (get_sha1_with_context(obj_name, sha1, &obj_context))

Do you really need to initialize obj_context here? I'd say the semantics of get_sha1_with_context should be "give me a pointer to an object_context, and I'll fill it in with the object context, whatever be its initial value", just like

int i; scanf("%d", &i);

doesn't require i to be initialized.
> +	case 'c':
> +		if (!obj_context.path)
> +			die("git cat-file --textconv %s: <object> must be <sha1:path>",
> +			    obj_name);

obj_context.path is an array contained in the struct. It is always non-null. Just tried:

$ ./git cat-file --textconv 99f036302a7e6d884369d1d3f4ce428e437cbccd | head fatal: git cat-file --textconv: unable to run textconv on 99f036302a7e6d884369d1d3f4ce428e437cbccd

you want to check that obj_context.path contains an empty string.
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Clément PoulainNext: Matthieu Moy
Message 6 of 10 in “git-gui blame: use textconv”
  1. 0/4 git-gui blame: use textconvClément Poulain, Jun 8, 2010
  2. 1/4 sha1_name: add get_sha1_with_context()Clément Poulain, Jun 8, 2010
  3. 2/4 textconv: support for cat_fileClément Poulain, Jun 8, 2010
  4. 3/4 git gui: use textconv filter for diff and blameClément Poulain, Jun 8, 2010
  5. 4/4 t/t8007: test textconv support for cat-fileClément Poulain, Jun 8, 2010
  6. Matthieu MoyJun 8, 2010
  7. Matthieu MoyJun 8, 2010
  8. Clément PoulainJun 8, 2010
  9. Jeff KingJun 9, 2010
  10. Matthieu MoyJun 9, 2010

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.