handle_revision_arg: stop using "dotdot" as a generic pointer
The handle_revision_arg() function has a "dotdot" variable that it uses to find a ".." or "..." in the argument. If we don't find one, we look for other marks, like "^!". But we just keep re-using the "dotdot" variable, which is confusing. Let's introduce a separate "mark" variable that can be used for these other marks. They still reuse the same variable, but at least the name is no longer actively misleading. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
May 19, 2017 at 08:50 UTC
f632dedd8d29da20d546612d908a5c1b2ebf37aa
1 file changed
+15
-14
revision.c
+15
-14
@@ -1433,6 +1433,7 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
1433
{
1434
struct object_context oc;
1435
char *dotdot;
1436
+ char *mark;
1437
struct object *object;
1438
unsigned char sha1[20];
1439
int local_flags;
@@ -1529,33 +1530,33 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
1530
*dotdot = '.';
1531
}
1532
1532
- dotdot = strstr(arg, "^@");
1533
- if (dotdot && !dotdot[2]) {
1534
- *dotdot = 0;
1533
+ mark = strstr(arg, "^@");
1534
+ if (mark && !mark[2]) {
1535
+ *mark = 0;
1536
if (add_parents_only(revs, arg, flags, 0))
1537
return 0;
1537
- *dotdot = '^';
1538
+ *mark = '^';
1539
}
1539
- dotdot = strstr(arg, "^!");
1540
- if (dotdot && !dotdot[2]) {
1541
- *dotdot = 0;
1540
+ mark = strstr(arg, "^!");
1541
+ if (mark && !mark[2]) {
1542
+ *mark = 0;
1543
if (!add_parents_only(revs, arg, flags ^ (UNINTERESTING | BOTTOM), 0))
1543
- *dotdot = '^';
1544
+ *mark = '^';
1545
}
1545
- dotdot = strstr(arg, "^-");
1546
- if (dotdot) {
1546
+ mark = strstr(arg, "^-");
1547
+ if (mark) {
1548
int exclude_parent = 1;
1549
1549
- if (dotdot[2]) {
1550
+ if (mark[2]) {
1551
char *end;
1551
- exclude_parent = strtoul(dotdot + 2, &end, 10);
1552
+ exclude_parent = strtoul(mark + 2, &end, 10);
1553
if (*end != '\0' || !exclude_parent)
1554
return -1;
1555
}
1556
1556
- *dotdot = 0;
1557
+ *mark = 0;
1558
if (!add_parents_only(revs, arg, flags ^ (UNINTERESTING | BOTTOM), exclude_parent))
1558
- *dotdot = '^';
1559
+ *mark = '^';
1560
}
1561
1562
local_flags = 0;