@@ -1948,24 +1948,31 @@ void diff_free_filespec_data(struct diff_filespec *s)
1948
1948
s -> cnt_data = NULL ;
1949
1949
}
1950
1950
1951
- static void prep_temp_blob (struct diff_tempfile * temp ,
1951
+ static void prep_temp_blob (const char * path , struct diff_tempfile * temp ,
1952
1952
void * blob ,
1953
1953
unsigned long size ,
1954
1954
const unsigned char * sha1 ,
1955
1955
int mode )
1956
1956
{
1957
1957
int fd ;
1958
+ struct strbuf buf = STRBUF_INIT ;
1958
1959
1959
1960
fd = git_mkstemp (temp -> tmp_path , PATH_MAX , ".diff_XXXXXX" );
1960
1961
if (fd < 0 )
1961
1962
die ("unable to create temp-file: %s" , strerror (errno ));
1963
+ if (convert_to_working_tree (path ,
1964
+ (const char * )blob , (size_t )size , & buf )) {
1965
+ blob = buf .buf ;
1966
+ size = buf .len ;
1967
+ }
1962
1968
if (write_in_full (fd , blob , size ) != size )
1963
1969
die ("unable to write temp-file" );
1964
1970
close (fd );
1965
1971
temp -> name = temp -> tmp_path ;
1966
1972
strcpy (temp -> hex , sha1_to_hex (sha1 ));
1967
1973
temp -> hex [40 ] = 0 ;
1968
1974
sprintf (temp -> mode , "%06o" , mode );
1975
+ strbuf_release (& buf );
1969
1976
}
1970
1977
1971
1978
static struct diff_tempfile * prepare_temp_file (const char * name ,
@@ -2006,7 +2013,7 @@ static struct diff_tempfile *prepare_temp_file(const char *name,
2006
2013
die ("readlink(%s)" , name );
2007
2014
if (ret == sizeof (buf ))
2008
2015
die ("symlink too long: %s" , name );
2009
- prep_temp_blob (temp , buf , ret ,
2016
+ prep_temp_blob (name , temp , buf , ret ,
2010
2017
(one -> sha1_valid ?
2011
2018
one -> sha1 : null_sha1 ),
2012
2019
(one -> sha1_valid ?
@@ -2032,7 +2039,7 @@ static struct diff_tempfile *prepare_temp_file(const char *name,
2032
2039
else {
2033
2040
if (diff_populate_filespec (one , 0 ))
2034
2041
die ("cannot read data blob for %s" , one -> path );
2035
- prep_temp_blob (temp , one -> data , one -> size ,
2042
+ prep_temp_blob (name , temp , one -> data , one -> size ,
2036
2043
one -> sha1 , one -> mode );
2037
2044
}
2038
2045
return temp ;
0 commit comments