Re: [PATCH v3] diff: generate prettier filenames when using GIT_EXTERNAL_DIFF

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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"?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]