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

Re: [PATCH v2 2/2] diff: generate prettier filenames when using GIT_EXTERNAL_DIFF

From
Jeff King <peff@peff.net>
Date
May 28, 2009, 17:44 UTC
Message-ID
<20090528174436.GA12723@coredump.intra.peff.net>
In-Reply-To
<1243491077-27738-2-git-send-email-davvid@gmail.com>
On Wed, May 27, 2009 at 11:11:17PM -0700, David Aguilar wrote:
> +int git_mkstemps(char *path, size_t n, const char *template, int suffix_len);

FWIW, I find this name not very descriptive. From the name, I would expect it to do the exact same thing as mkstemps, but be our own personal implementation. But it is actually a wrapper that behaves somewhat differently. So I wonder if "mkstemps_tmpdir" or something would be a better name.

> +	if (pretty_filename) {
> +		/* Generate "XXXXXX_filename" */

Is there a reason _not_ to always just use the pretty filename? It looks like you turn it on for external diff, but off for textconv. I don't think there is a reason not to use it for textconv.

Is there some other code path that changes it that I'm missing?
> +		int pretty_filename = 1;
> +		temp_one = prepare_temp_file(name, one, pretty_filename);
> +		temp_two = prepare_temp_file(othername, two, pretty_filename);
I think this reads much better as just:
  temp_one = prepare_temp_file(name, one, 1);
  temp_two = prepare_temp_file(othername, two, 1);

Then it eliminates one bit of state for the reader to keep track of; I don't have to wonder if pretty_filename might ever change. If I care about what the '1' means, I can go look at the definition of prepare_temp_file (or if you really want to make it more self-documenting, make it a "flags" field and set the USE_PRETTY_FILENAME flag).

However, I suspect that all callers should use pretty filenames, and then this bit would just go away.

> +	int pretty_filename = 0;
>  
> -	temp = prepare_temp_file(spec->path, spec);
> +	temp = prepare_temp_file(spec->path, spec, pretty_filename);
Ditto here.
-Peff
Previous: David AguilarNext: David Aguilar
Message 3 of 7 in “compat: add a mkstemps() compatibility function”
  1. 1/2 compat: add a mkstemps() compatibility functionDavid Aguilar, May 28, 2009
  2. 2/2 diff: generate prettier filenames when using GIT_EXTERNAL_DIFFDavid Aguilar, May 28, 2009
  3. Jeff KingMay 28, 2009
  4. David AguilarMay 28, 2009
  5. Jeff KingMay 28, 2009
  6. Johannes SixtMay 28, 2009
  7. David AguilarMay 28, 2009

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.