From: David Aguilar <davvid@gmail.com>
To: Stephen Boyd <bebarino@gmail.com>
Cc: git@vger.kernel.org, gitster@pobox.com,
johannes.schindelin@gmx.de, markus.heidelberg@web.de,
nick@incise.org
Subject: Re: [PATCH v3] diff: generate prettier filenames when using GIT_EXTERNAL_DIFF
Date: Tue, 26 May 2009 10:37:29 -0700 [thread overview]
Message-ID: <20090526173726.GA5528@gmail.com> (raw)
In-Reply-To: <4A1B85B8.1050907@gmail.com>
On Mon, May 25, 2009 at 11:01:28PM -0700, Stephen Boyd wrote:
> David Aguilar wrote:
> > - fd = git_mkstemp(temp->tmp_path, PATH_MAX, ".diff_XXXXXX");
> > + if (pretty_filename) {
> > + struct strbuf pretty_name = STRBUF_INIT;
> > + char *pathdup = xstrdup(path);
> > + char *base = basename(pathdup);
> > + char *dot = strchr(base, '.');
> > + int suffix_len = 0;
> > +
> > + if (dot) {
> > + /* path has an extension, e.g. "foo.txt";
> > + * generate "foo.XXXX.txt".
> > + */
> > + *dot = '\0';
> > + strbuf_addstr(&pretty_name, base);
> > + *dot = '.';
> > + strbuf_addstr(&pretty_name, ".XXXXXX");
> > + suffix_len = strlen(dot);
> > + strbuf_addstr(&pretty_name, dot);
>
> This *dot business annoys me. Would it be better to use strbuf_add()
> with some pointer math thrown in? Also, what happens with files such as
> "foo.bar.txt"? Do we want "foo.XXXXX.bar.txt"?
That was intentional; "foo.tar.gz" becomes "foo.XXXXXX.tar.gz",
which is what I considered better behavior when writing it.
Thanks for the note about using strbuf_add(). I'll see if we
can simplify things by using it instead of strbuf_addstr().
I should probably split the "add compat/mkstemps" and
"use it in git_mkstemps()" parts into separate commits since
we're going to want to use the native mkstemps implementation if
it's available.
--
David
next prev parent reply other threads:[~2009-05-26 17:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-26 5:36 [PATCH v3] diff: generate prettier filenames when using GIT_EXTERNAL_DIFF David Aguilar
2009-05-26 6:01 ` Stephen Boyd
2009-05-26 17:37 ` David Aguilar [this message]
2009-05-26 6:12 ` Junio C Hamano
2009-05-26 20:31 ` Markus Heidelberg
2009-05-26 20:52 ` David Aguilar
2009-05-26 21:41 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090526173726.GA5528@gmail.com \
--to=davvid@gmail.com \
--cc=bebarino@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
--cc=markus.heidelberg@web.de \
--cc=nick@incise.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox