16
16
#include "string-list.h"
17
17
#include "utf8.h"
18
18
#include "parse-options.h"
19
+ #include "quote.h"
19
20
20
21
static const char * fast_export_usage [] = {
21
22
"git fast-export [rev-list-opts]" ,
@@ -178,6 +179,15 @@ static int depth_first(const void *a_, const void *b_)
178
179
return (a -> status == 'R' ) - (b -> status == 'R' );
179
180
}
180
181
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
+
181
191
static void show_filemodify (struct diff_queue_struct * q ,
182
192
struct diff_options * options , void * data )
183
193
{
@@ -195,13 +205,18 @@ static void show_filemodify(struct diff_queue_struct *q,
195
205
196
206
switch (q -> queue [i ]-> status ) {
197
207
case DIFF_STATUS_DELETED :
198
- printf ("D %s\n" , spec -> path );
208
+ printf ("D " );
209
+ print_path (spec -> path );
210
+ putchar ('\n' );
199
211
break ;
200
212
201
213
case DIFF_STATUS_COPIED :
202
214
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' );
205
220
206
221
if (!hashcmp (ospec -> sha1 , spec -> sha1 ) &&
207
222
ospec -> mode == spec -> mode )
@@ -216,13 +231,15 @@ static void show_filemodify(struct diff_queue_struct *q,
216
231
* output the SHA-1 verbatim.
217
232
*/
218
233
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 ));
221
236
else {
222
237
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 ));
225
240
}
241
+ print_path (spec -> path );
242
+ putchar ('\n' );
226
243
break ;
227
244
228
245
default :
0 commit comments