11
#define INTERESTING (1u << 1)
12
#define COUNTED (1u << 2)
13
#define SHOWN (1u << 3)
14
+#define TREECHANGE (1u << 4)
15
16
static const char rev_list_usage[] =
17
"git-rev-list [OPTION] commit-id <commit-id>\n"
28
" --merge-order [ --show-breaks ]\n"
29
" --topo-order";
30
31
+static int dense = 0;
32
static int unpacked = 0;
33
static int bisect_list = 0;
34
static int tag_objects = 0;
81
fflush(stdout);
82
}
83
84
+static void rewrite_one(struct commit **pp)
85
+{
86
+ for (;;) {
87
+ struct commit *p = *pp;
88
+ if (p->object.flags & (TREECHANGE | UNINTERESTING))
89
+ return;
90
+ /* Only single-parent commits don't have TREECHANGE */
91
+ *pp = p->parents->item;
92
+ }
93
+}
94
+
95
+static void rewrite_parents(struct commit *commit)
96
+{
97
+ struct commit_list *parent = commit->parents;
98
+ while (parent) {
99
+ rewrite_one(&parent->item);
100
+ parent = parent->next;
101
+ }
102
+}
103
+
104
static int filter_commit(struct commit * commit)
105
{
106
if (stop_traversal && (commit->object.flags & BOUNDARY))
117
return STOP;
118
if (no_merges && (commit->parents && commit->parents->next))
119
return CONTINUE;
120
+ if (paths && dense) {
121
+ if (!(commit->object.flags & TREECHANGE))
122
+ return CONTINUE;
123
+ rewrite_parents(commit);
124
+ }
125
return DO;
126
}
127
431
.change = file_change,
432
};
433
434
+static int same_tree(struct tree *t1, struct tree *t2)
435
+{
436
+ is_different = 0;
437
+ if (diff_tree_sha1(t1->object.sha1, t2->object.sha1, "", &diff_opt) < 0)
438
+ return 0;
439
+ return !is_different;
440
+}
441
+
442
static struct commit *try_to_simplify_merge(struct commit *commit, struct commit_list *parent)
443
{
444
if (!commit->tree)
450
parse_commit(p);
451
if (!p->tree)
452
continue;
418
- is_different = 0;
419
- if (diff_tree_sha1(commit->tree->object.sha1,
420
- p->tree->object.sha1, "", &diff_opt) < 0)
421
- continue;
422
- if (!is_different)
453
+ if (same_tree(commit->tree, p->tree))
454
return p;
455
}
456
return NULL;
516
}
517
}
518
519
+static void compress_list(struct commit_list *list)
520
+{
521
+ while (list) {
522
+ struct commit *commit = list->item;
523
+ struct commit_list *parent = commit->parents;
524
+ list = list->next;
525
+
526
+ /*
527
+ * Exactly one parent? Check if it leaves the tree
528
+ * unchanged
529
+ */
530
+ if (parent && !parent->next) {
531
+ struct tree *t1 = commit->tree;
532
+ struct tree *t2 = parent->item->tree;
533
+ if (!t1 || !t2 || same_tree(t1, t2))
534
+ continue;
535
+ }
536
+ commit->object.flags |= TREECHANGE;
537
+ }
538
+}
539
+
540
static struct commit_list *limit_list(struct commit_list *list)
541
{
542
struct commit_list *newlist = NULL;
566
}
567
if (tree_objects)
568
mark_edges_uninteresting(newlist);
569
+ if (paths && dense)
570
+ compress_list(newlist);
571
if (bisect_list)
572
newlist = find_bisection(newlist);
573
return newlist;
754
limited = 1;
755
continue;
756
}
757
+ if (!strcmp(arg, "--dense")) {
758
+ dense = 1;
759
+ continue;
760
+ }
761
if (!strcmp(arg, "--")) {
762
paths = get_pathspec(prefix, argv + i + 1);
763
if (paths) {