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