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

Re: [RFC/PATCH 1/4] sha1_name: creating context cache

From
Jeff King <peff@peff.net>
Date
Jun 6, 2010, 22:15 UTC
Message-ID
<20100606221557.GF6993@coredump.intra.peff.net>
In-Reply-To
<vpqpr045f46.fsf@bauges.imag.fr>
On Sun, Jun 06, 2010 at 05:56:41PM +0200, Matthieu Moy wrote:
Show 12 quoted lines
> > +struct object_resolve_context {
> > +	unsigned char tree[20];
> > +	char path[PATH_MAX];
> > +	unsigned mode;
> > +};
> > +extern struct object_resolve_context object_context;
> 
> Is it really a good idea to make this a global variable? As I
> understand it, the semantics of this variable is that it contains
> information on the last sha1 name parsed (BTW, you probably want to
> add a comment here explaining that). Wouldn't it be more robust to
> have this value returned by the function doing the parsing?

This is straight from my earlier patch, but I think I said in that thread that it could use some cleaning up. You added the 'mode' field, but it probably makes sense to then get rid of the distinction between get_sha1 and get_sha1_with_mode, and just have:

  get_sha1_with_context(const char *name, unsigned char *sha1, struct
                        object_resolve_context *orc) {
     /* basically get_sha1_with_mode, but set mode in orc */
  }
  get_sha1(const char *name, unsigned char *sha1) {
         struct object_resolve_context orc; /* to be thrown away */
         return get_sha1_with_context(name, sha1, &orc);
  }
-Peff
Previous: Matthieu MoyNext: Clément Poulain
Message 7 of 8 in “git-gui blame: use textconv”
  1. 0/4 git-gui blame: use textconvClément Poulain, Jun 6, 2010
  2. 1/4 sha1_name: creating context cacheClément Poulain, Jun 6, 2010
  3. 2/4 textconv: support for cat-fileClément Poulain, Jun 6, 2010
  4. 3/4 git-gui: use textconv filter for diff and blameClément Poulain, Jun 6, 2010
  5. 4/4 t/t8007: test textconv support for cat-fileClément Poulain, Jun 6, 2010
  6. Matthieu MoyJun 6, 2010
  7. Jeff KingJun 6, 2010
  8. Clément PoulainJun 7, 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.