diff: generate pretty filenames in prep_temp_blob()
Naturally, prep_temp_blob() did not care about filenames. As a result, GIT_EXTERNAL_DIFF and textconv generated filenames such as ".diff_XXXXXX". This modifies prep_temp_blob() to generate user-friendly filenames when creating temporary files. Diffing "name.ext" now generates "XXXXXX_name.ext". Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
e1c0688692
commit
003b33a8ad
16
path.c
16
path.c
@ -139,6 +139,22 @@ int git_mkstemp(char *path, size_t len, const char *template)
|
||||
return mkstemp(path);
|
||||
}
|
||||
|
||||
/* git_mkstemps() - create tmp file with suffix honoring TMPDIR variable. */
|
||||
int git_mkstemps(char *path, size_t len, const char *template, int suffix_len)
|
||||
{
|
||||
const char *tmp;
|
||||
size_t n;
|
||||
|
||||
tmp = getenv("TMPDIR");
|
||||
if (!tmp)
|
||||
tmp = "/tmp";
|
||||
n = snprintf(path, len, "%s/%s", tmp, template);
|
||||
if (len <= n) {
|
||||
errno = ENAMETOOLONG;
|
||||
return -1;
|
||||
}
|
||||
return mkstemps(path, suffix_len);
|
||||
}
|
||||
|
||||
int validate_headref(const char *path)
|
||||
{
|
||||
|
Reference in New Issue
Block a user