rev-list --boundary
With the new --boundary flag, the output from rev-list includes the UNINTERESING commits at the boundary, which are usually not shown. Their object names are prefixed with '-'. For example, with this graph: C side / A---B---D master You would get something like this: $ git rev-list --boundary --header --parents side..master D B tree D^{tree} parent B ... log message for commit D here ... \0-B A tree B^{tree} parent A ... log message for commit B here ... \0 Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Mar 27, 2006 at 23:58 UTC
384e99a4a99820c34fe3600b2aad3f0185dd43db
3 files changed
+51
-7
rev-list.c
+4
-2
@@ -7,9 +7,9 @@
7
#include "diff.h"
8
#include "revision.h"
9
10
-/* bits #0-4 in revision.h */
10
+/* bits #0-5 in revision.h */
11
12
-#define COUNTED (1u<<5)
12
+#define COUNTED (1u<<6)
13
14
static const char rev_list_usage[] =
15
"git-rev-list [OPTION] <commit-id>... [ -- paths... ]\n"
@@ -51,6 +51,8 @@ static void show_commit(struct commit *commit)
51
printf("%lu ", commit->date);
52
if (commit_prefix[0])
53
fputs(commit_prefix, stdout);
54
+ if (commit->object.flags & BOUNDARY)
55
+ putchar('-');
56
fputs(sha1_to_hex(commit->object.sha1), stdout);
57
if (show_parents) {
58
struct commit_list *parents = commit->parents;
revision.c
+44
-4
@@ -419,6 +419,27 @@ static void limit_list(struct rev_info *revs)
419
continue;
420
p = &commit_list_insert(commit, p)->next;
421
}
422
+ if (revs->boundary) {
423
+ list = newlist;
424
+ while (list) {
425
+ struct commit *commit = list->item;
426
+ struct object *obj = &commit->object;
427
+ struct commit_list *parent = commit->parents;
428
+ if (obj->flags & (UNINTERESTING|BOUNDARY)) {
429
+ list = list->next;
430
+ continue;
431
+ }
432
+ while (parent) {
433
+ struct commit *pcommit = parent->item;
434
+ parent = parent->next;
435
+ if (!(pcommit->object.flags & UNINTERESTING))
436
+ continue;
437
+ pcommit->object.flags |= BOUNDARY;
438
+ p = &commit_list_insert(pcommit, p)->next;
439
+ }
440
+ list = list->next;
441
+ }
442
+ }
443
revs->commits = newlist;
444
}
445
@@ -591,6 +612,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
612
revs->no_merges = 1;
613
continue;
614
}
615
+ if (!strcmp(arg, "--boundary")) {
616
+ revs->boundary = 1;
617
+ continue;
618
+ }
619
if (!strcmp(arg, "--objects")) {
620
revs->tag_objects = 1;
621
revs->tree_objects = 1;
@@ -731,13 +756,17 @@ struct commit *get_revision(struct rev_info *revs)
756
do {
757
struct commit *commit = revs->commits->item;
758
734
- if (commit->object.flags & (UNINTERESTING|SHOWN))
759
+ if (commit->object.flags & SHOWN)
760
+ goto next;
761
+ if (!(commit->object.flags & BOUNDARY) &&
762
+ (commit->object.flags & UNINTERESTING))
763
goto next;
764
if (revs->min_age != -1 && (commit->date > revs->min_age))
765
goto next;
766
if (revs->max_age != -1 && (commit->date < revs->max_age))
767
return NULL;
740
- if (revs->no_merges && commit->parents && commit->parents->next)
768
+ if (revs->no_merges &&
769
+ commit->parents && commit->parents->next)
770
goto next;
771
if (revs->prune_fn && revs->dense) {
772
if (!(commit->object.flags & TREECHANGE))
@@ -745,8 +774,19 @@ struct commit *get_revision(struct rev_info *revs)
774
rewrite_parents(commit);
775
}
776
/* More to go? */
748
- if (revs->max_count)
749
- pop_most_recent_commit(&revs->commits, SEEN);
777
+ if (revs->max_count) {
778
+ if (commit->object.flags & BOUNDARY) {
779
+ /* this is already uninteresting,
780
+ * so there is no point popping its
781
+ * parents into the list.
782
+ */
783
+ struct commit_list *it = revs->commits;
784
+ revs->commits = it->next;
785
+ free(it);
786
+ }
787
+ else
788
+ pop_most_recent_commit(&revs->commits, SEEN);
789
+ }
790
commit->object.flags |= SHOWN;
791
return commit;
792
next:
revision.h
+3
-1
@@ -6,6 +6,7 @@
6
#define TREECHANGE (1u<<2)
7
#define SHOWN (1u<<3)
8
#define TMP_MARK (1u<<4) /* for isolated cases; clean after use */
9
+#define BOUNDARY (1u<<5)
10
11
struct rev_info;
12
@@ -32,7 +33,8 @@ struct rev_info {
33
blob_objects:1,
34
edge_hint:1,
35
limited:1,
35
- unpacked:1;
36
+ unpacked:1,
37
+ boundary:1;
38
39
/* special limits */
40
int max_count;