1616#include "string-list.h"
1717#include "utf8.h"
1818#include "parse-options.h"
19+ #include "quote.h"
1920
2021static const char * fast_export_usage [] = {
2122 "git fast-export [rev-list-opts]" ,
@@ -178,6 +179,15 @@ static int depth_first(const void *a_, const void *b_)
178179 return (a -> status == 'R' ) - (b -> status == 'R' );
179180}
180181
182+ static void print_path (const char * path )
183+ {
184+ int need_quote = quote_c_style (path , NULL , NULL , 0 );
185+ if (need_quote )
186+ quote_c_style (path , NULL , stdout , 0 );
187+ else
188+ printf ("%s" , path );
189+ }
190+
181191static void show_filemodify (struct diff_queue_struct * q ,
182192 struct diff_options * options , void * data )
183193{
@@ -195,13 +205,18 @@ static void show_filemodify(struct diff_queue_struct *q,
195205
196206 switch (q -> queue [i ]-> status ) {
197207 case DIFF_STATUS_DELETED :
198- printf ("D %s\n" , spec -> path );
208+ printf ("D " );
209+ print_path (spec -> path );
210+ putchar ('\n' );
199211 break ;
200212
201213 case DIFF_STATUS_COPIED :
202214 case DIFF_STATUS_RENAMED :
203- printf ("%c \"%s\" \"%s\"\n" , q -> queue [i ]-> status ,
204- ospec -> path , spec -> path );
215+ printf ("%c " , q -> queue [i ]-> status );
216+ print_path (ospec -> path );
217+ putchar (' ' );
218+ print_path (spec -> path );
219+ putchar ('\n' );
205220
206221 if (!hashcmp (ospec -> sha1 , spec -> sha1 ) &&
207222 ospec -> mode == spec -> mode )
@@ -216,13 +231,15 @@ static void show_filemodify(struct diff_queue_struct *q,
216231 * output the SHA-1 verbatim.
217232 */
218233 if (no_data || S_ISGITLINK (spec -> mode ))
219- printf ("M %06o %s %s\n " , spec -> mode ,
220- sha1_to_hex (spec -> sha1 ), spec -> path );
234+ printf ("M %06o %s " , spec -> mode ,
235+ sha1_to_hex (spec -> sha1 ));
221236 else {
222237 struct object * object = lookup_object (spec -> sha1 );
223- printf ("M %06o :%d %s\n " , spec -> mode ,
224- get_object_mark (object ), spec -> path );
238+ printf ("M %06o :%d " , spec -> mode ,
239+ get_object_mark (object ));
225240 }
241+ print_path (spec -> path );
242+ putchar ('\n' );
226243 break ;
227244
228245 default :
0 commit comments