@@ -2311,7 +2311,7 @@ static void parse_path_space(struct strbuf *sb, const char *p,
2311
2311
2312
2312
static void file_change_m (const char * p , struct branch * b )
2313
2313
{
2314
- static struct strbuf uq = STRBUF_INIT ;
2314
+ static struct strbuf path = STRBUF_INIT ;
2315
2315
struct object_entry * oe ;
2316
2316
struct object_id oid ;
2317
2317
uint16_t mode , inline_data = 0 ;
@@ -2348,13 +2348,12 @@ static void file_change_m(const char *p, struct branch *b)
2348
2348
die ("Missing space after SHA1: %s" , command_buf .buf );
2349
2349
}
2350
2350
2351
- strbuf_reset (& uq );
2352
- parse_path_eol (& uq , p , "path" );
2353
- p = uq .buf ;
2351
+ strbuf_reset (& path );
2352
+ parse_path_eol (& path , p , "path" );
2354
2353
2355
2354
/* Git does not track empty, non-toplevel directories. */
2356
- if (S_ISDIR (mode ) && is_empty_tree_oid (& oid ) && * p ) {
2357
- tree_content_remove (& b -> branch_tree , p , NULL , 0 );
2355
+ if (S_ISDIR (mode ) && is_empty_tree_oid (& oid ) && * path . buf ) {
2356
+ tree_content_remove (& b -> branch_tree , path . buf , NULL , 0 );
2358
2357
return ;
2359
2358
}
2360
2359
@@ -2375,10 +2374,6 @@ static void file_change_m(const char *p, struct branch *b)
2375
2374
if (S_ISDIR (mode ))
2376
2375
die ("Directories cannot be specified 'inline': %s" ,
2377
2376
command_buf .buf );
2378
- if (p != uq .buf ) {
2379
- strbuf_addstr (& uq , p );
2380
- p = uq .buf ;
2381
- }
2382
2377
while (read_next_command () != EOF ) {
2383
2378
const char * v ;
2384
2379
if (skip_prefix (command_buf .buf , "cat-blob " , & v ))
@@ -2404,55 +2399,51 @@ static void file_change_m(const char *p, struct branch *b)
2404
2399
command_buf .buf );
2405
2400
}
2406
2401
2407
- if (!* p ) {
2402
+ if (!* path . buf ) {
2408
2403
tree_content_replace (& b -> branch_tree , & oid , mode , NULL );
2409
2404
return ;
2410
2405
}
2411
- tree_content_set (& b -> branch_tree , p , & oid , mode , NULL );
2406
+ tree_content_set (& b -> branch_tree , path . buf , & oid , mode , NULL );
2412
2407
}
2413
2408
2414
2409
static void file_change_d (const char * p , struct branch * b )
2415
2410
{
2416
- static struct strbuf uq = STRBUF_INIT ;
2411
+ static struct strbuf path = STRBUF_INIT ;
2417
2412
2418
- strbuf_reset (& uq );
2419
- parse_path_eol (& uq , p , "path" );
2420
- p = uq .buf ;
2421
- tree_content_remove (& b -> branch_tree , p , NULL , 1 );
2413
+ strbuf_reset (& path );
2414
+ parse_path_eol (& path , p , "path" );
2415
+ tree_content_remove (& b -> branch_tree , path .buf , NULL , 1 );
2422
2416
}
2423
2417
2424
2418
static void file_change_cr (const char * p , struct branch * b , int rename )
2425
2419
{
2426
- const char * s , * d ;
2427
- static struct strbuf s_uq = STRBUF_INIT ;
2428
- static struct strbuf d_uq = STRBUF_INIT ;
2420
+ static struct strbuf source = STRBUF_INIT ;
2421
+ static struct strbuf dest = STRBUF_INIT ;
2429
2422
struct tree_entry leaf ;
2430
2423
2431
- strbuf_reset (& s_uq );
2432
- parse_path_space (& s_uq , p , & p , "source" );
2433
- s = s_uq .buf ;
2424
+ strbuf_reset (& source );
2425
+ parse_path_space (& source , p , & p , "source" );
2434
2426
2435
2427
if (!* p )
2436
2428
die ("Missing dest: %s" , command_buf .buf );
2437
- strbuf_reset (& d_uq );
2438
- parse_path_eol (& d_uq , p , "dest" );
2439
- d = d_uq .buf ;
2429
+ strbuf_reset (& dest );
2430
+ parse_path_eol (& dest , p , "dest" );
2440
2431
2441
2432
memset (& leaf , 0 , sizeof (leaf ));
2442
2433
if (rename )
2443
- tree_content_remove (& b -> branch_tree , s , & leaf , 1 );
2434
+ tree_content_remove (& b -> branch_tree , source . buf , & leaf , 1 );
2444
2435
else
2445
- tree_content_get (& b -> branch_tree , s , & leaf , 1 );
2436
+ tree_content_get (& b -> branch_tree , source . buf , & leaf , 1 );
2446
2437
if (!leaf .versions [1 ].mode )
2447
- die ("Path %s not in branch" , s );
2448
- if (!* d ) { /* C "path/to/subdir" "" */
2438
+ die ("Path %s not in branch" , source . buf );
2439
+ if (!* dest . buf ) { /* C "path/to/subdir" "" */
2449
2440
tree_content_replace (& b -> branch_tree ,
2450
2441
& leaf .versions [1 ].oid ,
2451
2442
leaf .versions [1 ].mode ,
2452
2443
leaf .tree );
2453
2444
return ;
2454
2445
}
2455
- tree_content_set (& b -> branch_tree , d ,
2446
+ tree_content_set (& b -> branch_tree , dest . buf ,
2456
2447
& leaf .versions [1 ].oid ,
2457
2448
leaf .versions [1 ].mode ,
2458
2449
leaf .tree );
@@ -3180,7 +3171,7 @@ static void print_ls(int mode, const unsigned char *hash, const char *path)
3180
3171
3181
3172
static void parse_ls (const char * p , struct branch * b )
3182
3173
{
3183
- static struct strbuf uq = STRBUF_INIT ;
3174
+ static struct strbuf path = STRBUF_INIT ;
3184
3175
struct tree_entry * root = NULL ;
3185
3176
struct tree_entry leaf = {NULL };
3186
3177
@@ -3197,18 +3188,17 @@ static void parse_ls(const char *p, struct branch *b)
3197
3188
root -> versions [1 ].mode = S_IFDIR ;
3198
3189
load_tree (root );
3199
3190
}
3200
- strbuf_reset (& uq );
3201
- parse_path_eol (& uq , p , "path" );
3202
- p = uq .buf ;
3203
- tree_content_get (root , p , & leaf , 1 );
3191
+ strbuf_reset (& path );
3192
+ parse_path_eol (& path , p , "path" );
3193
+ tree_content_get (root , path .buf , & leaf , 1 );
3204
3194
/*
3205
3195
* A directory in preparation would have a sha1 of zero
3206
3196
* until it is saved. Save, for simplicity.
3207
3197
*/
3208
3198
if (S_ISDIR (leaf .versions [1 ].mode ))
3209
3199
store_tree (& leaf );
3210
3200
3211
- print_ls (leaf .versions [1 ].mode , leaf .versions [1 ].oid .hash , p );
3201
+ print_ls (leaf .versions [1 ].mode , leaf .versions [1 ].oid .hash , path . buf );
3212
3202
if (leaf .tree )
3213
3203
release_tree_content_recursive (leaf .tree );
3214
3204
if (!b || root != & b -> branch_tree )
0 commit comments