]> git.ipfire.org Git - thirdparty/git.git/blame - revision.c
git-bundle: various fixups
[thirdparty/git.git] / revision.c
CommitLineData
ae563542
LT
1#include "cache.h"
2#include "tag.h"
3#include "blob.h"
4#include "tree.h"
5#include "commit.h"
a4a88b2b 6#include "diff.h"
ae563542
LT
7#include "refs.h"
8#include "revision.h"
8ecae9b0 9#include "grep.h"
8860fd42 10#include "reflog-walk.h"
ae563542
LT
11
12static char *path_name(struct name_path *path, const char *name)
13{
14 struct name_path *p;
15 char *n, *m;
16 int nlen = strlen(name);
17 int len = nlen + 1;
18
19 for (p = path; p; p = p->up) {
20 if (p->elem_len)
21 len += p->elem_len + 1;
22 }
23 n = xmalloc(len);
24 m = n + len - (nlen + 1);
25 strcpy(m, name);
26 for (p = path; p; p = p->up) {
27 if (p->elem_len) {
28 m -= p->elem_len + 1;
29 memcpy(m, p->elem, p->elem_len);
30 m[p->elem_len] = '/';
31 }
32 }
33 return n;
34}
35
1f1e895f
LT
36void add_object(struct object *obj,
37 struct object_array *p,
38 struct name_path *path,
39 const char *name)
ae563542 40{
1f1e895f 41 add_object_array(obj, path_name(path, name), p);
ae563542
LT
42}
43
44static void mark_blob_uninteresting(struct blob *blob)
45{
46 if (blob->object.flags & UNINTERESTING)
47 return;
48 blob->object.flags |= UNINTERESTING;
49}
50
51void mark_tree_uninteresting(struct tree *tree)
52{
f75e53ed 53 struct tree_desc desc;
4c068a98 54 struct name_entry entry;
ae563542 55 struct object *obj = &tree->object;
ae563542
LT
56
57 if (obj->flags & UNINTERESTING)
58 return;
59 obj->flags |= UNINTERESTING;
60 if (!has_sha1_file(obj->sha1))
61 return;
62 if (parse_tree(tree) < 0)
63 die("bad tree %s", sha1_to_hex(obj->sha1));
f75e53ed
LT
64
65 desc.buf = tree->buffer;
66 desc.size = tree->size;
4c068a98
LT
67 while (tree_entry(&desc, &entry)) {
68 if (S_ISDIR(entry.mode))
69 mark_tree_uninteresting(lookup_tree(entry.sha1));
ae563542 70 else
4c068a98 71 mark_blob_uninteresting(lookup_blob(entry.sha1));
ae563542 72 }
f75e53ed
LT
73
74 /*
75 * We don't care about the tree any more
76 * after it has been marked uninteresting.
77 */
78 free(tree->buffer);
79 tree->buffer = NULL;
ae563542
LT
80}
81
82void mark_parents_uninteresting(struct commit *commit)
83{
84 struct commit_list *parents = commit->parents;
85
86 while (parents) {
87 struct commit *commit = parents->item;
d2c4af73
MU
88 if (!(commit->object.flags & UNINTERESTING)) {
89 commit->object.flags |= UNINTERESTING;
ae563542 90
d2c4af73
MU
91 /*
92 * Normally we haven't parsed the parent
93 * yet, so we won't have a parent of a parent
94 * here. However, it may turn out that we've
95 * reached this commit some other way (where it
96 * wasn't uninteresting), in which case we need
97 * to mark its parents recursively too..
98 */
99 if (commit->parents)
100 mark_parents_uninteresting(commit);
101 }
ae563542
LT
102
103 /*
104 * A missing commit is ok iff its parent is marked
105 * uninteresting.
106 *
107 * We just mark such a thing parsed, so that when
108 * it is popped next time around, we won't be trying
109 * to parse it and get an error.
110 */
111 if (!has_sha1_file(commit->object.sha1))
112 commit->object.parsed = 1;
113 parents = parents->next;
114 }
115}
116
1f1e895f 117void add_pending_object(struct rev_info *revs, struct object *obj, const char *name)
ae563542 118{
aa27e461
LT
119 if (revs->no_walk && (obj->flags & UNINTERESTING))
120 die("object ranges do not make sense when not walking revisions");
1f1e895f 121 add_object_array(obj, name, &revs->pending);
8860fd42
JS
122 if (revs->reflog_info && obj->type == OBJ_COMMIT)
123 add_reflog_for_walk(revs->reflog_info,
124 (struct commit *)obj, name);
ae563542
LT
125}
126
cd2bdc53 127static struct object *get_reference(struct rev_info *revs, const char *name, const unsigned char *sha1, unsigned int flags)
ae563542
LT
128{
129 struct object *object;
130
131 object = parse_object(sha1);
132 if (!object)
133 die("bad object %s", name);
cd2bdc53
LT
134 object->flags |= flags;
135 return object;
136}
137
138static struct commit *handle_commit(struct rev_info *revs, struct object *object, const char *name)
139{
140 unsigned long flags = object->flags;
ae563542
LT
141
142 /*
143 * Tag object? Look what it points to..
144 */
1974632c 145 while (object->type == OBJ_TAG) {
ae563542 146 struct tag *tag = (struct tag *) object;
cd2bdc53 147 if (revs->tag_objects && !(flags & UNINTERESTING))
ae563542
LT
148 add_pending_object(revs, object, tag->tag);
149 object = parse_object(tag->tagged->sha1);
150 if (!object)
151 die("bad object %s", sha1_to_hex(tag->tagged->sha1));
152 }
153
154 /*
155 * Commit object? Just return it, we'll do all the complex
156 * reachability crud.
157 */
1974632c 158 if (object->type == OBJ_COMMIT) {
ae563542 159 struct commit *commit = (struct commit *)object;
ae563542
LT
160 if (parse_commit(commit) < 0)
161 die("unable to parse commit %s", name);
d9a83684 162 if (flags & UNINTERESTING) {
4262c1b0 163 commit->object.flags |= UNINTERESTING;
ae563542 164 mark_parents_uninteresting(commit);
d9a83684
LT
165 revs->limited = 1;
166 }
ae563542
LT
167 return commit;
168 }
169
170 /*
171 * Tree object? Either mark it uniniteresting, or add it
172 * to the list of objects to look at later..
173 */
1974632c 174 if (object->type == OBJ_TREE) {
ae563542
LT
175 struct tree *tree = (struct tree *)object;
176 if (!revs->tree_objects)
177 return NULL;
178 if (flags & UNINTERESTING) {
179 mark_tree_uninteresting(tree);
180 return NULL;
181 }
182 add_pending_object(revs, object, "");
183 return NULL;
184 }
185
186 /*
187 * Blob object? You know the drill by now..
188 */
1974632c 189 if (object->type == OBJ_BLOB) {
ae563542
LT
190 struct blob *blob = (struct blob *)object;
191 if (!revs->blob_objects)
192 return NULL;
193 if (flags & UNINTERESTING) {
194 mark_blob_uninteresting(blob);
195 return NULL;
196 }
197 add_pending_object(revs, object, "");
198 return NULL;
199 }
200 die("%s is unknown object", name);
201}
202
a4a88b2b
LT
203static int everybody_uninteresting(struct commit_list *orig)
204{
205 struct commit_list *list = orig;
206 while (list) {
207 struct commit *commit = list->item;
208 list = list->next;
209 if (commit->object.flags & UNINTERESTING)
210 continue;
211 return 0;
212 }
213 return 1;
214}
215
8efdc326 216static int tree_difference = REV_TREE_SAME;
a4a88b2b
LT
217
218static void file_add_remove(struct diff_options *options,
219 int addremove, unsigned mode,
220 const unsigned char *sha1,
221 const char *base, const char *path)
222{
8efdc326 223 int diff = REV_TREE_DIFFERENT;
a4a88b2b
LT
224
225 /*
8efdc326
FK
226 * Is it an add of a new file? It means that the old tree
227 * didn't have it at all, so we will turn "REV_TREE_SAME" ->
228 * "REV_TREE_NEW", but leave any "REV_TREE_DIFFERENT" alone
229 * (and if it already was "REV_TREE_NEW", we'll keep it
230 * "REV_TREE_NEW" of course).
a4a88b2b
LT
231 */
232 if (addremove == '+') {
233 diff = tree_difference;
8efdc326 234 if (diff != REV_TREE_SAME)
a4a88b2b 235 return;
8efdc326 236 diff = REV_TREE_NEW;
a4a88b2b
LT
237 }
238 tree_difference = diff;
239}
240
241static void file_change(struct diff_options *options,
242 unsigned old_mode, unsigned new_mode,
243 const unsigned char *old_sha1,
244 const unsigned char *new_sha1,
245 const char *base, const char *path)
246{
8efdc326 247 tree_difference = REV_TREE_DIFFERENT;
a4a88b2b
LT
248}
249
c4e05b1a 250int rev_compare_tree(struct rev_info *revs, struct tree *t1, struct tree *t2)
a4a88b2b
LT
251{
252 if (!t1)
8efdc326 253 return REV_TREE_NEW;
a4a88b2b 254 if (!t2)
8efdc326
FK
255 return REV_TREE_DIFFERENT;
256 tree_difference = REV_TREE_SAME;
c4e05b1a 257 if (diff_tree_sha1(t1->object.sha1, t2->object.sha1, "",
cd2bdc53 258 &revs->pruning) < 0)
8efdc326 259 return REV_TREE_DIFFERENT;
a4a88b2b
LT
260 return tree_difference;
261}
262
c4e05b1a 263int rev_same_tree_as_empty(struct rev_info *revs, struct tree *t1)
a4a88b2b
LT
264{
265 int retval;
266 void *tree;
267 struct tree_desc empty, real;
268
269 if (!t1)
270 return 0;
271
8e440259 272 tree = read_object_with_reference(t1->object.sha1, tree_type, &real.size, NULL);
a4a88b2b
LT
273 if (!tree)
274 return 0;
275 real.buf = tree;
276
277 empty.buf = "";
278 empty.size = 0;
279
280 tree_difference = 0;
cd2bdc53 281 retval = diff_tree(&empty, &real, "", &revs->pruning);
a4a88b2b
LT
282 free(tree);
283
284 return retval >= 0 && !tree_difference;
285}
286
287static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
288{
289 struct commit_list **pp, *parent;
6631c736 290 int tree_changed = 0, tree_same = 0;
a4a88b2b
LT
291
292 if (!commit->tree)
293 return;
294
295 if (!commit->parents) {
c4e05b1a 296 if (!rev_same_tree_as_empty(revs, commit->tree))
a4a88b2b
LT
297 commit->object.flags |= TREECHANGE;
298 return;
299 }
300
301 pp = &commit->parents;
302 while ((parent = *pp) != NULL) {
303 struct commit *p = parent->item;
304
a4a88b2b 305 parse_commit(p);
c4e05b1a 306 switch (rev_compare_tree(revs, p->tree, commit->tree)) {
8efdc326 307 case REV_TREE_SAME:
6631c736 308 tree_same = 1;
9202434c 309 if (!revs->simplify_history || (p->object.flags & UNINTERESTING)) {
f3219fbb
JH
310 /* Even if a merge with an uninteresting
311 * side branch brought the entire change
312 * we are interested in, we do not want
313 * to lose the other branches of this
314 * merge, so we just keep going.
315 */
316 pp = &parent->next;
317 continue;
318 }
a4a88b2b
LT
319 parent->next = NULL;
320 commit->parents = parent;
321 return;
322
8efdc326
FK
323 case REV_TREE_NEW:
324 if (revs->remove_empty_trees &&
c4e05b1a 325 rev_same_tree_as_empty(revs, p->tree)) {
c348f31a
JH
326 /* We are adding all the specified
327 * paths from this parent, so the
328 * history beyond this parent is not
329 * interesting. Remove its parents
330 * (they are grandparents for us).
331 * IOW, we pretend this parent is a
332 * "root" commit.
a41e109c 333 */
c348f31a
JH
334 parse_commit(p);
335 p->parents = NULL;
a4a88b2b
LT
336 }
337 /* fallthrough */
8efdc326 338 case REV_TREE_DIFFERENT:
f3219fbb 339 tree_changed = 1;
a4a88b2b
LT
340 pp = &parent->next;
341 continue;
342 }
343 die("bad tree compare for commit %s", sha1_to_hex(commit->object.sha1));
344 }
6631c736 345 if (tree_changed && !tree_same)
f3219fbb 346 commit->object.flags |= TREECHANGE;
a4a88b2b
LT
347}
348
349static void add_parents_to_list(struct rev_info *revs, struct commit *commit, struct commit_list **list)
350{
351 struct commit_list *parent = commit->parents;
577ed5c2 352 unsigned left_flag;
a4a88b2b 353
3381c790
LT
354 if (commit->object.flags & ADDED)
355 return;
356 commit->object.flags |= ADDED;
357
a4a88b2b
LT
358 /*
359 * If the commit is uninteresting, don't try to
360 * prune parents - we want the maximal uninteresting
361 * set.
362 *
363 * Normally we haven't parsed the parent
364 * yet, so we won't have a parent of a parent
365 * here. However, it may turn out that we've
366 * reached this commit some other way (where it
367 * wasn't uninteresting), in which case we need
368 * to mark its parents recursively too..
369 */
370 if (commit->object.flags & UNINTERESTING) {
371 while (parent) {
372 struct commit *p = parent->item;
373 parent = parent->next;
374 parse_commit(p);
375 p->object.flags |= UNINTERESTING;
376 if (p->parents)
377 mark_parents_uninteresting(p);
378 if (p->object.flags & SEEN)
379 continue;
380 p->object.flags |= SEEN;
381 insert_by_date(p, list);
382 }
383 return;
384 }
385
386 /*
387 * Ok, the commit wasn't uninteresting. Try to
388 * simplify the commit history and find the parent
389 * that has no differences in the path set if one exists.
390 */
8efdc326
FK
391 if (revs->prune_fn)
392 revs->prune_fn(revs, commit);
a4a88b2b 393
ba1d4505
LT
394 if (revs->no_walk)
395 return;
396
577ed5c2 397 left_flag = (commit->object.flags & SYMMETRIC_LEFT);
a4a88b2b
LT
398 parent = commit->parents;
399 while (parent) {
400 struct commit *p = parent->item;
401
402 parent = parent->next;
403
404 parse_commit(p);
577ed5c2 405 p->object.flags |= left_flag;
a4a88b2b
LT
406 if (p->object.flags & SEEN)
407 continue;
408 p->object.flags |= SEEN;
409 insert_by_date(p, list);
410 }
411}
412
413static void limit_list(struct rev_info *revs)
414{
415 struct commit_list *list = revs->commits;
416 struct commit_list *newlist = NULL;
417 struct commit_list **p = &newlist;
418
419 while (list) {
420 struct commit_list *entry = list;
421 struct commit *commit = list->item;
422 struct object *obj = &commit->object;
423
424 list = list->next;
425 free(entry);
426
427 if (revs->max_age != -1 && (commit->date < revs->max_age))
428 obj->flags |= UNINTERESTING;
a4a88b2b
LT
429 add_parents_to_list(revs, commit, &list);
430 if (obj->flags & UNINTERESTING) {
431 mark_parents_uninteresting(commit);
432 if (everybody_uninteresting(list))
433 break;
434 continue;
435 }
436 if (revs->min_age != -1 && (commit->date > revs->min_age))
437 continue;
438 p = &commit_list_insert(commit, p)->next;
439 }
440 revs->commits = newlist;
441}
442
63049292
JH
443struct all_refs_cb {
444 int all_flags;
71b03b42 445 int warned_bad_reflog;
63049292
JH
446 struct rev_info *all_revs;
447 const char *name_for_errormsg;
448};
ae563542 449
8da19775 450static int handle_one_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data)
ae563542 451{
63049292
JH
452 struct all_refs_cb *cb = cb_data;
453 struct object *object = get_reference(cb->all_revs, path, sha1,
454 cb->all_flags);
3d1efd8f 455 add_pending_object(cb->all_revs, object, path);
ae563542
LT
456 return 0;
457}
458
459static void handle_all(struct rev_info *revs, unsigned flags)
460{
63049292
JH
461 struct all_refs_cb cb;
462 cb.all_revs = revs;
463 cb.all_flags = flags;
464 for_each_ref(handle_one_ref, &cb);
465}
466
71b03b42 467static void handle_one_reflog_commit(unsigned char *sha1, void *cb_data)
63049292
JH
468{
469 struct all_refs_cb *cb = cb_data;
71b03b42
SP
470 if (!is_null_sha1(sha1)) {
471 struct object *o = parse_object(sha1);
472 if (o) {
473 o->flags |= cb->all_flags;
474 add_pending_object(cb->all_revs, o, "");
475 }
476 else if (!cb->warned_bad_reflog) {
477 warn("reflog of '%s' references pruned commits",
478 cb->name_for_errormsg);
479 cb->warned_bad_reflog = 1;
480 }
63049292 481 }
71b03b42
SP
482}
483
883d60fa
JS
484static int handle_one_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
485 const char *email, unsigned long timestamp, int tz,
486 const char *message, void *cb_data)
71b03b42
SP
487{
488 handle_one_reflog_commit(osha1, cb_data);
489 handle_one_reflog_commit(nsha1, cb_data);
63049292
JH
490 return 0;
491}
492
493static int handle_one_reflog(const char *path, const unsigned char *sha1, int flag, void *cb_data)
494{
495 struct all_refs_cb *cb = cb_data;
71b03b42 496 cb->warned_bad_reflog = 0;
63049292
JH
497 cb->name_for_errormsg = path;
498 for_each_reflog_ent(path, handle_one_reflog_ent, cb_data);
499 return 0;
500}
501
502static void handle_reflog(struct rev_info *revs, unsigned flags)
503{
504 struct all_refs_cb cb;
505 cb.all_revs = revs;
506 cb.all_flags = flags;
25b51e2c 507 for_each_reflog(handle_one_reflog, &cb);
ae563542
LT
508}
509
ea4a19e1
JH
510static int add_parents_only(struct rev_info *revs, const char *arg, int flags)
511{
512 unsigned char sha1[20];
513 struct object *it;
514 struct commit *commit;
515 struct commit_list *parents;
516
517 if (*arg == '^') {
518 flags ^= UNINTERESTING;
519 arg++;
520 }
521 if (get_sha1(arg, sha1))
522 return 0;
523 while (1) {
524 it = get_reference(revs, arg, sha1, 0);
1974632c 525 if (it->type != OBJ_TAG)
ea4a19e1 526 break;
e702496e 527 hashcpy(sha1, ((struct tag*)it)->tagged->sha1);
ea4a19e1 528 }
1974632c 529 if (it->type != OBJ_COMMIT)
ea4a19e1
JH
530 return 0;
531 commit = (struct commit *)it;
532 for (parents = commit->parents; parents; parents = parents->next) {
533 it = &parents->item->object;
534 it->flags |= flags;
535 add_pending_object(revs, it, arg);
536 }
537 return 1;
538}
539
db6296a5 540void init_revisions(struct rev_info *revs, const char *prefix)
8efdc326
FK
541{
542 memset(revs, 0, sizeof(*revs));
8e8f9987 543
6b9c58f4 544 revs->abbrev = DEFAULT_ABBREV;
8e8f9987 545 revs->ignore_merges = 1;
9202434c 546 revs->simplify_history = 1;
cd2bdc53
LT
547 revs->pruning.recursive = 1;
548 revs->pruning.add_remove = file_add_remove;
549 revs->pruning.change = file_change;
8efdc326
FK
550 revs->lifo = 1;
551 revs->dense = 1;
db6296a5 552 revs->prefix = prefix;
8efdc326
FK
553 revs->max_age = -1;
554 revs->min_age = -1;
d5db6c9e 555 revs->skip_count = -1;
8efdc326
FK
556 revs->max_count = -1;
557
558 revs->prune_fn = NULL;
559 revs->prune_data = NULL;
560
561 revs->topo_setter = topo_sort_default_setter;
562 revs->topo_getter = topo_sort_default_getter;
cd2bdc53 563
cd2bdc53
LT
564 revs->commit_format = CMIT_FMT_DEFAULT;
565
566 diff_setup(&revs->diffopt);
8efdc326
FK
567}
568
0d2c9d67
RS
569static void add_pending_commit_list(struct rev_info *revs,
570 struct commit_list *commit_list,
571 unsigned int flags)
572{
573 while (commit_list) {
574 struct object *object = &commit_list->item->object;
575 object->flags |= flags;
576 add_pending_object(revs, object, sha1_to_hex(object->sha1));
577 commit_list = commit_list->next;
578 }
579}
580
ae3e5e1e
JH
581static void prepare_show_merge(struct rev_info *revs)
582{
583 struct commit_list *bases;
584 struct commit *head, *other;
585 unsigned char sha1[20];
586 const char **prune = NULL;
587 int i, prune_num = 1; /* counting terminating NULL */
588
589 if (get_sha1("HEAD", sha1) || !(head = lookup_commit(sha1)))
590 die("--merge without HEAD?");
591 if (get_sha1("MERGE_HEAD", sha1) || !(other = lookup_commit(sha1)))
592 die("--merge without MERGE_HEAD?");
593 add_pending_object(revs, &head->object, "HEAD");
594 add_pending_object(revs, &other->object, "MERGE_HEAD");
595 bases = get_merge_bases(head, other, 1);
596 while (bases) {
597 struct commit *it = bases->item;
598 struct commit_list *n = bases->next;
599 free(bases);
600 bases = n;
601 it->object.flags |= UNINTERESTING;
602 add_pending_object(revs, &it->object, "(merge-base)");
603 }
604
605 if (!active_nr)
606 read_cache();
607 for (i = 0; i < active_nr; i++) {
608 struct cache_entry *ce = active_cache[i];
609 if (!ce_stage(ce))
610 continue;
611 if (ce_path_match(ce, revs->prune_data)) {
612 prune_num++;
613 prune = xrealloc(prune, sizeof(*prune) * prune_num);
614 prune[prune_num-2] = ce->name;
615 prune[prune_num-1] = NULL;
616 }
617 while ((i+1 < active_nr) &&
618 ce_same_name(ce, active_cache[i+1]))
619 i++;
620 }
621 revs->prune_data = prune;
622}
623
5d6f0935
JH
624int handle_revision_arg(const char *arg, struct rev_info *revs,
625 int flags,
626 int cant_be_filename)
627{
628 char *dotdot;
629 struct object *object;
630 unsigned char sha1[20];
631 int local_flags;
632
633 dotdot = strstr(arg, "..");
634 if (dotdot) {
635 unsigned char from_sha1[20];
636 const char *next = dotdot + 2;
637 const char *this = arg;
638 int symmetric = *next == '.';
639 unsigned int flags_exclude = flags ^ UNINTERESTING;
640
641 *dotdot = 0;
642 next += symmetric;
643
644 if (!*next)
645 next = "HEAD";
646 if (dotdot == arg)
647 this = "HEAD";
648 if (!get_sha1(this, from_sha1) &&
649 !get_sha1(next, sha1)) {
650 struct commit *a, *b;
651 struct commit_list *exclude;
652
653 a = lookup_commit_reference(from_sha1);
654 b = lookup_commit_reference(sha1);
655 if (!a || !b) {
656 die(symmetric ?
657 "Invalid symmetric difference expression %s...%s" :
658 "Invalid revision range %s..%s",
659 arg, next);
660 }
661
662 if (!cant_be_filename) {
663 *dotdot = '.';
664 verify_non_filename(revs->prefix, arg);
665 }
666
667 if (symmetric) {
668 exclude = get_merge_bases(a, b, 1);
669 add_pending_commit_list(revs, exclude,
670 flags_exclude);
671 free_commit_list(exclude);
577ed5c2 672 a->object.flags |= flags | SYMMETRIC_LEFT;
5d6f0935
JH
673 } else
674 a->object.flags |= flags_exclude;
675 b->object.flags |= flags;
676 add_pending_object(revs, &a->object, this);
677 add_pending_object(revs, &b->object, next);
678 return 0;
679 }
680 *dotdot = '.';
681 }
682 dotdot = strstr(arg, "^@");
683 if (dotdot && !dotdot[2]) {
684 *dotdot = 0;
685 if (add_parents_only(revs, arg, flags))
686 return 0;
687 *dotdot = '^';
688 }
62476c8e
JH
689 dotdot = strstr(arg, "^!");
690 if (dotdot && !dotdot[2]) {
691 *dotdot = 0;
692 if (!add_parents_only(revs, arg, flags ^ UNINTERESTING))
693 *dotdot = '^';
694 }
695
5d6f0935
JH
696 local_flags = 0;
697 if (*arg == '^') {
698 local_flags = UNINTERESTING;
699 arg++;
700 }
701 if (get_sha1(arg, sha1))
702 return -1;
703 if (!cant_be_filename)
704 verify_non_filename(revs->prefix, arg);
705 object = get_reference(revs, arg, sha1, flags ^ local_flags);
706 add_pending_object(revs, object, arg);
707 return 0;
708}
709
2d10c555 710static void add_grep(struct rev_info *revs, const char *ptn, enum grep_pat_token what)
bd95fcd3 711{
2d10c555 712 if (!revs->grep_filter) {
bd95fcd3
JH
713 struct grep_opt *opt = xcalloc(1, sizeof(*opt));
714 opt->status_only = 1;
715 opt->pattern_tail = &(opt->pattern_list);
716 opt->regflags = REG_NEWLINE;
2d10c555 717 revs->grep_filter = opt;
bd95fcd3 718 }
2d10c555
JH
719 append_grep_pattern(revs->grep_filter, ptn,
720 "command line", 0, what);
721}
722
723static void add_header_grep(struct rev_info *revs, const char *field, const char *pattern)
724{
725 char *pat;
726 const char *prefix;
727 int patlen, fldlen;
bd95fcd3
JH
728
729 fldlen = strlen(field);
730 patlen = strlen(pattern);
a2ed6ae4
LT
731 pat = xmalloc(patlen + fldlen + 10);
732 prefix = ".*";
733 if (*pattern == '^') {
734 prefix = "";
735 pattern++;
736 }
737 sprintf(pat, "^%s %s%s", field, prefix, pattern);
2d10c555 738 add_grep(revs, pat, GREP_PATTERN_HEAD);
bd95fcd3
JH
739}
740
741static void add_message_grep(struct rev_info *revs, const char *pattern)
742{
2d10c555 743 add_grep(revs, pattern, GREP_PATTERN_BODY);
bd95fcd3
JH
744}
745
106d710b
JH
746static void add_ignore_packed(struct rev_info *revs, const char *name)
747{
748 int num = ++revs->num_ignore_packed;
749
750 revs->ignore_packed = xrealloc(revs->ignore_packed,
751 sizeof(const char **) * (num + 1));
752 revs->ignore_packed[num-1] = name;
753 revs->ignore_packed[num] = NULL;
754}
755
ae563542
LT
756/*
757 * Parse revision information, filling in the "rev_info" structure,
758 * and removing the used arguments from the argument list.
759 *
765ac8ec
LT
760 * Returns the number of arguments left that weren't recognized
761 * (which are also moved to the head of the argument list)
ae563542 762 */
a4a88b2b 763int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def)
ae563542 764{
ae3e5e1e 765 int i, flags, seen_dashdash, show_merge;
765ac8ec 766 const char **unrecognized = argv + 1;
ae563542 767 int left = 1;
70d0afba 768 int all_match = 0;
ae563542 769
ae563542
LT
770 /* First, search for "--" */
771 seen_dashdash = 0;
772 for (i = 1; i < argc; i++) {
773 const char *arg = argv[i];
774 if (strcmp(arg, "--"))
775 continue;
776 argv[i] = NULL;
777 argc = i;
8efdc326 778 revs->prune_data = get_pathspec(revs->prefix, argv + i + 1);
ae563542
LT
779 seen_dashdash = 1;
780 break;
781 }
782
ae3e5e1e 783 flags = show_merge = 0;
ae563542 784 for (i = 1; i < argc; i++) {
ae563542 785 const char *arg = argv[i];
ae563542 786 if (*arg == '-') {
cd2bdc53 787 int opts;
cc44c765 788 if (!prefixcmp(arg, "--max-count=")) {
ae563542
LT
789 revs->max_count = atoi(arg + 12);
790 continue;
791 }
cc44c765 792 if (!prefixcmp(arg, "--skip=")) {
d5db6c9e
JH
793 revs->skip_count = atoi(arg + 7);
794 continue;
795 }
de5f2bf3 796 /* accept -<digit>, like traditional "head" */
64bc6e3d
JH
797 if ((*arg == '-') && isdigit(arg[1])) {
798 revs->max_count = atoi(arg + 1);
799 continue;
800 }
801 if (!strcmp(arg, "-n")) {
802 if (argc <= i + 1)
803 die("-n requires an argument");
804 revs->max_count = atoi(argv[++i]);
805 continue;
806 }
1968d77d 807 if (!prefixcmp(arg, "-n")) {
64bc6e3d
JH
808 revs->max_count = atoi(arg + 2);
809 continue;
810 }
cc44c765 811 if (!prefixcmp(arg, "--max-age=")) {
ae563542 812 revs->max_age = atoi(arg + 10);
ae563542
LT
813 continue;
814 }
cc44c765 815 if (!prefixcmp(arg, "--since=")) {
fd751667 816 revs->max_age = approxidate(arg + 8);
fd751667
JH
817 continue;
818 }
cc44c765 819 if (!prefixcmp(arg, "--after=")) {
fd751667 820 revs->max_age = approxidate(arg + 8);
53069686
JH
821 continue;
822 }
cc44c765 823 if (!prefixcmp(arg, "--min-age=")) {
53069686 824 revs->min_age = atoi(arg + 10);
fd751667
JH
825 continue;
826 }
cc44c765 827 if (!prefixcmp(arg, "--before=")) {
fd751667 828 revs->min_age = approxidate(arg + 9);
fd751667
JH
829 continue;
830 }
cc44c765 831 if (!prefixcmp(arg, "--until=")) {
fd751667 832 revs->min_age = approxidate(arg + 8);
fd751667
JH
833 continue;
834 }
ae563542
LT
835 if (!strcmp(arg, "--all")) {
836 handle_all(revs, flags);
837 continue;
838 }
63049292
JH
839 if (!strcmp(arg, "--reflog")) {
840 handle_reflog(revs, flags);
841 continue;
842 }
084ae0a7
JS
843 if (!strcmp(arg, "-g") ||
844 !strcmp(arg, "--walk-reflogs")) {
8860fd42
JS
845 init_reflog_walk(&revs->reflog_info);
846 continue;
847 }
ae563542
LT
848 if (!strcmp(arg, "--not")) {
849 flags ^= UNINTERESTING;
850 continue;
851 }
852 if (!strcmp(arg, "--default")) {
853 if (++i >= argc)
854 die("bad --default argument");
855 def = argv[i];
856 continue;
857 }
ae3e5e1e
JH
858 if (!strcmp(arg, "--merge")) {
859 show_merge = 1;
860 continue;
861 }
ae563542
LT
862 if (!strcmp(arg, "--topo-order")) {
863 revs->topo_order = 1;
864 continue;
865 }
866 if (!strcmp(arg, "--date-order")) {
867 revs->lifo = 0;
868 revs->topo_order = 1;
869 continue;
870 }
7b0c9966
LT
871 if (!strcmp(arg, "--parents")) {
872 revs->parents = 1;
873 continue;
874 }
ae563542
LT
875 if (!strcmp(arg, "--dense")) {
876 revs->dense = 1;
877 continue;
878 }
879 if (!strcmp(arg, "--sparse")) {
880 revs->dense = 0;
881 continue;
882 }
883 if (!strcmp(arg, "--remove-empty")) {
884 revs->remove_empty_trees = 1;
885 continue;
886 }
5cdeae71 887 if (!strcmp(arg, "--no-merges")) {
765ac8ec
LT
888 revs->no_merges = 1;
889 continue;
890 }
384e99a4
JH
891 if (!strcmp(arg, "--boundary")) {
892 revs->boundary = 1;
893 continue;
894 }
8dce8235
JH
895 if (!strcmp(arg, "--left-right")) {
896 revs->left_right = 1;
74bd9029
JH
897 continue;
898 }
ae563542
LT
899 if (!strcmp(arg, "--objects")) {
900 revs->tag_objects = 1;
901 revs->tree_objects = 1;
902 revs->blob_objects = 1;
903 continue;
904 }
905 if (!strcmp(arg, "--objects-edge")) {
906 revs->tag_objects = 1;
907 revs->tree_objects = 1;
908 revs->blob_objects = 1;
909 revs->edge_hint = 1;
910 continue;
911 }
d9a83684
LT
912 if (!strcmp(arg, "--unpacked")) {
913 revs->unpacked = 1;
106d710b
JH
914 free(revs->ignore_packed);
915 revs->ignore_packed = NULL;
916 revs->num_ignore_packed = 0;
917 continue;
918 }
cc44c765 919 if (!prefixcmp(arg, "--unpacked=")) {
106d710b
JH
920 revs->unpacked = 1;
921 add_ignore_packed(revs, arg+11);
d9a83684
LT
922 continue;
923 }
cd2bdc53
LT
924 if (!strcmp(arg, "-r")) {
925 revs->diff = 1;
926 revs->diffopt.recursive = 1;
927 continue;
928 }
929 if (!strcmp(arg, "-t")) {
930 revs->diff = 1;
931 revs->diffopt.recursive = 1;
932 revs->diffopt.tree_in_recursive = 1;
933 continue;
934 }
935 if (!strcmp(arg, "-m")) {
936 revs->ignore_merges = 0;
937 continue;
938 }
939 if (!strcmp(arg, "-c")) {
940 revs->diff = 1;
0fe7c1de 941 revs->dense_combined_merges = 0;
cd2bdc53
LT
942 revs->combine_merges = 1;
943 continue;
944 }
945 if (!strcmp(arg, "--cc")) {
946 revs->diff = 1;
947 revs->dense_combined_merges = 1;
948 revs->combine_merges = 1;
949 continue;
950 }
951 if (!strcmp(arg, "-v")) {
952 revs->verbose_header = 1;
cd2bdc53
LT
953 continue;
954 }
cc44c765 955 if (!prefixcmp(arg, "--pretty")) {
cd2bdc53 956 revs->verbose_header = 1;
cd2bdc53
LT
957 revs->commit_format = get_commit_format(arg+8);
958 continue;
959 }
960 if (!strcmp(arg, "--root")) {
961 revs->show_root_diff = 1;
962 continue;
963 }
964 if (!strcmp(arg, "--no-commit-id")) {
965 revs->no_commit_id = 1;
966 continue;
967 }
968 if (!strcmp(arg, "--always")) {
969 revs->always_show_header = 1;
970 continue;
971 }
972 if (!strcmp(arg, "--no-abbrev")) {
973 revs->abbrev = 0;
974 continue;
975 }
976 if (!strcmp(arg, "--abbrev")) {
977 revs->abbrev = DEFAULT_ABBREV;
978 continue;
979 }
cc44c765 980 if (!prefixcmp(arg, "--abbrev=")) {
508d9e37
LT
981 revs->abbrev = strtoul(arg + 9, NULL, 10);
982 if (revs->abbrev < MINIMUM_ABBREV)
983 revs->abbrev = MINIMUM_ABBREV;
984 else if (revs->abbrev > 40)
985 revs->abbrev = 40;
986 continue;
987 }
cd2bdc53
LT
988 if (!strcmp(arg, "--abbrev-commit")) {
989 revs->abbrev_commit = 1;
990 continue;
991 }
992 if (!strcmp(arg, "--full-diff")) {
993 revs->diff = 1;
994 revs->full_diff = 1;
995 continue;
996 }
9202434c
LT
997 if (!strcmp(arg, "--full-history")) {
998 revs->simplify_history = 0;
999 continue;
1000 }
3dfb9278
JF
1001 if (!strcmp(arg, "--relative-date")) {
1002 revs->relative_date = 1;
1003 continue;
1004 }
2d10c555
JH
1005
1006 /*
1007 * Grepping the commit log
1008 */
cc44c765 1009 if (!prefixcmp(arg, "--author=")) {
bd95fcd3
JH
1010 add_header_grep(revs, "author", arg+9);
1011 continue;
1012 }
cc44c765 1013 if (!prefixcmp(arg, "--committer=")) {
bd95fcd3
JH
1014 add_header_grep(revs, "committer", arg+12);
1015 continue;
1016 }
cc44c765 1017 if (!prefixcmp(arg, "--grep=")) {
bd95fcd3
JH
1018 add_message_grep(revs, arg+7);
1019 continue;
1020 }
70d0afba
JH
1021 if (!strcmp(arg, "--all-match")) {
1022 all_match = 1;
1023 continue;
1024 }
cc44c765 1025 if (!prefixcmp(arg, "--encoding=")) {
7cbcf4d5
JH
1026 arg += 11;
1027 if (strcmp(arg, "none"))
1028 git_log_output_encoding = strdup(arg);
1029 else
1030 git_log_output_encoding = "";
1031 continue;
1032 }
9c5e66e9
JS
1033 if (!strcmp(arg, "--reverse")) {
1034 revs->reverse ^= 1;
1035 continue;
1036 }
2d10c555 1037
cd2bdc53
LT
1038 opts = diff_opt_parse(&revs->diffopt, argv+i, argc-i);
1039 if (opts > 0) {
1040 revs->diff = 1;
1041 i += opts - 1;
1042 continue;
1043 }
ae563542
LT
1044 *unrecognized++ = arg;
1045 left++;
1046 continue;
1047 }
ae563542 1048
5d6f0935
JH
1049 if (handle_revision_arg(arg, revs, flags, seen_dashdash)) {
1050 int j;
1051 if (seen_dashdash || *arg == '^')
ae563542
LT
1052 die("bad revision '%s'", arg);
1053
ea92f41f
JH
1054 /* If we didn't have a "--":
1055 * (1) all filenames must exist;
1056 * (2) all rev-args must not be interpretable
1057 * as a valid filename.
1058 * but the latter we have checked in the main loop.
1059 */
e23d0b4a
LT
1060 for (j = i; j < argc; j++)
1061 verify_filename(revs->prefix, argv[j]);
1062
5d6f0935
JH
1063 revs->prune_data = get_pathspec(revs->prefix,
1064 argv + i);
ae563542
LT
1065 break;
1066 }
ae563542 1067 }
5d6f0935 1068
ae3e5e1e
JH
1069 if (show_merge)
1070 prepare_show_merge(revs);
1f1e895f 1071 if (def && !revs->pending.nr) {
ae563542 1072 unsigned char sha1[20];
cd2bdc53 1073 struct object *object;
31fff305 1074 if (get_sha1(def, sha1))
ae563542 1075 die("bad default revision '%s'", def);
cd2bdc53
LT
1076 object = get_reference(revs, def, sha1, 0);
1077 add_pending_object(revs, object, def);
ae563542 1078 }
8efdc326 1079
9dad9d2e 1080 if (revs->topo_order)
53069686
JH
1081 revs->limited = 1;
1082
8efdc326 1083 if (revs->prune_data) {
cd2bdc53 1084 diff_tree_setup_paths(revs->prune_data, &revs->pruning);
8efdc326 1085 revs->prune_fn = try_to_simplify_commit;
cd2bdc53
LT
1086 if (!revs->full_diff)
1087 diff_tree_setup_paths(revs->prune_data, &revs->diffopt);
8efdc326 1088 }
cd2bdc53
LT
1089 if (revs->combine_merges) {
1090 revs->ignore_merges = 0;
0e677e1a 1091 if (revs->dense_combined_merges && !revs->diffopt.output_format)
cd2bdc53
LT
1092 revs->diffopt.output_format = DIFF_FORMAT_PATCH;
1093 }
cd2bdc53 1094 revs->diffopt.abbrev = revs->abbrev;
72ee96c0
JH
1095 if (diff_setup_done(&revs->diffopt) < 0)
1096 die("diff_setup_done failed");
8efdc326 1097
70d0afba
JH
1098 if (revs->grep_filter) {
1099 revs->grep_filter->all_match = all_match;
2d10c555 1100 compile_grep_patterns(revs->grep_filter);
70d0afba 1101 }
bd95fcd3 1102
ae563542
LT
1103 return left;
1104}
a4a88b2b
LT
1105
1106void prepare_revision_walk(struct rev_info *revs)
1107{
1f1e895f 1108 int nr = revs->pending.nr;
94d23673 1109 struct object_array_entry *e, *list;
cd2bdc53 1110
94d23673 1111 e = list = revs->pending.objects;
1f1e895f
LT
1112 revs->pending.nr = 0;
1113 revs->pending.alloc = 0;
1114 revs->pending.objects = NULL;
1115 while (--nr >= 0) {
94d23673 1116 struct commit *commit = handle_commit(revs, e->item, e->name);
cd2bdc53
LT
1117 if (commit) {
1118 if (!(commit->object.flags & SEEN)) {
1119 commit->object.flags |= SEEN;
1120 insert_by_date(commit, &revs->commits);
1121 }
1122 }
94d23673 1123 e++;
cd2bdc53 1124 }
94d23673 1125 free(list);
cd2bdc53 1126
ba1d4505
LT
1127 if (revs->no_walk)
1128 return;
a4a88b2b
LT
1129 if (revs->limited)
1130 limit_list(revs);
1131 if (revs->topo_order)
8efdc326
FK
1132 sort_in_topological_order_fn(&revs->commits, revs->lifo,
1133 revs->topo_setter,
1134 revs->topo_getter);
a4a88b2b
LT
1135}
1136
3381c790 1137static int rewrite_one(struct rev_info *revs, struct commit **pp)
765ac8ec
LT
1138{
1139 for (;;) {
1140 struct commit *p = *pp;
3381c790
LT
1141 if (!revs->limited)
1142 add_parents_to_list(revs, p, &revs->commits);
6631c736
LT
1143 if (p->parents && p->parents->next)
1144 return 0;
765ac8ec
LT
1145 if (p->object.flags & (TREECHANGE | UNINTERESTING))
1146 return 0;
1147 if (!p->parents)
1148 return -1;
1149 *pp = p->parents->item;
1150 }
1151}
1152
3381c790 1153static void rewrite_parents(struct rev_info *revs, struct commit *commit)
765ac8ec
LT
1154{
1155 struct commit_list **pp = &commit->parents;
1156 while (*pp) {
1157 struct commit_list *parent = *pp;
3381c790 1158 if (rewrite_one(revs, &parent->item) < 0) {
765ac8ec
LT
1159 *pp = parent->next;
1160 continue;
1161 }
1162 pp = &parent->next;
1163 }
1164}
1165
8ecae9b0
JH
1166static int commit_match(struct commit *commit, struct rev_info *opt)
1167{
2d10c555 1168 if (!opt->grep_filter)
8ecae9b0 1169 return 1;
2d10c555
JH
1170 return grep_buffer(opt->grep_filter,
1171 NULL, /* we say nothing, not even filename */
1172 commit->buffer, strlen(commit->buffer));
8ecae9b0
JH
1173}
1174
d5db6c9e 1175static struct commit *get_revision_1(struct rev_info *revs)
a4a88b2b 1176{
d5db6c9e 1177 if (!revs->commits)
a4a88b2b 1178 return NULL;
a4a88b2b 1179
765ac8ec 1180 do {
cb115748
LT
1181 struct commit_list *entry = revs->commits;
1182 struct commit *commit = entry->item;
ea5ed3ab 1183
cb115748
LT
1184 revs->commits = entry->next;
1185 free(entry);
2a0925be 1186
8860fd42
JS
1187 if (revs->reflog_info)
1188 fake_reflog_parent(revs->reflog_info, commit);
1189
2a0925be
LT
1190 /*
1191 * If we haven't done the list limiting, we need to look at
be7db6e5
LT
1192 * the parents here. We also need to do the date-based limiting
1193 * that we'd otherwise have done in limit_list().
2a0925be 1194 */
be7db6e5 1195 if (!revs->limited) {
744f4985 1196 if (revs->max_age != -1 &&
86ab4906
JH
1197 (commit->date < revs->max_age))
1198 continue;
1199 add_parents_to_list(revs, commit, &revs->commits);
be7db6e5 1200 }
384e99a4 1201 if (commit->object.flags & SHOWN)
2a0925be 1202 continue;
1b65a5aa 1203
744f4985
JH
1204 if (revs->unpacked && has_sha1_pack(commit->object.sha1,
1205 revs->ignore_packed))
1206 continue;
1207
1b65a5aa 1208 if (commit->object.flags & UNINTERESTING)
2a0925be 1209 continue;
765ac8ec 1210 if (revs->min_age != -1 && (commit->date > revs->min_age))
2a0925be 1211 continue;
384e99a4
JH
1212 if (revs->no_merges &&
1213 commit->parents && commit->parents->next)
2a0925be 1214 continue;
8ecae9b0
JH
1215 if (!commit_match(commit, revs))
1216 continue;
8efdc326 1217 if (revs->prune_fn && revs->dense) {
6631c736
LT
1218 /* Commit without changes? */
1219 if (!(commit->object.flags & TREECHANGE)) {
1220 /* drop merges unless we want parenthood */
1221 if (!revs->parents)
1222 continue;
1223 /* non-merge - always ignore it */
02d3dca3 1224 if (!commit->parents || !commit->parents->next)
6631c736
LT
1225 continue;
1226 }
2a0925be 1227 if (revs->parents)
3381c790 1228 rewrite_parents(revs, commit);
384e99a4 1229 }
765ac8ec
LT
1230 commit->object.flags |= SHOWN;
1231 return commit;
1232 } while (revs->commits);
1233 return NULL;
1234}
d5db6c9e 1235
86ab4906
JH
1236static void gc_boundary(struct object_array *array)
1237{
1238 unsigned nr = array->nr;
1239 unsigned alloc = array->alloc;
1240 struct object_array_entry *objects = array->objects;
1241
1242 if (alloc <= nr) {
1243 unsigned i, j;
1244 for (i = j = 0; i < nr; i++) {
1245 if (objects[i].item->flags & SHOWN)
1246 continue;
1247 if (i != j)
1248 objects[j] = objects[i];
1249 j++;
1250 }
1251 for (i = j; j < nr; j++)
1252 objects[i].item = NULL;
1253 array->nr = j;
1254 }
1255}
1256
d5db6c9e
JH
1257struct commit *get_revision(struct rev_info *revs)
1258{
1259 struct commit *c = NULL;
86ab4906
JH
1260 struct commit_list *l;
1261
1262 if (revs->boundary == 2) {
1263 unsigned i;
1264 struct object_array *array = &revs->boundary_commits;
1265 struct object_array_entry *objects = array->objects;
1266 for (i = 0; i < array->nr; i++) {
1267 c = (struct commit *)(objects[i].item);
1268 if (!c)
1269 continue;
1270 if (!(c->object.flags & CHILD_SHOWN))
1271 continue;
1272 if (!(c->object.flags & SHOWN))
1273 break;
9c5e66e9 1274 }
86ab4906 1275 if (array->nr <= i)
9c5e66e9 1276 return NULL;
86ab4906
JH
1277
1278 c->object.flags |= SHOWN | BOUNDARY;
9c5e66e9
JS
1279 return c;
1280 }
1281
86ab4906
JH
1282 if (revs->reverse) {
1283 l = NULL;
1284 while ((c = get_revision_1(revs)))
1285 commit_list_insert(c, &l);
1286 revs->commits = l;
1287 revs->reverse = 0;
2b064697 1288 c = NULL;
d5db6c9e
JH
1289 }
1290
86ab4906
JH
1291 /*
1292 * Now pick up what they want to give us
1293 */
2b064697
JH
1294 if (!(c = get_revision_1(revs)))
1295 return NULL;
86ab4906
JH
1296 while (0 < revs->skip_count) {
1297 revs->skip_count--;
1298 c = get_revision_1(revs);
1299 if (!c)
1300 break;
2b064697
JH
1301 /* Although we grabbed it, it is not shown. */
1302 c->object.flags &= ~SHOWN;
86ab4906
JH
1303 }
1304
1305 /*
1306 * Check the max_count.
1307 */
d5db6c9e
JH
1308 switch (revs->max_count) {
1309 case -1:
1310 break;
1311 case 0:
2b064697
JH
1312 /* Although we grabbed it, it is not shown. */
1313 if (c)
1314 c->object.flags &= ~SHOWN;
86ab4906
JH
1315 c = NULL;
1316 break;
d5db6c9e
JH
1317 default:
1318 revs->max_count--;
1319 }
86ab4906
JH
1320
1321 if (!revs->boundary)
d5db6c9e 1322 return c;
86ab4906
JH
1323
1324 if (!c) {
1325 /*
1326 * get_revision_1() runs out the commits, and
1327 * we are done computing the boundaries.
1328 * switch to boundary commits output mode.
1329 */
1330 revs->boundary = 2;
1331 return get_revision(revs);
1332 }
1333
1334 /*
1335 * boundary commits are the commits that are parents of the
1336 * ones we got from get_revision_1() but they themselves are
1337 * not returned from get_revision_1(). Before returning
1338 * 'c', we need to mark its parents that they could be boundaries.
1339 */
1340
1341 for (l = c->parents; l; l = l->next) {
1342 struct object *p;
1343 p = &(l->item->object);
1344 if (p->flags & CHILD_SHOWN)
1345 continue;
1346 p->flags |= CHILD_SHOWN;
1347 gc_boundary(&revs->boundary_commits);
1348 add_object_array(p, NULL, &revs->boundary_commits);
1349 }
1350
1351 return c;
d5db6c9e 1352}