@@ -1427,9 +1427,12 @@ static int reinterpret(struct repository *r,
1427
1427
struct strbuf tmp = STRBUF_INIT ;
1428
1428
int used = buf -> len ;
1429
1429
int ret ;
1430
+ struct interpret_branch_name_options options = {
1431
+ .allowed = allowed
1432
+ };
1430
1433
1431
1434
strbuf_add (buf , name + len , namelen - len );
1432
- ret = repo_interpret_branch_name (r , buf -> buf , buf -> len , & tmp , allowed );
1435
+ ret = repo_interpret_branch_name (r , buf -> buf , buf -> len , & tmp , & options );
1433
1436
/* that data was not interpreted, remove our cruft */
1434
1437
if (ret < 0 ) {
1435
1438
strbuf_setlen (buf , used );
@@ -1471,7 +1474,7 @@ static int interpret_branch_mark(struct repository *r,
1471
1474
int (* get_mark )(const char * , int ),
1472
1475
const char * (* get_data )(struct branch * ,
1473
1476
struct strbuf * ),
1474
- unsigned allowed )
1477
+ const struct interpret_branch_name_options * options )
1475
1478
{
1476
1479
int len ;
1477
1480
struct branch * branch ;
@@ -1496,7 +1499,7 @@ static int interpret_branch_mark(struct repository *r,
1496
1499
if (!value )
1497
1500
die ("%s" , err .buf );
1498
1501
1499
- if (!branch_interpret_allowed (value , allowed ))
1502
+ if (!branch_interpret_allowed (value , options -> allowed ))
1500
1503
return -1 ;
1501
1504
1502
1505
set_shortened_ref (r , buf , value );
@@ -1506,7 +1509,7 @@ static int interpret_branch_mark(struct repository *r,
1506
1509
int repo_interpret_branch_name (struct repository * r ,
1507
1510
const char * name , int namelen ,
1508
1511
struct strbuf * buf ,
1509
- unsigned allowed )
1512
+ const struct interpret_branch_name_options * options )
1510
1513
{
1511
1514
char * at ;
1512
1515
const char * start ;
@@ -1515,38 +1518,39 @@ int repo_interpret_branch_name(struct repository *r,
1515
1518
if (!namelen )
1516
1519
namelen = strlen (name );
1517
1520
1518
- if (!allowed || (allowed & INTERPRET_BRANCH_LOCAL )) {
1521
+ if (!options -> allowed || (options -> allowed & INTERPRET_BRANCH_LOCAL )) {
1519
1522
len = interpret_nth_prior_checkout (r , name , namelen , buf );
1520
1523
if (!len ) {
1521
1524
return len ; /* syntax Ok, not enough switches */
1522
1525
} else if (len > 0 ) {
1523
1526
if (len == namelen )
1524
1527
return len ; /* consumed all */
1525
1528
else
1526
- return reinterpret (r , name , namelen , len , buf , allowed );
1529
+ return reinterpret (r , name , namelen , len , buf ,
1530
+ options -> allowed );
1527
1531
}
1528
1532
}
1529
1533
1530
1534
for (start = name ;
1531
1535
(at = memchr (start , '@' , namelen - (start - name )));
1532
1536
start = at + 1 ) {
1533
1537
1534
- if (!allowed || (allowed & INTERPRET_BRANCH_HEAD )) {
1538
+ if (!options -> allowed || (options -> allowed & INTERPRET_BRANCH_HEAD )) {
1535
1539
len = interpret_empty_at (name , namelen , at - name , buf );
1536
1540
if (len > 0 )
1537
1541
return reinterpret (r , name , namelen , len , buf ,
1538
- allowed );
1542
+ options -> allowed );
1539
1543
}
1540
1544
1541
1545
len = interpret_branch_mark (r , name , namelen , at - name , buf ,
1542
1546
upstream_mark , branch_get_upstream ,
1543
- allowed );
1547
+ options );
1544
1548
if (len > 0 )
1545
1549
return len ;
1546
1550
1547
1551
len = interpret_branch_mark (r , name , namelen , at - name , buf ,
1548
1552
push_mark , branch_get_push ,
1549
- allowed );
1553
+ options );
1550
1554
if (len > 0 )
1551
1555
return len ;
1552
1556
}
@@ -1557,7 +1561,10 @@ int repo_interpret_branch_name(struct repository *r,
1557
1561
void strbuf_branchname (struct strbuf * sb , const char * name , unsigned allowed )
1558
1562
{
1559
1563
int len = strlen (name );
1560
- int used = interpret_branch_name (name , len , sb , allowed );
1564
+ struct interpret_branch_name_options options = {
1565
+ .allowed = allowed
1566
+ };
1567
+ int used = interpret_branch_name (name , len , sb , & options );
1561
1568
1562
1569
if (used < 0 )
1563
1570
used = 0 ;
0 commit comments