aboutsummaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-03-26 00:27:30 -0700
committerJunio C Hamano <gitster@pobox.com>2009-03-26 00:27:30 -0700
commitb71fdc590d660f81e8e2ebfdab989feb60e86dde (patch)
treea73038255ad7ab3d43dfed19e47d3d410382bb86 /diff.c
parentb2aa958dc29eb836a831138f6d84ad7cfadf4355 (diff)
parent4e218f54b3de6aa8ef7d15020c4507031a519f7d (diff)
downloadgit-b71fdc590d660f81e8e2ebfdab989feb60e86dde.tar.gz
git-b71fdc590d660f81e8e2ebfdab989feb60e86dde.tar.xz
Merge branch 'js/maint-diff-temp-smudge'
* js/maint-diff-temp-smudge: Smudge the files fed to external diff and textconv
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/diff.c b/diff.c
index 75d9fab8f..699ae6aca 100644
--- a/diff.c
+++ b/diff.c
@@ -1946,17 +1946,23 @@ void diff_free_filespec_data(struct diff_filespec *s)
s->cnt_data = NULL;
}
-static void prep_temp_blob(struct diff_tempfile *temp,
+static void prep_temp_blob(const char *path, struct diff_tempfile *temp,
void *blob,
unsigned long size,
const unsigned char *sha1,
int mode)
{
int fd;
+ struct strbuf buf = STRBUF_INIT;
fd = git_mkstemp(temp->tmp_path, PATH_MAX, ".diff_XXXXXX");
if (fd < 0)
die("unable to create temp-file: %s", strerror(errno));
+ if (convert_to_working_tree(path,
+ (const char *)blob, (size_t)size, &buf)) {
+ blob = buf.buf;
+ size = buf.len;
+ }
if (write_in_full(fd, blob, size) != size)
die("unable to write temp-file");
close(fd);
@@ -1964,6 +1970,7 @@ static void prep_temp_blob(struct diff_tempfile *temp,
strcpy(temp->hex, sha1_to_hex(sha1));
temp->hex[40] = 0;
sprintf(temp->mode, "%06o", mode);
+ strbuf_release(&buf);
}
static struct diff_tempfile *prepare_temp_file(const char *name,
@@ -2004,7 +2011,7 @@ static struct diff_tempfile *prepare_temp_file(const char *name,
die("readlink(%s)", name);
if (ret == sizeof(buf))
die("symlink too long: %s", name);
- prep_temp_blob(temp, buf, ret,
+ prep_temp_blob(name, temp, buf, ret,
(one->sha1_valid ?
one->sha1 : null_sha1),
(one->sha1_valid ?
@@ -2030,7 +2037,7 @@ static struct diff_tempfile *prepare_temp_file(const char *name,
else {
if (diff_populate_filespec(one, 0))
die("cannot read data blob for %s", one->path);
- prep_temp_blob(temp, one->data, one->size,
+ prep_temp_blob(name, temp, one->data, one->size,
one->sha1, one->mode);
}
return temp;