@matheusbsbs / matheus-bagliano / commits / 765ac8ec46
Fork 0

Rip out merge-order and make "git log <paths>..." work again.

Well, assuming breaking --merge-order is fine, here's a patch (on top of the other ones) that makes git log <filename> actually work, as far as I can tell. I didn't add the logic for --before/--after flags, but that should be pretty trivial, and is independent of this anyway. Signed-off-by: Junio C Hamano <junkio@cox.net>

Linus Torvalds committed Feb 28, 2006 at 15:07 UTC 765ac8ec469f110e88376e4fac05d0ed475bcb28
11 files changed +82 -1299
Documentation/git-rev-list.txt
+1 -48
@@ -16,7 +16,7 @@ SYNOPSIS
16 [ \--no-merges ]
17 [ \--remove-empty ]
18 [ \--all ]
19 - [ [ \--merge-order [ \--show-breaks ] ] | [ \--topo-order ] ]
19 + [ \--topo-order ]
20 [ \--parents ]
21 [ \--objects [ \--unpacked ] ]
22 [ \--pretty | \--header ]
@@ -94,57 +94,10 @@ OPTIONS
94 topological order (i.e. descendant commits are shown
95 before their parents).
96
97 ---merge-order::
98 - When specified the commit history is decomposed into a unique
99 - sequence of minimal, non-linear epochs and maximal, linear epochs.
100 - Non-linear epochs are then linearised by sorting them into merge
101 - order, which is described below.
102 -+
103 -Maximal, linear epochs correspond to periods of sequential development.
104 -Minimal, non-linear epochs correspond to periods of divergent development
105 -followed by a converging merge. The theory of epochs is described in more
106 -detail at
107 -link:http://blackcubes.dyndns.org/epoch/[http://blackcubes.dyndns.org/epoch/].
108 -+
109 -The merge order for a non-linear epoch is defined as a linearisation for which
110 -the following invariants are true:
111 -+
112 - 1. if a commit P is reachable from commit N, commit P sorts after commit N
113 - in the linearised list.
114 - 2. if Pi and Pj are any two parents of a merge M (with i < j), then any
115 - commit N, such that N is reachable from Pj but not reachable from Pi,
116 - sorts before all commits reachable from Pi.
117 -+
118 -Invariant 1 states that later commits appear before earlier commits they are
119 -derived from.
120 -+
121 -Invariant 2 states that commits unique to "later" parents in a merge, appear
122 -before all commits from "earlier" parents of a merge.
123 -
124 ---show-breaks::
125 - Each item of the list is output with a 2-character prefix consisting
126 - of one of: (|), (^), (=) followed by a space.
127 -+
128 -Commits marked with (=) represent the boundaries of minimal, non-linear epochs
129 -and correspond either to the start of a period of divergent development or to
130 -the end of such a period.
131 -+
132 -Commits marked with (|) are direct parents of commits immediately preceding
133 -the marked commit in the list.
134 -+
135 -Commits marked with (^) are not parents of the immediately preceding commit.
136 -These "breaks" represent necessary discontinuities implied by trying to
137 -represent an arbitrary DAG in a linear form.
138 -+
139 -`--show-breaks` is only valid if `--merge-order` is also specified.
140 -
141 -
97 Author
98 ------
99 Written by Linus Torvalds <torvalds@osdl.org>
100
146 -Original *--merge-order* logic by Jon Seymour <jon.seymour@gmail.com>
147 -
101 Documentation
102 --------------
103 Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
INSTALL
+1 -3
@@ -40,9 +40,7 @@ Issues of note:
40
41 If you don't have openssl, you can use one of the SHA1 libraries
42 that come with git (git includes the one from Mozilla, and has
43 - its own PowerPC-optimized one too - see the Makefile), and you
44 - can avoid the bignum support by excising git-rev-list support
45 - for "--merge-order" (by hand).
43 + its own PowerPC and ARM optimized ones too - see the Makefile).
44
45 - "libcurl" and "curl" executable. git-http-fetch and
46 git-fetch use them. If you do not use http
Makefile
+3 -4
@@ -6,8 +6,8 @@ all:
6 # on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default
7 # choice) has very fast version optimized for i586.
8 #
9 -# Define NO_OPENSSL environment variable if you do not have OpenSSL. You will
10 -# miss out git-rev-list --merge-order. This also implies MOZILLA_SHA1.
9 +# Define NO_OPENSSL environment variable if you do not have OpenSSL.
10 +# This also implies MOZILLA_SHA1.
11 #
12 # Define NO_CURL if you do not have curl installed. git-http-pull and
13 # git-http-push are not built, and you cannot use http:// and https://
@@ -191,7 +191,7 @@ LIB_FILE=libgit.a
191
192 LIB_H = \
193 blob.h cache.h commit.h count-delta.h csum-file.h delta.h \
194 - diff.h epoch.h object.h pack.h pkt-line.h quote.h refs.h \
194 + diff.h object.h pack.h pkt-line.h quote.h refs.h \
195 run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h
196
197 DIFF_OBJS = \
@@ -324,7 +324,6 @@ ifndef NO_CURL
324 endif
325
326 ifndef NO_OPENSSL
327 - LIB_OBJS += epoch.o
327 OPENSSL_LIBSSL = -lssl
328 ifdef OPENSSLDIR
329 # Again this may be problematic -- gcc does not always want -R.
epoch.c deleted
-640
@@ -1,640 +0,0 @@
1 -/*
2 - * Copyright (c) 2005, Jon Seymour
3 - *
4 - * For more information about epoch theory on which this module is based,
5 - * refer to http://blackcubes.dyndns.org/epoch/. That web page defines
6 - * terms such as "epoch" and "minimal, non-linear epoch" and provides rationales
7 - * for some of the algorithms used here.
8 - *
9 - */
10 -#include <stdlib.h>
11 -
12 -/* Provides arbitrary precision integers required to accurately represent
13 - * fractional mass: */
14 -#include <openssl/bn.h>
15 -
16 -#include "cache.h"
17 -#include "commit.h"
18 -#include "revision.h"
19 -#include "epoch.h"
20 -
21 -struct fraction {
22 - BIGNUM numerator;
23 - BIGNUM denominator;
24 -};
25 -
26 -#define HAS_EXACTLY_ONE_PARENT(n) ((n)->parents && !(n)->parents->next)
27 -
28 -static BN_CTX *context = NULL;
29 -static struct fraction *one = NULL;
30 -static struct fraction *zero = NULL;
31 -
32 -static BN_CTX *get_BN_CTX(void)
33 -{
34 - if (!context) {
35 - context = BN_CTX_new();
36 - }
37 - return context;
38 -}
39 -
40 -static struct fraction *new_zero(void)
41 -{
42 - struct fraction *result = xmalloc(sizeof(*result));
43 - BN_init(&result->numerator);
44 - BN_init(&result->denominator);
45 - BN_zero(&result->numerator);
46 - BN_one(&result->denominator);
47 - return result;
48 -}
49 -
50 -static void clear_fraction(struct fraction *fraction)
51 -{
52 - BN_clear(&fraction->numerator);
53 - BN_clear(&fraction->denominator);
54 -}
55 -
56 -static struct fraction *divide(struct fraction *result, struct fraction *fraction, int divisor)
57 -{
58 - BIGNUM bn_divisor;
59 -
60 - BN_init(&bn_divisor);
61 - BN_set_word(&bn_divisor, divisor);
62 -
63 - BN_copy(&result->numerator, &fraction->numerator);
64 - BN_mul(&result->denominator, &fraction->denominator, &bn_divisor, get_BN_CTX());
65 -
66 - BN_clear(&bn_divisor);
67 - return result;
68 -}
69 -
70 -static struct fraction *init_fraction(struct fraction *fraction)
71 -{
72 - BN_init(&fraction->numerator);
73 - BN_init(&fraction->denominator);
74 - BN_zero(&fraction->numerator);
75 - BN_one(&fraction->denominator);
76 - return fraction;
77 -}
78 -
79 -static struct fraction *get_one(void)
80 -{
81 - if (!one) {
82 - one = new_zero();
83 - BN_one(&one->numerator);
84 - }
85 - return one;
86 -}
87 -
88 -static struct fraction *get_zero(void)
89 -{
90 - if (!zero) {
91 - zero = new_zero();
92 - }
93 - return zero;
94 -}
95 -
96 -static struct fraction *copy(struct fraction *to, struct fraction *from)
97 -{
98 - BN_copy(&to->numerator, &from->numerator);
99 - BN_copy(&to->denominator, &from->denominator);
100 - return to;
101 -}
102 -
103 -static struct fraction *add(struct fraction *result, struct fraction *left, struct fraction *right)
104 -{
105 - BIGNUM a, b, gcd;
106 -
107 - BN_init(&a);
108 - BN_init(&b);
109 - BN_init(&gcd);
110 -
111 - BN_mul(&a, &left->numerator, &right->denominator, get_BN_CTX());
112 - BN_mul(&b, &left->denominator, &right->numerator, get_BN_CTX());
113 - BN_mul(&result->denominator, &left->denominator, &right->denominator, get_BN_CTX());
114 - BN_add(&result->numerator, &a, &b);
115 -
116 - BN_gcd(&gcd, &result->denominator, &result->numerator, get_BN_CTX());
117 - BN_div(&result->denominator, NULL, &result->denominator, &gcd, get_BN_CTX());
118 - BN_div(&result->numerator, NULL, &result->numerator, &gcd, get_BN_CTX());
119 -
120 - BN_clear(&a);
121 - BN_clear(&b);
122 - BN_clear(&gcd);
123 -
124 - return result;
125 -}
126 -
127 -static int compare(struct fraction *left, struct fraction *right)
128 -{
129 - BIGNUM a, b;
130 - int result;
131 -
132 - BN_init(&a);
133 - BN_init(&b);
134 -
135 - BN_mul(&a, &left->numerator, &right->denominator, get_BN_CTX());
136 - BN_mul(&b, &left->denominator, &right->numerator, get_BN_CTX());
137 -
138 - result = BN_cmp(&a, &b);
139 -
140 - BN_clear(&a);
141 - BN_clear(&b);
142 -
143 - return result;
144 -}
145 -
146 -struct mass_counter {
147 - struct fraction seen;
148 - struct fraction pending;
149 -};
150 -
151 -static struct mass_counter *new_mass_counter(struct commit *commit, struct fraction *pending)
152 -{
153 - struct mass_counter *mass_counter = xmalloc(sizeof(*mass_counter));
154 - memset(mass_counter, 0, sizeof(*mass_counter));
155 -
156 - init_fraction(&mass_counter->seen);
157 - init_fraction(&mass_counter->pending);
158 -
159 - copy(&mass_counter->pending, pending);
160 - copy(&mass_counter->seen, get_zero());
161 -
162 - if (commit->object.util) {
163 - die("multiple attempts to initialize mass counter for %s",
164 - sha1_to_hex(commit->object.sha1));
165 - }
166 -
167 - commit->object.util = mass_counter;
168 -
169 - return mass_counter;
170 -}
171 -
172 -static void free_mass_counter(struct mass_counter *counter)
173 -{
174 - clear_fraction(&counter->seen);
175 - clear_fraction(&counter->pending);
176 - free(counter);
177 -}
178 -
179 -/*
180 - * Finds the base commit of a list of commits.
181 - *
182 - * One property of the commit being searched for is that every commit reachable
183 - * from the base commit is reachable from the commits in the starting list only
184 - * via paths that include the base commit.
185 - *
186 - * This algorithm uses a conservation of mass approach to find the base commit.
187 - *
188 - * We start by injecting one unit of mass into the graph at each
189 - * of the commits in the starting list. Injecting mass into a commit
190 - * is achieved by adding to its pending mass counter and, if it is not already
191 - * enqueued, enqueuing the commit in a list of pending commits, in latest
192 - * commit date first order.
193 - *
194 - * The algorithm then proceeds to visit each commit in the pending queue.
195 - * Upon each visit, the pending mass is added to the mass already seen for that
196 - * commit and then divided into N equal portions, where N is the number of
197 - * parents of the commit being visited. The divided portions are then injected
198 - * into each of the parents.
199 - *
200 - * The algorithm continues until we discover a commit which has seen all the
201 - * mass originally injected or until we run out of things to do.
202 - *
203 - * If we find a commit that has seen all the original mass, we have found
204 - * the common base of all the commits in the starting list.
205 - *
206 - * The algorithm does _not_ depend on accurate timestamps for correct operation.
207 - * However, reasonably sane (e.g. non-random) timestamps are required in order
208 - * to prevent an exponential performance characteristic. The occasional
209 - * timestamp inaccuracy will not dramatically affect performance but may
210 - * result in more nodes being processed than strictly necessary.
211 - *
212 - * This procedure sets *boundary to the address of the base commit. It returns
213 - * non-zero if, and only if, there was a problem parsing one of the
214 - * commits discovered during the traversal.
215 - */
216 -static int find_base_for_list(struct commit_list *list, struct commit **boundary)
217 -{
218 - int ret = 0;
219 - struct commit_list *cleaner = NULL;
220 - struct commit_list *pending = NULL;
221 - struct fraction injected;
222 - init_fraction(&injected);
223 - *boundary = NULL;
224 -
225 - for (; list; list = list->next) {
226 - struct commit *item = list->item;
227 -
228 - if (!item->object.util) {
229 - new_mass_counter(list->item, get_one());
230 - add(&injected, &injected, get_one());
231 -
232 - commit_list_insert(list->item, &cleaner);
233 - commit_list_insert(list->item, &pending);
234 - }
235 - }
236 -
237 - while (!*boundary && pending && !ret) {
238 - struct commit *latest = pop_commit(&pending);
239 - struct mass_counter *latest_node = (struct mass_counter *) latest->object.util;
240 - int num_parents;
241 -
242 - if ((ret = parse_commit(latest)))
243 - continue;
244 - add(&latest_node->seen, &latest_node->seen, &latest_node->pending);
245 -
246 - num_parents = count_parents(latest);
247 - if (num_parents) {
248 - struct fraction distribution;
249 - struct commit_list *parents;
250 -
251 - divide(init_fraction(&distribution), &latest_node->pending, num_parents);
252 -
253 - for (parents = latest->parents; parents; parents = parents->next) {
254 - struct commit *parent = parents->item;
255 - struct mass_counter *parent_node = (struct mass_counter *) parent->object.util;
256 -
257 - if (!parent_node) {
258 - parent_node = new_mass_counter(parent, &distribution);
259 - insert_by_date(parent, &pending);
260 - commit_list_insert(parent, &cleaner);
261 - } else {
262 - if (!compare(&parent_node->pending, get_zero()))
263 - insert_by_date(parent, &pending);
264 - add(&parent_node->pending, &parent_node->pending, &distribution);
265 - }
266 - }
267 -
268 - clear_fraction(&distribution);
269 - }
270 -
271 - if (!compare(&latest_node->seen, &injected))
272 - *boundary = latest;
273 - copy(&latest_node->pending, get_zero());
274 - }
275 -
276 - while (cleaner) {
277 - struct commit *next = pop_commit(&cleaner);
278 - free_mass_counter((struct mass_counter *) next->object.util);
279 - next->object.util = NULL;
280 - }
281 -
282 - if (pending)
283 - free_commit_list(pending);
284 -
285 - clear_fraction(&injected);
286 - return ret;
287 -}
288 -
289 -
290 -/*
291 - * Finds the base of an minimal, non-linear epoch, headed at head, by
292 - * applying the find_base_for_list to a list consisting of the parents
293 - */
294 -static int find_base(struct commit *head, struct commit **boundary)
295 -{
296 - int ret = 0;
297 - struct commit_list *pending = NULL;
298 - struct commit_list *next;
299 -
300 - for (next = head->parents; next; next = next->next) {
301 - commit_list_insert(next->item, &pending);
302 - }
303 - ret = find_base_for_list(pending, boundary);
304 - free_commit_list(pending);
305 -
306 - return ret;
307 -}
308 -
309 -/*
310 - * This procedure traverses to the boundary of the first epoch in the epoch
311 - * sequence of the epoch headed at head_of_epoch. This is either the end of
312 - * the maximal linear epoch or the base of a minimal non-linear epoch.
313 - *
314 - * The queue of pending nodes is sorted in reverse date order and each node
315 - * is currently in the queue at most once.
316 - */
317 -static int find_next_epoch_boundary(struct commit *head_of_epoch, struct commit **boundary)
318 -{
319 - int ret;
320 - struct commit *item = head_of_epoch;
321 -
322 - ret = parse_commit(item);
323 - if (ret)
324 - return ret;
325 -
326 - if (HAS_EXACTLY_ONE_PARENT(item)) {
327 - /*
328 - * We are at the start of a maximimal linear epoch.
329 - * Traverse to the end.
330 - */
331 - while (HAS_EXACTLY_ONE_PARENT(item) && !ret) {
332 - item = item->parents->item;
333 - ret = parse_commit(item);
334 - }
335 - *boundary = item;
336 -
337 - } else {
338 - /*
339 - * Otherwise, we are at the start of a minimal, non-linear
340 - * epoch - find the common base of all parents.
341 - */
342 - ret = find_base(item, boundary);
343 - }
344 -
345 - return ret;
346 -}
347 -
348 -/*
349 - * Returns non-zero if parent is known to be a parent of child.
350 - */
351 -static int is_parent_of(struct commit *parent, struct commit *child)
352 -{
353 - struct commit_list *parents;
354 - for (parents = child->parents; parents; parents = parents->next) {
355 - if (!memcmp(parent->object.sha1, parents->item->object.sha1,
356 - sizeof(parents->item->object.sha1)))
357 - return 1;
358 - }
359 - return 0;
360 -}
361 -
362 -/*
363 - * Pushes an item onto the merge order stack. If the top of the stack is
364 - * marked as being a possible "break", we check to see whether it actually
365 - * is a break.
366 - */
367 -static void push_onto_merge_order_stack(struct commit_list **stack, struct commit *item)
368 -{
369 - struct commit_list *top = *stack;
370 - if (top && (top->item->object.flags & DISCONTINUITY)) {
371 - if (is_parent_of(top->item, item)) {
372 - top->item->object.flags &= ~DISCONTINUITY;
373 - }
374 - }
375 - commit_list_insert(item, stack);
376 -}
377 -
378 -/*
379 - * Marks all interesting, visited commits reachable from this commit
380 - * as uninteresting. We stop recursing when we reach the epoch boundary,
381 - * an unvisited node or a node that has already been marking uninteresting.
382 - *
383 - * This doesn't actually mark all ancestors between the start node and the
384 - * epoch boundary uninteresting, but does ensure that they will eventually
385 - * be marked uninteresting when the main sort_first_epoch() traversal
386 - * eventually reaches them.
387 - */
388 -static void mark_ancestors_uninteresting(struct commit *commit)
389 -{
390 - unsigned int flags = commit->object.flags;
391 - int visited = flags & VISITED;
392 - int boundary = flags & BOUNDARY;
393 - int uninteresting = flags & UNINTERESTING;
394 - struct commit_list *next;
395 -
396 - commit->object.flags |= UNINTERESTING;
397 -
398 - /*
399 - * We only need to recurse if
400 - * we are not on the boundary and
401 - * we have not already been marked uninteresting and
402 - * we have already been visited.
403 - *
404 - * The main sort_first_epoch traverse will mark unreachable
405 - * all uninteresting, unvisited parents as they are visited
406 - * so there is no need to duplicate that traversal here.
407 - *
408 - * Similarly, if we are already marked uninteresting
409 - * then either all ancestors have already been marked
410 - * uninteresting or will be once the sort_first_epoch
411 - * traverse reaches them.
412 - */
413 -
414 - if (uninteresting || boundary || !visited)
415 - return;
416 -
417 - for (next = commit->parents; next; next = next->next)
418 - mark_ancestors_uninteresting(next->item);
419 -}
420 -
421 -/*
422 - * Sorts the nodes of the first epoch of the epoch sequence of the epoch headed at head
423 - * into merge order.
424 - */
425 -static void sort_first_epoch(struct commit *head, struct commit_list **stack)
426 -{
427 - struct commit_list *parents;
428 -
429 - head->object.flags |= VISITED;
430 -
431 - /*
432 - * TODO: By sorting the parents in a different order, we can alter the
433 - * merge order to show contemporaneous changes in parallel branches
434 - * occurring after "local" changes. This is useful for a developer
435 - * when a developer wants to see all changes that were incorporated
436 - * into the same merge as her own changes occur after her own
437 - * changes.
438 - */
439 -
440 - for (parents = head->parents; parents; parents = parents->next) {
441 - struct commit *parent = parents->item;
442 -
443 - if (head->object.flags & UNINTERESTING) {
444 - /*
445 - * Propagates the uninteresting bit to all parents.
446 - * if we have already visited this parent, then
447 - * the uninteresting bit will be propagated to each
448 - * reachable commit that is still not marked
449 - * uninteresting and won't otherwise be reached.
450 - */
451 - mark_ancestors_uninteresting(parent);
452 - }
453 -
454 - if (!(parent->object.flags & VISITED)) {
455 - if (parent->object.flags & BOUNDARY) {
456 - if (*stack) {
457 - die("something else is on the stack - %s",
458 - sha1_to_hex((*stack)->item->object.sha1));
459 - }
460 - push_onto_merge_order_stack(stack, parent);
461 - parent->object.flags |= VISITED;
462 -
463 - } else {
464 - sort_first_epoch(parent, stack);
465 - if (parents) {
466 - /*
467 - * This indicates a possible
468 - * discontinuity it may not be be
469 - * actual discontinuity if the head
470 - * of parent N happens to be the tail
471 - * of parent N+1.
472 - *
473 - * The next push onto the stack will
474 - * resolve the question.
475 - */
476 - (*stack)->item->object.flags |= DISCONTINUITY;
477 - }
478 - }
479 - }
480 - }
481 -
482 - push_onto_merge_order_stack(stack, head);
483 -}
484 -
485 -/*
486 - * Emit the contents of the stack.
487 - *
488 - * The stack is freed and replaced by NULL.
489 - *
490 - * Sets the return value to STOP if no further output should be generated.
491 - */
492 -static int emit_stack(struct commit_list **stack, emitter_func emitter, int include_last)
493 -{
494 - unsigned int seen = 0;
495 - int action = CONTINUE;
496 -
497 - while (*stack && (action != STOP)) {
498 - struct commit *next = pop_commit(stack);
499 - seen |= next->object.flags;
500 - if (*stack || include_last) {
501 - if (!*stack)
502 - next->object.flags |= BOUNDARY;
503 - action = emitter(next);
504 - }
505 - }
506 -
507 - if (*stack) {
508 - free_commit_list(*stack);
509 - *stack = NULL;
510 - }
511 -
512 - return (action == STOP || (seen & UNINTERESTING)) ? STOP : CONTINUE;
513 -}
514 -
515 -/*
516 - * Sorts an arbitrary epoch into merge order by sorting each epoch
517 - * of its epoch sequence into order.
518 - *
519 - * Note: this algorithm currently leaves traces of its execution in the
520 - * object flags of nodes it discovers. This should probably be fixed.
521 - */
522 -static int sort_in_merge_order(struct commit *head_of_epoch, emitter_func emitter)
523 -{
524 - struct commit *next = head_of_epoch;
525 - int ret = 0;
526 - int action = CONTINUE;
527 -
528 - ret = parse_commit(head_of_epoch);
529 -
530 - next->object.flags |= BOUNDARY;
531 -
532 - while (next && next->parents && !ret && (action != STOP)) {
533 - struct commit *base = NULL;
534 -
535 - ret = find_next_epoch_boundary(next, &base);
536 - if (ret)
537 - return ret;
538 - next->object.flags |= BOUNDARY;
539 - if (base)
540 - base->object.flags |= BOUNDARY;
541 -
542 - if (HAS_EXACTLY_ONE_PARENT(next)) {
543 - while (HAS_EXACTLY_ONE_PARENT(next)
544 - && (action != STOP)
545 - && !ret) {
546 - if (next->object.flags & UNINTERESTING) {
547 - action = STOP;
548 - } else {
549 - action = emitter(next);
550 - }
551 - if (action != STOP) {
552 - next = next->parents->item;
553 - ret = parse_commit(next);
554 - }
555 - }
556 -
557 - } else {
558 - struct commit_list *stack = NULL;
559 - sort_first_epoch(next, &stack);
560 - action = emit_stack(&stack, emitter, (base == NULL));
561 - next = base;
562 - }
563 - }
564 -
565 - if (next && (action != STOP) && !ret) {
566 - emitter(next);
567 - }
568 -
569 - return ret;
570 -}
571 -
572 -/*
573 - * Sorts the nodes reachable from a starting list in merge order, we
574 - * first find the base for the starting list and then sort all nodes
575 - * in this subgraph using the sort_first_epoch algorithm. Once we have
576 - * reached the base we can continue sorting using sort_in_merge_order.
577 - */
578 -int sort_list_in_merge_order(struct commit_list *list, emitter_func emitter)
579 -{
580 - struct commit_list *stack = NULL;
581 - struct commit *base;
582 - int ret = 0;
583 - int action = CONTINUE;
584 - struct commit_list *reversed = NULL;
585 -
586 - for (; list; list = list->next)
587 - commit_list_insert(list->item, &reversed);
588 -
589 - if (!reversed)
590 - return ret;
591 - else if (!reversed->next) {
592 - /*
593 - * If there is only one element in the list, we can sort it
594 - * using sort_in_merge_order.
595 - */
596 - base = reversed->item;
597 - } else {
598 - /*
599 - * Otherwise, we search for the base of the list.
600 - */
601 - ret = find_base_for_list(reversed, &base);
602 - if (ret)
603 - return ret;
604 - if (base)
605 - base->object.flags |= BOUNDARY;
606 -
607 - while (reversed) {
608 - struct commit * next = pop_commit(&reversed);
609 -
610 - if (!(next->object.flags & VISITED) && next!=base) {
611 - sort_first_epoch(next, &stack);
612 - if (reversed) {
613 - /*
614 - * If we have more commits
615 - * to push, then the first
616 - * push for the next parent may
617 - * (or may * not) represent a
618 - * discontinuity with respect
619 - * to the parent currently on
620 - * the top of the stack.
621 - *
622 - * Mark it for checking here,
623 - * and check it with the next
624 - * push. See sort_first_epoch()
625 - * for more details.
626 - */
627 - stack->item->object.flags |= DISCONTINUITY;
628 - }
629 - }
630 - }
631 -
632 - action = emit_stack(&stack, emitter, (base==NULL));
633 - }
634 -
635 - if (base && (action != STOP)) {
636 - ret = sort_in_merge_order(base, emitter);
637 - }
638 -
639 - return ret;
640 -}
epoch.h deleted
-20
@@ -1,20 +0,0 @@
1 -#ifndef EPOCH_H
2 -#define EPOCH_H
3 -
4 -
5 -// return codes for emitter_func
6 -#define STOP 0
7 -#define CONTINUE 1
8 -#define DO 2
9 -typedef int (*emitter_func) (struct commit *);
10 -
11 -int sort_list_in_merge_order(struct commit_list *list, emitter_func emitter);
12 -
13 -/* Low bits are used by rev-list */
14 -#define BOUNDARY (1u<<11)
15 -#define VISITED (1u<<12)
16 -#define DISCONTINUITY (1u<<13)
17 -#define LAST_EPOCH_FLAG (1u<<14)
18 -
19 -
20 -#endif /* EPOCH_H */
git-archimport.perl
+2 -2
@@ -928,7 +928,7 @@ sub find_parents {
928
929 # now walk up to the mergepoint collecting what patches we have
930 my $branchtip = git_rev_parse($ps->{branch});
931 - my @ancestors = `git-rev-list --merge-order $branchtip ^$mergebase`;
931 + my @ancestors = `git-rev-list --topo-order $branchtip ^$mergebase`;
932 my %have; # collected merges this branch has
933 foreach my $merge (@{$ps->{merges}}) {
934 $have{$merge} = 1;
@@ -951,7 +951,7 @@ sub find_parents {
951 # see what the remote branch has - these are the merges we
952 # will want to have in a consecutive series from the mergebase
953 my $otherbranchtip = git_rev_parse($branch);
954 - my @needraw = `git-rev-list --merge-order $otherbranchtip ^$mergebase`;
954 + my @needraw = `git-rev-list --topo-order $otherbranchtip ^$mergebase`;
955 my @need;
956 foreach my $needps (@needraw) { # get the psets
957 $needps = commitid2pset($needps);
rev-list.c
+4 -110
@@ -4,14 +4,12 @@
4 #include "commit.h"
5 #include "tree.h"
6 #include "blob.h"
7 -#include "epoch.h"
7 #include "diff.h"
8 #include "revision.h"
9
11 -/* bits #0-2 in revision.h */
10 +/* bits #0-3 in revision.h */
11
13 -#define COUNTED (1u << 3)
14 -#define SHOWN (1u << 4)
12 +#define COUNTED (1u << 4)
13 #define TMP_MARK (1u << 5) /* for isolated cases; clean after use */
14
15 static const char rev_list_usage[] =
@@ -25,7 +23,6 @@ static const char rev_list_usage[] =
23 " --remove-empty\n"
24 " --all\n"
25 " ordering output:\n"
28 -" --merge-order [ --show-breaks ]\n"
26 " --topo-order\n"
27 " --date-order\n"
28 " formatting output:\n"
@@ -47,22 +44,9 @@ static int show_parents = 0;
44 static int hdr_termination = 0;
45 static const char *commit_prefix = "";
46 static enum cmit_fmt commit_format = CMIT_FMT_RAW;
50 -static int merge_order = 0;
51 -static int show_breaks = 0;
52 -static int stop_traversal = 0;
53 -static int no_merges = 0;
47
48 static void show_commit(struct commit *commit)
49 {
57 - commit->object.flags |= SHOWN;
58 - if (show_breaks) {
59 - commit_prefix = "| ";
60 - if (commit->object.flags & DISCONTINUITY) {
61 - commit_prefix = "^ ";
62 - } else if (commit->object.flags & BOUNDARY) {
63 - commit_prefix = "= ";
64 - }
65 - }
50 printf("%s%s", commit_prefix, sha1_to_hex(commit->object.sha1));
51 if (show_parents) {
52 struct commit_list *parents = commit->parents;
@@ -96,73 +80,6 @@ static void show_commit(struct commit *commit)
80 fflush(stdout);
81 }
82
99 -static int rewrite_one(struct commit **pp)
100 -{
101 - for (;;) {
102 - struct commit *p = *pp;
103 - if (p->object.flags & (TREECHANGE | UNINTERESTING))
104 - return 0;
105 - if (!p->parents)
106 - return -1;
107 - *pp = p->parents->item;
108 - }
109 -}
110 -
111 -static void rewrite_parents(struct commit *commit)
112 -{
113 - struct commit_list **pp = &commit->parents;
114 - while (*pp) {
115 - struct commit_list *parent = *pp;
116 - if (rewrite_one(&parent->item) < 0) {
117 - *pp = parent->next;
118 - continue;
119 - }
120 - pp = &parent->next;
121 - }
122 -}
123 -
124 -static int filter_commit(struct commit * commit)
125 -{
126 - if (stop_traversal && (commit->object.flags & BOUNDARY))
127 - return STOP;
128 - if (commit->object.flags & (UNINTERESTING|SHOWN))
129 - return CONTINUE;
130 - if (revs.min_age != -1 && (commit->date > revs.min_age))
131 - return CONTINUE;
132 - if (revs.max_age != -1 && (commit->date < revs.max_age)) {
133 - stop_traversal=1;
134 - return CONTINUE;
135 - }
136 - if (no_merges && (commit->parents && commit->parents->next))
137 - return CONTINUE;
138 - if (revs.paths && revs.dense) {
139 - if (!(commit->object.flags & TREECHANGE))
140 - return CONTINUE;
141 - rewrite_parents(commit);
142 - }
143 - return DO;
144 -}
145 -
146 -static int process_commit(struct commit * commit)
147 -{
148 - int action=filter_commit(commit);
149 -
150 - if (action == STOP) {
151 - return STOP;
152 - }
153 -
154 - if (action == CONTINUE) {
155 - return CONTINUE;
156 - }
157 -
158 - if (revs.max_count != -1 && !revs.max_count--)
159 - return STOP;
160 -
161 - show_commit(commit);
162 -
163 - return CONTINUE;
164 -}
165 -
83 static struct object_list **process_blob(struct blob *blob,
84 struct object_list **p,
85 struct name_path *path,
@@ -219,8 +136,7 @@ static void show_commit_list(struct rev_info *revs)
136
137 while ((commit = get_revision(revs)) != NULL) {
138 p = process_tree(commit->tree, p, NULL, "");
222 - if (process_commit(commit) == STOP)
223 - break;
139 + show_commit(commit);
140 }
141 for (pending = revs->pending_objects; pending; pending = pending->next) {
142 struct object *obj = pending->item;
@@ -416,10 +332,6 @@ int main(int argc, const char **argv)
332 commit_prefix = "commit ";
333 continue;
334 }
419 - if (!strncmp(arg, "--no-merges", 11)) {
420 - no_merges = 1;
421 - continue;
422 - }
335 if (!strcmp(arg, "--parents")) {
336 show_parents = 1;
337 continue;
@@ -428,14 +340,6 @@ int main(int argc, const char **argv)
340 bisect_list = 1;
341 continue;
342 }
431 - if (!strcmp(arg, "--merge-order")) {
432 - merge_order = 1;
433 - continue;
434 - }
435 - if (!strcmp(arg, "--show-breaks")) {
436 - show_breaks = 1;
437 - continue;
438 - }
343 usage(rev_list_usage);
344
345 }
@@ -456,17 +360,7 @@ int main(int argc, const char **argv)
360 save_commit_buffer = verbose_header;
361 track_object_refs = 0;
362
459 - if (!merge_order) {
460 - show_commit_list(&revs);
461 - } else {
462 -#ifndef NO_OPENSSL
463 - if (sort_list_in_merge_order(list, &process_commit)) {
464 - die("merge order sort failed\n");
465 - }
466 -#else
467 - die("merge order sort unsupported, OpenSSL not linked");
468 -#endif
469 - }
363 + show_commit_list(&revs);
364
365 return 0;
366 }
rev-parse.c
-2
@@ -39,14 +39,12 @@ static int is_rev_argument(const char *arg)
39 "--header",
40 "--max-age=",
41 "--max-count=",
42 - "--merge-order",
42 "--min-age=",
43 "--no-merges",
44 "--objects",
45 "--objects-edge",
46 "--parents",
47 "--pretty",
49 - "--show-breaks",
48 "--sparse",
49 "--topo-order",
50 "--date-order",
revision.c
+69 -8
@@ -381,6 +381,9 @@ static void limit_list(struct rev_info *revs)
381 struct commit_list *newlist = NULL;
382 struct commit_list **p = &newlist;
383
384 + if (revs->paths)
385 + diff_tree_setup_paths(revs->paths);
386 +
387 while (list) {
388 struct commit_list *entry = list;
389 struct commit *commit = list->item;
@@ -436,12 +439,13 @@ static void handle_all(struct rev_info *revs, unsigned flags)
439 * Parse revision information, filling in the "rev_info" structure,
440 * and removing the used arguments from the argument list.
441 *
439 - * Returns the number of arguments left ("new argc").
442 + * Returns the number of arguments left that weren't recognized
443 + * (which are also moved to the head of the argument list)
444 */
445 int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def)
446 {
447 int i, flags, seen_dashdash;
444 - const char **unrecognized = argv+1;
448 + const char **unrecognized = argv + 1;
449 int left = 1;
450
451 memset(revs, 0, sizeof(*revs));
@@ -525,6 +529,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
529 revs->remove_empty_trees = 1;
530 continue;
531 }
532 + if (!strncmp(arg, "--no-merges", 11)) {
533 + revs->no_merges = 1;
534 + continue;
535 + }
536 if (!strcmp(arg, "--objects")) {
537 revs->tag_objects = 1;
538 revs->tree_objects = 1;
@@ -601,14 +609,11 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
609 }
610 if (revs->paths)
611 revs->limited = 1;
604 - *unrecognized = NULL;
612 return left;
613 }
614
615 void prepare_revision_walk(struct rev_info *revs)
616 {
610 - if (revs->paths)
611 - diff_tree_setup_paths(revs->paths);
617 sort_by_date(&revs->commits);
618 if (revs->limited)
619 limit_list(revs);
@@ -616,11 +621,67 @@ void prepare_revision_walk(struct rev_info *revs)
621 sort_in_topological_order(&revs->commits, revs->lifo);
622 }
623
624 +static int rewrite_one(struct commit **pp)
625 +{
626 + for (;;) {
627 + struct commit *p = *pp;
628 + if (p->object.flags & (TREECHANGE | UNINTERESTING))
629 + return 0;
630 + if (!p->parents)
631 + return -1;
632 + *pp = p->parents->item;
633 + }
634 +}
635 +
636 +static void rewrite_parents(struct commit *commit)
637 +{
638 + struct commit_list **pp = &commit->parents;
639 + while (*pp) {
640 + struct commit_list *parent = *pp;
641 + if (rewrite_one(&parent->item) < 0) {
642 + *pp = parent->next;
643 + continue;
644 + }
645 + pp = &parent->next;
646 + }
647 +}
648 +
649 struct commit *get_revision(struct rev_info *revs)
650 {
621 - if (!revs->commits)
651 + struct commit_list *list = revs->commits;
652 + struct commit *commit;
653 +
654 + if (!list)
655 return NULL;
623 - return pop_most_recent_commit(&revs->commits, SEEN);
624 -}
656
657 + /* Check the max_count ... */
658 + commit = list->item;
659 + switch (revs->max_count) {
660 + case -1:
661 + break;
662 + case 0:
663 + return NULL;
664 + default:
665 + revs->max_count--;
666 + }
667
668 + do {
669 + commit = pop_most_recent_commit(&revs->commits, SEEN);
670 + if (commit->object.flags & (UNINTERESTING|SHOWN))
671 + continue;
672 + if (revs->min_age != -1 && (commit->date > revs->min_age))
673 + continue;
674 + if (revs->max_age != -1 && (commit->date < revs->max_age))
675 + return NULL;
676 + if (revs->no_merges && commit->parents && commit->parents->next)
677 + continue;
678 + if (revs->paths && revs->dense) {
679 + if (!(commit->object.flags & TREECHANGE))
680 + continue;
681 + rewrite_parents(commit);
682 + }
683 + commit->object.flags |= SHOWN;
684 + return commit;
685 + } while (revs->commits);
686 + return NULL;
687 +}
revision.h
+2
@@ -4,6 +4,7 @@
4 #define SEEN (1u<<0)
5 #define UNINTERESTING (1u<<1)
6 #define TREECHANGE (1u<<2)
7 +#define SHOWN (1u<<3)
8
9 struct rev_info {
10 /* Starting list */
@@ -16,6 +17,7 @@ struct rev_info {
17
18 /* Traversal flags */
19 unsigned int dense:1,
20 + no_merges:1,
21 remove_empty_trees:1,
22 lifo:1,
23 topo_order:1,
t/t6001-rev-list-merge-order.sh deleted
-462
@@ -1,462 +0,0 @@
1 -#!/bin/sh
2 -#
3 -# Copyright (c) 2005 Jon Seymour
4 -#
5 -
6 -test_description='Tests git-rev-list --merge-order functionality'
7 -
8 -. ./test-lib.sh
9 -. ../t6000lib.sh # t6xxx specific functions
10 -
11 -# test-case specific test function
12 -check_adjacency()
13 -{
14 - read previous
15 - echo "= $previous"
16 - while read next
17 - do
18 - if ! (git-cat-file commit $previous | grep "^parent $next" >/dev/null)
19 - then
20 - echo "^ $next"
21 - else
22 - echo "| $next"
23 - fi
24 - previous=$next
25 - done
26 -}
27 -
28 -list_duplicates()
29 -{
30 - "$@" | sort | uniq -d
31 -}
32 -
33 -grep_stderr()
34 -{
35 - args=$1
36 - shift 1
37 - "$@" 2>&1 | grep "$args"
38 -}
39 -
40 -date >path0
41 -git-update-index --add path0
42 -save_tag tree git-write-tree
43 -on_committer_date "1971-08-16 00:00:00" hide_error save_tag root unique_commit root tree
44 -on_committer_date "1971-08-16 00:00:01" save_tag l0 unique_commit l0 tree -p root
45 -on_committer_date "1971-08-16 00:00:02" save_tag l1 unique_commit l1 tree -p l0
46 -on_committer_date "1971-08-16 00:00:03" save_tag l2 unique_commit l2 tree -p l1
47 -on_committer_date "1971-08-16 00:00:04" save_tag a0 unique_commit a0 tree -p l2
48 -on_committer_date "1971-08-16 00:00:05" save_tag a1 unique_commit a1 tree -p a0
49 -on_committer_date "1971-08-16 00:00:06" save_tag b1 unique_commit b1 tree -p a0
50 -on_committer_date "1971-08-16 00:00:07" save_tag c1 unique_commit c1 tree -p b1
51 -on_committer_date "1971-08-16 00:00:08" as_author foobar@example.com save_tag b2 unique_commit b2 tree -p b1
52 -on_committer_date "1971-08-16 00:00:09" save_tag b3 unique_commit b2 tree -p b2
53 -on_committer_date "1971-08-16 00:00:10" save_tag c2 unique_commit c2 tree -p c1 -p b2
54 -on_committer_date "1971-08-16 00:00:11" save_tag c3 unique_commit c3 tree -p c2
55 -on_committer_date "1971-08-16 00:00:12" save_tag a2 unique_commit a2 tree -p a1
56 -on_committer_date "1971-08-16 00:00:13" save_tag a3 unique_commit a3 tree -p a2
57 -on_committer_date "1971-08-16 00:00:14" save_tag b4 unique_commit b4 tree -p b3 -p a3
58 -on_committer_date "1971-08-16 00:00:15" save_tag a4 unique_commit a4 tree -p a3 -p b4 -p c3
59 -on_committer_date "1971-08-16 00:00:16" save_tag l3 unique_commit l3 tree -p a4
60 -on_committer_date "1971-08-16 00:00:17" save_tag l4 unique_commit l4 tree -p l3
61 -on_committer_date "1971-08-16 00:00:18" save_tag l5 unique_commit l5 tree -p l4
62 -on_committer_date "1971-08-16 00:00:19" save_tag m1 unique_commit m1 tree -p a4 -p c3
63 -on_committer_date "1971-08-16 00:00:20" save_tag m2 unique_commit m2 tree -p c3 -p a4
64 -on_committer_date "1971-08-16 00:00:21" hide_error save_tag alt_root unique_commit alt_root tree
65 -on_committer_date "1971-08-16 00:00:22" save_tag r0 unique_commit r0 tree -p alt_root
66 -on_committer_date "1971-08-16 00:00:23" save_tag r1 unique_commit r1 tree -p r0
67 -on_committer_date "1971-08-16 00:00:24" save_tag l5r1 unique_commit l5r1 tree -p l5 -p r1
68 -on_committer_date "1971-08-16 00:00:25" save_tag r1l5 unique_commit r1l5 tree -p r1 -p l5
69 -
70 -
71 -#
72 -# note: as of 20/6, it isn't possible to create duplicate parents, so this
73 -# can't be tested.
74 -#
75 -#on_committer_date "1971-08-16 00:00:20" save_tag m3 unique_commit m3 tree -p c3 -p a4 -p c3
76 -hide_error save_tag e1 as_author e@example.com unique_commit e1 tree
77 -save_tag e2 as_author e@example.com unique_commit e2 tree -p e1
78 -save_tag f1 as_author f@example.com unique_commit f1 tree -p e1
79 -save_tag e3 as_author e@example.com unique_commit e3 tree -p e2
80 -save_tag f2 as_author f@example.com unique_commit f2 tree -p f1
81 -save_tag e4 as_author e@example.com unique_commit e4 tree -p e3 -p f2
82 -save_tag e5 as_author e@example.com unique_commit e5 tree -p e4
83 -save_tag f3 as_author f@example.com unique_commit f3 tree -p f2
84 -save_tag f4 as_author f@example.com unique_commit f4 tree -p f3
85 -save_tag e6 as_author e@example.com unique_commit e6 tree -p e5 -p f4
86 -save_tag f5 as_author f@example.com unique_commit f5 tree -p f4
87 -save_tag f6 as_author f@example.com unique_commit f6 tree -p f5 -p e6
88 -save_tag e7 as_author e@example.com unique_commit e7 tree -p e6
89 -save_tag e8 as_author e@example.com unique_commit e8 tree -p e7
90 -save_tag e9 as_author e@example.com unique_commit e9 tree -p e8
91 -save_tag f7 as_author f@example.com unique_commit f7 tree -p f6
92 -save_tag f8 as_author f@example.com unique_commit f8 tree -p f7
93 -save_tag f9 as_author f@example.com unique_commit f9 tree -p f8
94 -save_tag e10 as_author e@example.com unique_commit e1 tree -p e9 -p f8
95 -
96 -hide_error save_tag g0 unique_commit g0 tree
97 -save_tag g1 unique_commit g1 tree -p g0
98 -save_tag h1 unique_commit g2 tree -p g0
99 -save_tag g2 unique_commit g3 tree -p g1 -p h1
100 -save_tag h2 unique_commit g4 tree -p g2
101 -save_tag g3 unique_commit g5 tree -p g2
102 -save_tag g4 unique_commit g6 tree -p g3 -p h2
103 -
104 -git-update-ref HEAD $(tag l5)
105 -
106 -test_output_expect_success 'rev-list has correct number of entries' 'git-rev-list HEAD | wc -l | tr -d \" \"' <<EOF
107 -19
108 -EOF
109 -
110 -if git-rev-list --merge-order HEAD 2>&1 | grep 'OpenSSL not linked' >/dev/null
111 -then
112 - test_expect_success 'skipping merge-order test' :
113 - test_done
114 - exit
115 -fi
116 -
117 -normal_adjacency_count=$(git-rev-list HEAD | check_adjacency | grep -c "\^" | tr -d ' ')
118 -merge_order_adjacency_count=$(git-rev-list --merge-order HEAD | check_adjacency | grep -c "\^" | tr -d ' ')
119 -test_expect_success '--merge-order produces as many or fewer discontinuities' '[ $merge_order_adjacency_count -le $normal_adjacency_count ]'
120 -test_output_expect_success 'simple merge order' 'git-rev-list --merge-order --show-breaks HEAD' <<EOF
121 -= l5
122 -| l4
123 -| l3
124 -= a4
125 -| c3
126 -| c2
127 -| c1
128 -^ b4
129 -| b3
130 -| b2
131 -| b1
132 -^ a3
133 -| a2
134 -| a1
135 -= a0
136 -| l2
137 -| l1
138 -| l0
139 -= root
140 -EOF
141 -
142 -test_output_expect_success 'two diamonds merge order (g6)' 'git-rev-list --merge-order --show-breaks g4' <<EOF
143 -= g4
144 -| h2
145 -^ g3
146 -= g2
147 -| h1
148 -^ g1
149 -= g0
150 -EOF
151 -
152 -test_output_expect_success 'multiple heads' 'git-rev-list --merge-order a3 b3 c3' <<EOF
153 -c3
154 -c2
155 -c1
156 -b3
157 -b2
158 -b1
159 -a3
160 -a2
161 -a1
162 -a0
163 -l2
164 -l1
165 -l0
166 -root
167 -EOF
168 -
169 -test_output_expect_success 'multiple heads, prune at a1' 'git-rev-list --merge-order a3 b3 c3 ^a1' <<EOF
170 -c3
171 -c2
172 -c1
173 -b3
174 -b2
175 -b1
176 -a3
177 -a2
178 -EOF
179 -
180 -test_output_expect_success 'multiple heads, prune at l1' 'git-rev-list --merge-order a3 b3 c3 ^l1' <<EOF
181 -c3
182 -c2
183 -c1
184 -b3
185 -b2
186 -b1
187 -a3
188 -a2
189 -a1
190 -a0
191 -l2
192 -EOF
193 -
194 -test_output_expect_success 'cross-epoch, head at l5, prune at l1' 'git-rev-list --merge-order l5 ^l1' <<EOF
195 -l5
196 -l4
197 -l3
198 -a4
199 -c3
200 -c2
201 -c1
202 -b4
203 -b3
204 -b2
205 -b1
206 -a3
207 -a2
208 -a1
209 -a0
210 -l2
211 -EOF
212 -
213 -test_output_expect_success 'duplicated head arguments' 'git-rev-list --merge-order l5 l5 ^l1' <<EOF
214 -l5
215 -l4
216 -l3
217 -a4
218 -c3
219 -c2
220 -c1
221 -b4
222 -b3
223 -b2
224 -b1
225 -a3
226 -a2
227 -a1
228 -a0
229 -l2
230 -EOF
231 -
232 -test_output_expect_success 'prune near merge' 'git-rev-list --merge-order a4 ^c3' <<EOF
233 -a4
234 -b4
235 -b3
236 -a3
237 -a2
238 -a1
239 -EOF
240 -
241 -test_output_expect_success "head has no parent" 'git-rev-list --merge-order --show-breaks root' <<EOF
242 -= root
243 -EOF
244 -
245 -test_output_expect_success "two nodes - one head, one base" 'git-rev-list --merge-order --show-breaks l0' <<EOF
246 -= l0
247 -= root
248 -EOF
249 -
250 -test_output_expect_success "three nodes one head, one internal, one base" 'git-rev-list --merge-order --show-breaks l1' <<EOF
251 -= l1
252 -| l0
253 -= root
254 -EOF
255 -
256 -test_output_expect_success "linear prune l2 ^root" 'git-rev-list --merge-order --show-breaks l2 ^root' <<EOF
257 -^ l2
258 -| l1
259 -| l0
260 -EOF
261 -
262 -test_output_expect_success "linear prune l2 ^l0" 'git-rev-list --merge-order --show-breaks l2 ^l0' <<EOF
263 -^ l2
264 -| l1
265 -EOF
266 -
267 -test_output_expect_success "linear prune l2 ^l1" 'git-rev-list --merge-order --show-breaks l2 ^l1' <<EOF
268 -^ l2
269 -EOF
270 -
271 -test_output_expect_success "linear prune l5 ^a4" 'git-rev-list --merge-order --show-breaks l5 ^a4' <<EOF
272 -^ l5
273 -| l4
274 -| l3
275 -EOF
276 -
277 -test_output_expect_success "linear prune l5 ^l3" 'git-rev-list --merge-order --show-breaks l5 ^l3' <<EOF
278 -^ l5
279 -| l4
280 -EOF
281 -
282 -test_output_expect_success "linear prune l5 ^l4" 'git-rev-list --merge-order --show-breaks l5 ^l4' <<EOF
283 -^ l5
284 -EOF
285 -
286 -test_output_expect_success "max-count 10 - merge order" 'git-rev-list --merge-order --show-breaks --max-count=10 l5' <<EOF
287 -= l5
288 -| l4
289 -| l3
290 -= a4
291 -| c3
292 -| c2
293 -| c1
294 -^ b4
295 -| b3
296 -| b2
297 -EOF
298 -
299 -test_output_expect_success "max-count 10 - non merge order" 'git-rev-list --max-count=10 l5' <<EOF
300 -l5
301 -l4
302 -l3
303 -a4
304 -b4
305 -a3
306 -a2
307 -c3
308 -c2
309 -b3
310 -EOF
311 -
312 -test_output_expect_success '--max-age=c3, no --merge-order' "git-rev-list --max-age=$(commit_date c3) l5" <<EOF
313 -l5
314 -l4
315 -l3
316 -a4
317 -b4
318 -a3
319 -a2
320 -c3
321 -EOF
322 -
323 -test_output_expect_success '--max-age=c3, --merge-order' "git-rev-list --merge-order --max-age=$(commit_date c3) l5" <<EOF
324 -l5
325 -l4
326 -l3
327 -a4
328 -c3
329 -b4
330 -a3
331 -a2
332 -EOF
333 -
334 -test_output_expect_success 'one specified head reachable from another a4, c3, --merge-order' "list_duplicates git-rev-list --merge-order a4 c3" <<EOF
335 -EOF
336 -
337 -test_output_expect_success 'one specified head reachable from another c3, a4, --merge-order' "list_duplicates git-rev-list --merge-order c3 a4" <<EOF
338 -EOF
339 -
340 -test_output_expect_success 'one specified head reachable from another a4, c3, no --merge-order' "list_duplicates git-rev-list a4 c3" <<EOF
341 -EOF
342 -
343 -test_output_expect_success 'one specified head reachable from another c3, a4, no --merge-order' "list_duplicates git-rev-list c3 a4" <<EOF
344 -EOF
345 -
346 -test_output_expect_success 'graph with c3 and a4 parents of head' "list_duplicates git-rev-list m1" <<EOF
347 -EOF
348 -
349 -test_output_expect_success 'graph with a4 and c3 parents of head' "list_duplicates git-rev-list m2" <<EOF
350 -EOF
351 -
352 -test_expect_success "head ^head --merge-order" 'git-rev-list --merge-order --show-breaks a3 ^a3' <<EOF
353 -EOF
354 -
355 -#
356 -# can't test this now - duplicate parents can't be created
357 -#
358 -#test_output_expect_success 'duplicate parents' 'git-rev-list --parents --merge-order --show-breaks m3' <<EOF
359 -#= m3 c3 a4 c3
360 -#| a4 c3 b4 a3
361 -#| b4 a3 b3
362 -#| b3 b2
363 -#^ a3 a2
364 -#| a2 a1
365 -#| a1 a0
366 -#^ c3 c2
367 -#| c2 b2 c1
368 -#| b2 b1
369 -#^ c1 b1
370 -#| b1 a0
371 -#= a0 l2
372 -#| l2 l1
373 -#| l1 l0
374 -#| l0 root
375 -#= root
376 -#EOF
377 -
378 -test_expect_success "head ^head no --merge-order" 'git-rev-list a3 ^a3' <<EOF
379 -EOF
380 -
381 -test_output_expect_success 'simple merge order (l5r1)' 'git-rev-list --merge-order --show-breaks l5r1' <<EOF
382 -= l5r1
383 -| r1
384 -| r0
385 -| alt_root
386 -^ l5
387 -| l4
388 -| l3
389 -| a4
390 -| c3
391 -| c2
392 -| c1
393 -^ b4
394 -| b3
395 -| b2
396 -| b1
397 -^ a3
398 -| a2
399 -| a1
400 -| a0
401 -| l2
402 -| l1
403 -| l0
404 -= root
405 -EOF
406 -
407 -test_output_expect_success 'simple merge order (r1l5)' 'git-rev-list --merge-order --show-breaks r1l5' <<EOF
408 -= r1l5
409 -| l5
410 -| l4
411 -| l3
412 -| a4
413 -| c3
414 -| c2
415 -| c1
416 -^ b4
417 -| b3
418 -| b2
419 -| b1
420 -^ a3
421 -| a2
422 -| a1
423 -| a0
424 -| l2
425 -| l1
426 -| l0
427 -| root
428 -^ r1
429 -| r0
430 -= alt_root
431 -EOF
432 -
433 -test_output_expect_success "don't print things unreachable from one branch" "git-rev-list a3 ^b3 --merge-order" <<EOF
434 -a3
435 -a2
436 -a1
437 -EOF
438 -
439 -test_output_expect_success "--merge-order a4 l3" "git-rev-list --merge-order a4 l3" <<EOF
440 -l3
441 -a4
442 -c3
443 -c2
444 -c1
445 -b4
446 -b3
447 -b2
448 -b1
449 -a3
450 -a2
451 -a1
452 -a0
453 -l2
454 -l1
455 -l0
456 -root
457 -EOF
458 -
459 -#
460 -#
461 -
462 -test_done