revision traversal: SHOWN means shown
This moves the code to set SHOWN on the commit from get_revision_1() back to get_revision(), so that the bit means what it originally meant: this commit has been given back to the caller. Also it fixes the --reverse breakage Dscho pointed out. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Mar 5, 2007 at 18:23 UTC
c33d8593851ef1b3b59fc9b8022019cb955e8d59
1 file changed
+18
-8
revision.c
+18
-8
@@ -1227,7 +1227,6 @@ static struct commit *get_revision_1(struct rev_info *revs)
1227
if (revs->parents)
1228
rewrite_parents(revs, commit);
1229
}
1230
- commit->object.flags |= SHOWN;
1230
return commit;
1231
} while (revs->commits);
1232
return NULL;
@@ -1280,11 +1279,22 @@ struct commit *get_revision(struct rev_info *revs)
1279
}
1280
1281
if (revs->reverse) {
1282
+ int limit = -1;
1283
+
1284
+ if (0 <= revs->max_count) {
1285
+ limit = revs->max_count;
1286
+ if (0 < revs->skip_count)
1287
+ limit += revs->skip_count;
1288
+ }
1289
l = NULL;
1284
- while ((c = get_revision_1(revs)))
1290
+ while ((c = get_revision_1(revs))) {
1291
commit_list_insert(c, &l);
1292
+ if ((0 < limit) && !--limit)
1293
+ break;
1294
+ }
1295
revs->commits = l;
1296
revs->reverse = 0;
1297
+ revs->max_count = -1;
1298
c = NULL;
1299
}
1300
@@ -1298,8 +1308,6 @@ struct commit *get_revision(struct rev_info *revs)
1308
c = get_revision_1(revs);
1309
if (!c)
1310
break;
1301
- /* Although we grabbed it, it is not shown. */
1302
- c->object.flags &= ~SHOWN;
1311
}
1312
1313
/*
@@ -1310,16 +1318,18 @@ struct commit *get_revision(struct rev_info *revs)
1318
break;
1319
case 0:
1320
/* Although we grabbed it, it is not shown. */
1313
- if (c)
1314
- c->object.flags &= ~SHOWN;
1321
c = NULL;
1322
break;
1323
default:
1324
revs->max_count--;
1325
}
1326
1321
- if (!revs->boundary)
1327
+ if (c)
1328
+ c->object.flags |= SHOWN;
1329
+
1330
+ if (!revs->boundary) {
1331
return c;
1332
+ }
1333
1334
if (!c) {
1335
/*
@@ -1341,7 +1351,7 @@ struct commit *get_revision(struct rev_info *revs)
1351
for (l = c->parents; l; l = l->next) {
1352
struct object *p;
1353
p = &(l->item->object);
1344
- if (p->flags & CHILD_SHOWN)
1354
+ if (p->flags & (CHILD_SHOWN | SHOWN))
1355
continue;
1356
p->flags |= CHILD_SHOWN;
1357
gc_boundary(&revs->boundary_commits);