@@ -1946,24 +1946,31 @@ void diff_free_filespec_data(struct diff_filespec *s)
19461946 s -> cnt_data = NULL ;
19471947}
19481948
1949- static void prep_temp_blob (struct diff_tempfile * temp ,
1949+ static void prep_temp_blob (const char * path , struct diff_tempfile * temp ,
19501950 void * blob ,
19511951 unsigned long size ,
19521952 const unsigned char * sha1 ,
19531953 int mode )
19541954{
19551955 int fd ;
1956+ struct strbuf buf = STRBUF_INIT ;
19561957
19571958 fd = git_mkstemp (temp -> tmp_path , PATH_MAX , ".diff_XXXXXX" );
19581959 if (fd < 0 )
19591960 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+ }
19601966 if (write_in_full (fd , blob , size ) != size )
19611967 die ("unable to write temp-file" );
19621968 close (fd );
19631969 temp -> name = temp -> tmp_path ;
19641970 strcpy (temp -> hex , sha1_to_hex (sha1 ));
19651971 temp -> hex [40 ] = 0 ;
19661972 sprintf (temp -> mode , "%06o" , mode );
1973+ strbuf_release (& buf );
19671974}
19681975
19691976static struct diff_tempfile * prepare_temp_file (const char * name ,
@@ -2004,7 +2011,7 @@ static struct diff_tempfile *prepare_temp_file(const char *name,
20042011 die ("readlink(%s)" , name );
20052012 if (ret == sizeof (buf ))
20062013 die ("symlink too long: %s" , name );
2007- prep_temp_blob (temp , buf , ret ,
2014+ prep_temp_blob (name , temp , buf , ret ,
20082015 (one -> sha1_valid ?
20092016 one -> sha1 : null_sha1 ),
20102017 (one -> sha1_valid ?
@@ -2030,7 +2037,7 @@ static struct diff_tempfile *prepare_temp_file(const char *name,
20302037 else {
20312038 if (diff_populate_filespec (one , 0 ))
20322039 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 ,
20342041 one -> sha1 , one -> mode );
20352042 }
20362043 return temp ;
0 commit comments