@@ -1180,7 +1180,9 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
1180
1180
!strcmp (arg , "--tags" ) || !strcmp (arg , "--remotes" ) ||
1181
1181
!strcmp (arg , "--reflog" ) || !strcmp (arg , "--not" ) ||
1182
1182
!strcmp (arg , "--no-walk" ) || !strcmp (arg , "--do-walk" ) ||
1183
- !strcmp (arg , "--bisect" ))
1183
+ !strcmp (arg , "--bisect" ) || !prefixcmp (arg , "--glob=" ) ||
1184
+ !prefixcmp (arg , "--branches=" ) || !prefixcmp (arg , "--tags=" ) ||
1185
+ !prefixcmp (arg , "--remotes=" ))
1184
1186
{
1185
1187
unkv [(* unkc )++ ] = arg ;
1186
1188
return 1 ;
@@ -1535,6 +1537,69 @@ static void append_prune_data(const char ***prune_data, const char **av)
1535
1537
* prune_data = prune ;
1536
1538
}
1537
1539
1540
+ static int handle_revision_pseudo_opt (const char * submodule ,
1541
+ struct rev_info * revs ,
1542
+ int argc , const char * * argv , int * flags )
1543
+ {
1544
+ const char * arg = argv [0 ];
1545
+ const char * optarg ;
1546
+ int argcount ;
1547
+
1548
+ /*
1549
+ * NOTE!
1550
+ *
1551
+ * Commands like "git shortlog" will not accept the options below
1552
+ * unless parse_revision_opt queues them (as opposed to erroring
1553
+ * out).
1554
+ *
1555
+ * When implementing your new pseudo-option, remember to
1556
+ * register it in the list at the top of handle_revision_opt.
1557
+ */
1558
+ if (!strcmp (arg , "--all" )) {
1559
+ handle_refs (submodule , revs , * flags , for_each_ref_submodule );
1560
+ handle_refs (submodule , revs , * flags , head_ref_submodule );
1561
+ } else if (!strcmp (arg , "--branches" )) {
1562
+ handle_refs (submodule , revs , * flags , for_each_branch_ref_submodule );
1563
+ } else if (!strcmp (arg , "--bisect" )) {
1564
+ handle_refs (submodule , revs , * flags , for_each_bad_bisect_ref );
1565
+ handle_refs (submodule , revs , * flags ^ UNINTERESTING , for_each_good_bisect_ref );
1566
+ revs -> bisect = 1 ;
1567
+ } else if (!strcmp (arg , "--tags" )) {
1568
+ handle_refs (submodule , revs , * flags , for_each_tag_ref_submodule );
1569
+ } else if (!strcmp (arg , "--remotes" )) {
1570
+ handle_refs (submodule , revs , * flags , for_each_remote_ref_submodule );
1571
+ } else if ((argcount = parse_long_opt ("glob" , argv , & optarg ))) {
1572
+ struct all_refs_cb cb ;
1573
+ init_all_refs_cb (& cb , revs , * flags );
1574
+ for_each_glob_ref (handle_one_ref , optarg , & cb );
1575
+ return argcount ;
1576
+ } else if (!prefixcmp (arg , "--branches=" )) {
1577
+ struct all_refs_cb cb ;
1578
+ init_all_refs_cb (& cb , revs , * flags );
1579
+ for_each_glob_ref_in (handle_one_ref , arg + 11 , "refs/heads/" , & cb );
1580
+ } else if (!prefixcmp (arg , "--tags=" )) {
1581
+ struct all_refs_cb cb ;
1582
+ init_all_refs_cb (& cb , revs , * flags );
1583
+ for_each_glob_ref_in (handle_one_ref , arg + 7 , "refs/tags/" , & cb );
1584
+ } else if (!prefixcmp (arg , "--remotes=" )) {
1585
+ struct all_refs_cb cb ;
1586
+ init_all_refs_cb (& cb , revs , * flags );
1587
+ for_each_glob_ref_in (handle_one_ref , arg + 10 , "refs/remotes/" , & cb );
1588
+ } else if (!strcmp (arg , "--reflog" )) {
1589
+ handle_reflog (revs , * flags );
1590
+ } else if (!strcmp (arg , "--not" )) {
1591
+ * flags ^= UNINTERESTING ;
1592
+ } else if (!strcmp (arg , "--no-walk" )) {
1593
+ revs -> no_walk = 1 ;
1594
+ } else if (!strcmp (arg , "--do-walk" )) {
1595
+ revs -> no_walk = 0 ;
1596
+ } else {
1597
+ return 0 ;
1598
+ }
1599
+
1600
+ return 1 ;
1601
+ }
1602
+
1538
1603
/*
1539
1604
* Parse revision information, filling in the "rev_info" structure,
1540
1605
* and removing the used arguments from the argument list.
@@ -1547,8 +1612,6 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
1547
1612
int i , flags , left , seen_dashdash , read_from_stdin , got_rev_arg = 0 ;
1548
1613
const char * * prune_data = NULL ;
1549
1614
const char * submodule = NULL ;
1550
- const char * optarg ;
1551
- int argcount ;
1552
1615
1553
1616
if (opt )
1554
1617
submodule = opt -> submodule ;
@@ -1575,70 +1638,14 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
1575
1638
if (* arg == '-' ) {
1576
1639
int opts ;
1577
1640
1578
- if (!strcmp (arg , "--all" )) {
1579
- handle_refs (submodule , revs , flags , for_each_ref_submodule );
1580
- handle_refs (submodule , revs , flags , head_ref_submodule );
1581
- continue ;
1582
- }
1583
- if (!strcmp (arg , "--branches" )) {
1584
- handle_refs (submodule , revs , flags , for_each_branch_ref_submodule );
1585
- continue ;
1586
- }
1587
- if (!strcmp (arg , "--bisect" )) {
1588
- handle_refs (submodule , revs , flags , for_each_bad_bisect_ref );
1589
- handle_refs (submodule , revs , flags ^ UNINTERESTING , for_each_good_bisect_ref );
1590
- revs -> bisect = 1 ;
1591
- continue ;
1592
- }
1593
- if (!strcmp (arg , "--tags" )) {
1594
- handle_refs (submodule , revs , flags , for_each_tag_ref_submodule );
1595
- continue ;
1596
- }
1597
- if (!strcmp (arg , "--remotes" )) {
1598
- handle_refs (submodule , revs , flags , for_each_remote_ref_submodule );
1599
- continue ;
1600
- }
1601
- if ((argcount = parse_long_opt ("glob" , argv + i , & optarg ))) {
1602
- struct all_refs_cb cb ;
1603
- i += argcount - 1 ;
1604
- init_all_refs_cb (& cb , revs , flags );
1605
- for_each_glob_ref (handle_one_ref , optarg , & cb );
1606
- continue ;
1607
- }
1608
- if (!prefixcmp (arg , "--branches=" )) {
1609
- struct all_refs_cb cb ;
1610
- init_all_refs_cb (& cb , revs , flags );
1611
- for_each_glob_ref_in (handle_one_ref , arg + 11 , "refs/heads/" , & cb );
1612
- continue ;
1613
- }
1614
- if (!prefixcmp (arg , "--tags=" )) {
1615
- struct all_refs_cb cb ;
1616
- init_all_refs_cb (& cb , revs , flags );
1617
- for_each_glob_ref_in (handle_one_ref , arg + 7 , "refs/tags/" , & cb );
1618
- continue ;
1619
- }
1620
- if (!prefixcmp (arg , "--remotes=" )) {
1621
- struct all_refs_cb cb ;
1622
- init_all_refs_cb (& cb , revs , flags );
1623
- for_each_glob_ref_in (handle_one_ref , arg + 10 , "refs/remotes/" , & cb );
1624
- continue ;
1625
- }
1626
- if (!strcmp (arg , "--reflog" )) {
1627
- handle_reflog (revs , flags );
1628
- continue ;
1629
- }
1630
- if (!strcmp (arg , "--not" )) {
1631
- flags ^= UNINTERESTING ;
1632
- continue ;
1633
- }
1634
- if (!strcmp (arg , "--no-walk" )) {
1635
- revs -> no_walk = 1 ;
1636
- continue ;
1637
- }
1638
- if (!strcmp (arg , "--do-walk" )) {
1639
- revs -> no_walk = 0 ;
1641
+ opts = handle_revision_pseudo_opt (submodule ,
1642
+ revs , argc - i , argv + i ,
1643
+ & flags );
1644
+ if (opts > 0 ) {
1645
+ i += opts - 1 ;
1640
1646
continue ;
1641
1647
}
1648
+
1642
1649
if (!strcmp (arg , "--stdin" )) {
1643
1650
if (revs -> disable_stdin ) {
1644
1651
argv [left ++ ] = arg ;
0 commit comments