All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Boyd <bebarino@gmail.com>
To: David Aguilar <davvid@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: Mon, 25 May 2009 23:01:28 -0700	[thread overview]
Message-ID: <4A1B85B8.1050907@gmail.com> (raw)
In-Reply-To: <1243316165-99065-1-git-send-email-davvid@gmail.com>

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"?

  reply	other threads:[~2009-05-26  6:01 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 [this message]
2009-05-26 17:37   ` David Aguilar
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=4A1B85B8.1050907@gmail.com \
    --to=bebarino@gmail.com \
    --cc=davvid@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.