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