1 #define USE_THE_REPOSITORY_VARIABLE
4 #include "environment.h"
12 #include "object-name.h"
13 #include "parse-options.h"
16 #include "commit-slab.h"
18 #include "wildmatch.h"
20 static const char* show_branch_usage
[] = {
21 N_("git show-branch [-a | --all] [-r | --remotes] [--topo-order | --date-order]\n"
22 " [--current] [--color[=<when>] | --no-color] [--sparse]\n"
23 " [--more=<n> | --list | --independent | --merge-base]\n"
24 " [--no-name | --sha1-name] [--topics]\n"
25 " [(<rev> | <glob>)...]"),
26 N_("git show-branch (-g | --reflog)[=<n>[,<base>]] [--list] [<ref>]"),
30 static int showbranch_use_color
= -1;
32 static struct strvec default_args
= STRVEC_INIT
;
35 * TODO: convert this use of commit->object.flags to commit-slab
36 * instead to store a pointer to ref name directly. Then use the same
37 * UNINTERESTING definition from revision.h here.
39 #define UNINTERESTING 01
42 #define MAX_REVS (FLAG_BITS - REV_SHIFT) /* should not exceed bits_per_int - REV_SHIFT */
44 #define DEFAULT_REFLOG 4
46 static const char *get_color_code(int idx
)
48 if (want_color(showbranch_use_color
))
49 return column_colors_ansi
[idx
% column_colors_ansi_max
];
53 static const char *get_color_reset_code(void)
55 if (want_color(showbranch_use_color
))
56 return GIT_COLOR_RESET
;
60 static struct commit
*interesting(struct commit_list
*list
)
63 struct commit
*commit
= list
->item
;
65 if (commit
->object
.flags
& UNINTERESTING
)
73 const char *head_name
; /* which head's ancestor? */
74 int generation
; /* how many parents away from head_name */
77 define_commit_slab(commit_name_slab
, struct commit_name
*);
78 static struct commit_name_slab name_slab
;
80 static struct commit_name
*commit_to_name(struct commit
*commit
)
82 return *commit_name_slab_at(&name_slab
, commit
);
86 /* Name the commit as nth generation ancestor of head_name;
87 * we count only the first-parent relationship for naming purposes.
89 static void name_commit(struct commit
*commit
, const char *head_name
, int nth
)
91 struct commit_name
*name
;
93 name
= *commit_name_slab_at(&name_slab
, commit
);
95 name
= xmalloc(sizeof(*name
));
96 *commit_name_slab_at(&name_slab
, commit
) = name
;
98 name
->head_name
= head_name
;
99 name
->generation
= nth
;
102 /* Parent is the first parent of the commit. We may name it
103 * as (n+1)th generation ancestor of the same head_name as
104 * commit is nth generation ancestor of, if that generation
105 * number is better than the name it already has.
107 static void name_parent(struct commit
*commit
, struct commit
*parent
)
109 struct commit_name
*commit_name
= commit_to_name(commit
);
110 struct commit_name
*parent_name
= commit_to_name(parent
);
114 commit_name
->generation
+ 1 < parent_name
->generation
)
115 name_commit(parent
, commit_name
->head_name
,
116 commit_name
->generation
+ 1);
119 static int name_first_parent_chain(struct commit
*c
)
124 if (!commit_to_name(c
))
128 p
= c
->parents
->item
;
129 if (!commit_to_name(p
)) {
140 static void name_commits(struct commit_list
*list
,
145 struct commit_list
*cl
;
149 /* First give names to the given heads */
150 for (cl
= list
; cl
; cl
= cl
->next
) {
152 if (commit_to_name(c
))
154 for (i
= 0; i
< num_rev
; i
++) {
156 name_commit(c
, ref_name
[i
], 0);
162 /* Then commits on the first parent ancestry chain */
165 for (cl
= list
; cl
; cl
= cl
->next
) {
166 i
+= name_first_parent_chain(cl
->item
);
170 /* Finally, any unnamed commits */
173 for (cl
= list
; cl
; cl
= cl
->next
) {
174 struct commit_list
*parents
;
175 struct commit_name
*n
;
178 if (!commit_to_name(c
))
180 n
= commit_to_name(c
);
181 parents
= c
->parents
;
184 struct commit
*p
= parents
->item
;
185 struct strbuf newname
= STRBUF_INIT
;
186 parents
= parents
->next
;
188 if (commit_to_name(p
))
190 switch (n
->generation
) {
192 strbuf_addstr(&newname
, n
->head_name
);
195 strbuf_addf(&newname
, "%s^", n
->head_name
);
198 strbuf_addf(&newname
, "%s~%d",
199 n
->head_name
, n
->generation
);
203 strbuf_addch(&newname
, '^');
205 strbuf_addf(&newname
, "^%d", nth
);
206 name_commit(p
, strbuf_detach(&newname
, NULL
), 0);
208 name_first_parent_chain(p
);
214 static int mark_seen(struct commit
*commit
, struct commit_list
**seen_p
)
216 if (!commit
->object
.flags
) {
217 commit_list_insert(commit
, seen_p
);
223 static void join_revs(struct commit_list
**list_p
,
224 struct commit_list
**seen_p
,
225 int num_rev
, int extra
)
227 int all_mask
= ((1u << (REV_SHIFT
+ num_rev
)) - 1);
228 int all_revs
= all_mask
& ~((1u << REV_SHIFT
) - 1);
231 struct commit_list
*parents
;
232 int still_interesting
= !!interesting(*list_p
);
233 struct commit
*commit
= pop_commit(list_p
);
234 int flags
= commit
->object
.flags
& all_mask
;
236 if (!still_interesting
&& extra
<= 0)
239 mark_seen(commit
, seen_p
);
240 if ((flags
& all_revs
) == all_revs
)
241 flags
|= UNINTERESTING
;
242 parents
= commit
->parents
;
245 struct commit
*p
= parents
->item
;
246 int this_flag
= p
->object
.flags
;
247 parents
= parents
->next
;
248 if ((this_flag
& flags
) == flags
)
250 repo_parse_commit(the_repository
, p
);
251 if (mark_seen(p
, seen_p
) && !still_interesting
)
253 p
->object
.flags
|= flags
;
254 commit_list_insert_by_date(p
, list_p
);
259 * Postprocess to complete well-poisoning.
261 * At this point we have all the commits we have seen in
262 * seen_p list. Mark anything that can be reached from
263 * uninteresting commits not interesting.
267 struct commit_list
*s
;
268 for (s
= *seen_p
; s
; s
= s
->next
) {
269 struct commit
*c
= s
->item
;
270 struct commit_list
*parents
;
272 if (((c
->object
.flags
& all_revs
) != all_revs
) &&
273 !(c
->object
.flags
& UNINTERESTING
))
276 /* The current commit is either a merge base or
277 * already uninteresting one. Mark its parents
278 * as uninteresting commits _only_ if they are
279 * already parsed. No reason to find new ones
282 parents
= c
->parents
;
284 struct commit
*p
= parents
->item
;
285 parents
= parents
->next
;
286 if (!(p
->object
.flags
& UNINTERESTING
)) {
287 p
->object
.flags
|= UNINTERESTING
;
297 static void show_one_commit(struct commit
*commit
, int no_name
)
299 struct strbuf pretty
= STRBUF_INIT
;
300 const char *pretty_str
= "(unavailable)";
301 struct commit_name
*name
= commit_to_name(commit
);
303 if (commit
->object
.parsed
) {
304 pp_commit_easy(CMIT_FMT_ONELINE
, commit
, &pretty
);
305 pretty_str
= pretty
.buf
;
307 skip_prefix(pretty_str
, "[PATCH] ", &pretty_str
);
310 if (name
&& name
->head_name
) {
311 printf("[%s", name
->head_name
);
312 if (name
->generation
) {
313 if (name
->generation
== 1)
316 printf("~%d", name
->generation
);
322 repo_find_unique_abbrev(the_repository
, &commit
->object
.oid
,
326 strbuf_release(&pretty
);
329 static char *ref_name
[MAX_REVS
+ 1];
330 static int ref_name_cnt
;
332 static const char *find_digit_prefix(const char *s
, int *v
)
339 '0' <= (ch
= *p
) && ch
<= '9';
341 ver
= ver
* 10 + ch
- '0';
347 static int version_cmp(const char *a
, const char *b
)
352 a
= find_digit_prefix(a
, &va
);
353 b
= find_digit_prefix(b
, &vb
);
360 if ('0' <= ca
&& ca
<= '9')
362 if ('0' <= cb
&& cb
<= '9')
376 static int compare_ref_name(const void *a_
, const void *b_
)
378 const char * const*a
= a_
, * const*b
= b_
;
379 return version_cmp(*a
, *b
);
382 static void sort_ref_range(int bottom
, int top
)
384 QSORT(ref_name
+ bottom
, top
- bottom
, compare_ref_name
);
387 static int append_ref(const char *refname
, const struct object_id
*oid
,
390 struct commit
*commit
= lookup_commit_reference_gently(the_repository
,
398 /* Avoid adding the same thing twice */
399 for (i
= 0; i
< ref_name_cnt
; i
++)
400 if (!strcmp(refname
, ref_name
[i
]))
403 if (MAX_REVS
<= ref_name_cnt
) {
404 warning(Q_("ignoring %s; cannot handle more than %d ref",
405 "ignoring %s; cannot handle more than %d refs",
406 MAX_REVS
), refname
, MAX_REVS
);
409 ref_name
[ref_name_cnt
++] = xstrdup(refname
);
410 ref_name
[ref_name_cnt
] = NULL
;
414 static int append_head_ref(const char *refname
, const char *referent UNUSED
, const struct object_id
*oid
,
415 int flag UNUSED
, void *cb_data UNUSED
)
417 struct object_id tmp
;
419 if (!starts_with(refname
, "refs/heads/"))
421 /* If both heads/foo and tags/foo exists, get_sha1 would
424 if (repo_get_oid(the_repository
, refname
+ ofs
, &tmp
) || !oideq(&tmp
, oid
))
426 return append_ref(refname
+ ofs
, oid
, 0);
429 static int append_remote_ref(const char *refname
, const char *referent UNUSED
, const struct object_id
*oid
,
430 int flag UNUSED
, void *cb_data UNUSED
)
432 struct object_id tmp
;
434 if (!starts_with(refname
, "refs/remotes/"))
436 /* If both heads/foo and tags/foo exists, get_sha1 would
439 if (repo_get_oid(the_repository
, refname
+ ofs
, &tmp
) || !oideq(&tmp
, oid
))
441 return append_ref(refname
+ ofs
, oid
, 0);
444 static int append_tag_ref(const char *refname
, const struct object_id
*oid
,
445 int flag UNUSED
, void *cb_data UNUSED
)
447 if (!starts_with(refname
, "refs/tags/"))
449 return append_ref(refname
+ 5, oid
, 0);
452 static const char *match_ref_pattern
= NULL
;
453 static int match_ref_slash
= 0;
455 static int append_matching_ref(const char *refname
, const char *referent UNUSED
, const struct object_id
*oid
,
456 int flag
, void *cb_data
)
458 /* we want to allow pattern hold/<asterisk> to show all
459 * branches under refs/heads/hold/, and v0.99.9? to show
460 * refs/tags/v0.99.9a and friends.
463 int slash
= count_slashes(refname
);
464 for (tail
= refname
; *tail
&& match_ref_slash
< slash
; )
469 if (wildmatch(match_ref_pattern
, tail
, 0))
471 if (starts_with(refname
, "refs/heads/"))
472 return append_head_ref(refname
, NULL
, oid
, flag
, cb_data
);
473 if (starts_with(refname
, "refs/tags/"))
474 return append_tag_ref(refname
, oid
, flag
, cb_data
);
475 return append_ref(refname
, oid
, 0);
478 static void snarf_refs(int head
, int remotes
)
481 int orig_cnt
= ref_name_cnt
;
483 refs_for_each_ref(get_main_ref_store(the_repository
),
484 append_head_ref
, NULL
);
485 sort_ref_range(orig_cnt
, ref_name_cnt
);
488 int orig_cnt
= ref_name_cnt
;
490 refs_for_each_ref(get_main_ref_store(the_repository
),
491 append_remote_ref
, NULL
);
492 sort_ref_range(orig_cnt
, ref_name_cnt
);
496 static int rev_is_head(const char *head
, const char *name
)
500 skip_prefix(head
, "refs/heads/", &head
);
501 if (!skip_prefix(name
, "refs/heads/", &name
))
502 skip_prefix(name
, "heads/", &name
);
503 return !strcmp(head
, name
);
506 static int show_merge_base(const struct commit_list
*seen
, int num_rev
)
508 int all_mask
= ((1u << (REV_SHIFT
+ num_rev
)) - 1);
509 int all_revs
= all_mask
& ~((1u << REV_SHIFT
) - 1);
512 for (const struct commit_list
*s
= seen
; s
; s
= s
->next
) {
513 struct commit
*commit
= s
->item
;
514 int flags
= commit
->object
.flags
& all_mask
;
515 if (!(flags
& UNINTERESTING
) &&
516 ((flags
& all_revs
) == all_revs
)) {
517 puts(oid_to_hex(&commit
->object
.oid
));
519 commit
->object
.flags
|= UNINTERESTING
;
525 static int show_independent(struct commit
**rev
,
527 unsigned int *rev_mask
)
531 for (i
= 0; i
< num_rev
; i
++) {
532 struct commit
*commit
= rev
[i
];
533 unsigned int flag
= rev_mask
[i
];
535 if (commit
->object
.flags
== flag
)
536 puts(oid_to_hex(&commit
->object
.oid
));
537 commit
->object
.flags
|= UNINTERESTING
;
542 static void append_one_rev(const char *av
)
544 struct object_id revkey
;
545 if (!repo_get_oid(the_repository
, av
, &revkey
)) {
546 append_ref(av
, &revkey
, 0);
549 if (strpbrk(av
, "*?[")) {
550 /* glob style match */
551 int saved_matches
= ref_name_cnt
;
553 match_ref_pattern
= av
;
554 match_ref_slash
= count_slashes(av
);
555 refs_for_each_ref(get_main_ref_store(the_repository
),
556 append_matching_ref
, NULL
);
557 if (saved_matches
== ref_name_cnt
&&
558 ref_name_cnt
< MAX_REVS
)
559 error(_("no matching refs with %s"), av
);
560 sort_ref_range(saved_matches
, ref_name_cnt
);
563 die("bad sha1 reference %s", av
);
566 static int git_show_branch_config(const char *var
, const char *value
,
567 const struct config_context
*ctx
, void *cb
)
569 if (!strcmp(var
, "showbranch.default")) {
571 return config_error_nonbool(var
);
573 * default_arg is now passed to parse_options(), so we need to
574 * mimic the real argv a bit better.
576 if (!default_args
.nr
)
577 strvec_push(&default_args
, "show-branch");
578 strvec_push(&default_args
, value
);
582 if (!strcmp(var
, "color.showbranch")) {
583 showbranch_use_color
= git_config_colorbool(var
, value
);
587 if (git_color_config(var
, value
, cb
) < 0)
590 return git_default_config(var
, value
, ctx
, cb
);
593 static int omit_in_dense(struct commit
*commit
, struct commit
**rev
, int n
)
595 /* If the commit is tip of the named branches, do not
597 * Otherwise, if it is a merge that is reachable from only one
598 * tip, it is not that interesting.
601 for (i
= 0; i
< n
; i
++)
602 if (rev
[i
] == commit
)
604 flag
= commit
->object
.flags
;
605 for (i
= count
= 0; i
< n
; i
++) {
606 if (flag
& (1u << (i
+ REV_SHIFT
)))
614 static int reflog
= 0;
616 static int parse_reflog_param(const struct option
*opt
, const char *arg
,
620 const char **base
= (const char **)opt
->value
;
621 BUG_ON_OPT_NEG(unset
);
624 reflog
= strtoul(arg
, &ep
, 10);
628 return error("unrecognized reflog param '%s'", arg
);
632 reflog
= DEFAULT_REFLOG
;
636 int cmd_show_branch(int ac
,
639 struct repository
*repo UNUSED
)
641 struct commit
*rev
[MAX_REVS
], *commit
;
642 char *reflog_msg
[MAX_REVS
] = {0};
643 struct commit_list
*list
= NULL
, *seen
= NULL
;
644 unsigned int rev_mask
[MAX_REVS
];
645 int num_rev
, i
, extra
= 0;
646 int all_heads
= 0, all_remotes
= 0;
647 int all_mask
, all_revs
;
648 enum rev_sort_order sort_order
= REV_SORT_IN_GRAPH_ORDER
;
650 struct object_id head_oid
;
655 int shown_merge_point
= 0;
656 int with_current_branch
= 0;
660 const char *reflog_base
= NULL
;
661 struct option builtin_show_branch_options
[] = {
662 OPT_BOOL('a', "all", &all_heads
,
663 N_("show remote-tracking and local branches")),
664 OPT_BOOL('r', "remotes", &all_remotes
,
665 N_("show remote-tracking branches")),
666 OPT__COLOR(&showbranch_use_color
,
667 N_("color '*!+-' corresponding to the branch")),
668 { OPTION_INTEGER
, 0, "more", &extra
, N_("n"),
669 N_("show <n> more commits after the common ancestor"),
670 PARSE_OPT_OPTARG
, NULL
, (intptr_t)1 },
671 OPT_SET_INT(0, "list", &extra
, N_("synonym to more=-1"), -1),
672 OPT_BOOL(0, "no-name", &no_name
, N_("suppress naming strings")),
673 OPT_BOOL(0, "current", &with_current_branch
,
674 N_("include the current branch")),
675 OPT_BOOL(0, "sha1-name", &sha1_name
,
676 N_("name commits with their object names")),
677 OPT_BOOL(0, "merge-base", &merge_base
,
678 N_("show possible merge bases")),
679 OPT_BOOL(0, "independent", &independent
,
680 N_("show refs unreachable from any other ref")),
681 OPT_SET_INT_F(0, "topo-order", &sort_order
,
682 N_("show commits in topological order"),
683 REV_SORT_IN_GRAPH_ORDER
, PARSE_OPT_NONEG
),
684 OPT_BOOL(0, "topics", &topics
,
685 N_("show only commits not on the first branch")),
686 OPT_SET_INT(0, "sparse", &sparse
,
687 N_("show merges reachable from only one tip"), 1),
688 OPT_SET_INT_F(0, "date-order", &sort_order
,
689 N_("topologically sort, maintaining date order "
691 REV_SORT_BY_COMMIT_DATE
, PARSE_OPT_NONEG
),
692 OPT_CALLBACK_F('g', "reflog", &reflog_base
, N_("<n>[,<base>]"),
693 N_("show <n> most recent ref-log entries starting at "
695 PARSE_OPT_OPTARG
| PARSE_OPT_NONEG
,
699 const char **args_copy
= NULL
;
702 init_commit_name_slab(&name_slab
);
704 git_config(git_show_branch_config
, NULL
);
706 /* If nothing is specified, try the default first */
707 if (ac
== 1 && default_args
.nr
) {
708 DUP_ARRAY(args_copy
, default_args
.v
, default_args
.nr
);
709 ac
= default_args
.nr
;
713 ac
= parse_options(ac
, av
, prefix
, builtin_show_branch_options
,
714 show_branch_usage
, PARSE_OPT_STOP_AT_NON_OPTION
);
718 if (extra
|| reflog
) {
719 /* "listing" mode is incompatible with
720 * independent nor merge-base modes.
722 if (independent
|| merge_base
)
723 usage_with_options(show_branch_usage
,
724 builtin_show_branch_options
);
725 if (reflog
&& ((0 < extra
) || all_heads
|| all_remotes
))
727 * Asking for --more in reflog mode does not
728 * make sense. --list is Ok.
730 * Also --all and --remotes do not make sense either.
732 die(_("options '%s' and '%s' cannot be used together"), "--reflog",
733 "--all/--remotes/--independent/--merge-base");
736 if (with_current_branch
&& reflog
)
737 die(_("options '%s' and '%s' cannot be used together"),
738 "--reflog", "--current");
740 /* If nothing is specified, show all branches by default */
741 if (ac
<= topics
&& all_heads
+ all_remotes
== 0)
745 struct object_id oid
;
748 unsigned int flags
= 0;
751 static const char *fake_av
[2];
753 fake_av
[0] = refs_resolve_refdup(get_main_ref_store(the_repository
),
762 die(_("no branches given, and HEAD is not valid"));
765 die(_("--reflog option needs one branch name"));
767 if (MAX_REVS
< reflog
)
768 die(Q_("only %d entry can be shown at one time.",
769 "only %d entries can be shown at one time.",
770 MAX_REVS
), MAX_REVS
);
771 if (!repo_dwim_ref(the_repository
, *av
, strlen(*av
), &oid
,
773 die(_("no such ref %s"), *av
);
775 /* Has the base been specified? */
778 base
= strtoul(reflog_base
, &ep
, 10);
780 /* Ah, that is a date spec... */
782 at
= approxidate(reflog_base
);
783 read_ref_at(get_main_ref_store(the_repository
),
784 ref
, flags
, at
, -1, &oid
, NULL
,
789 for (i
= 0; i
< reflog
; i
++) {
794 timestamp_t timestamp
;
797 if (read_ref_at(get_main_ref_store(the_repository
),
798 ref
, flags
, 0, base
+ i
, &oid
, &logmsg
,
799 ×tamp
, &tz
, NULL
)) {
805 end
= strchr(logmsg
, '\n');
809 msg
= (*logmsg
== '\0') ? "(none)" : logmsg
;
810 reflog_msg
[i
] = xstrfmt("(%s) %s",
811 show_date(timestamp
, tz
,
812 DATE_MODE(RELATIVE
)),
816 nth_desc
= xstrfmt("%s@{%d}", *av
, base
+i
);
817 append_ref(nth_desc
, &oid
, 1);
827 if (all_heads
+ all_remotes
)
828 snarf_refs(all_heads
, all_remotes
);
831 head
= refs_resolve_refdup(get_main_ref_store(the_repository
), "HEAD",
835 if (with_current_branch
&& head
) {
837 for (i
= 0; !has_head
&& i
< ref_name_cnt
; i
++) {
838 /* We are only interested in adding the branch
841 if (rev_is_head(head
, ref_name
[i
]))
845 const char *name
= head
;
846 skip_prefix(name
, "refs/heads/", &name
);
847 append_one_rev(name
);
852 fprintf(stderr
, "No revs to be shown.\n");
857 for (num_rev
= 0; ref_name
[num_rev
]; num_rev
++) {
858 struct object_id revkey
;
859 unsigned int flag
= 1u << (num_rev
+ REV_SHIFT
);
861 if (MAX_REVS
<= num_rev
)
862 die(Q_("cannot handle more than %d rev.",
863 "cannot handle more than %d revs.",
864 MAX_REVS
), MAX_REVS
);
865 if (repo_get_oid(the_repository
, ref_name
[num_rev
], &revkey
))
866 die(_("'%s' is not a valid ref."), ref_name
[num_rev
]);
867 commit
= lookup_commit_reference(the_repository
, &revkey
);
869 die(_("cannot find commit %s (%s)"),
870 ref_name
[num_rev
], oid_to_hex(&revkey
));
871 repo_parse_commit(the_repository
, commit
);
872 mark_seen(commit
, &seen
);
874 /* rev#0 uses bit REV_SHIFT, rev#1 uses bit REV_SHIFT+1,
875 * and so on. REV_SHIFT bits from bit 0 are used for
876 * internal bookkeeping.
878 commit
->object
.flags
|= flag
;
879 if (commit
->object
.flags
== flag
)
880 commit_list_insert_by_date(commit
, &list
);
881 rev
[num_rev
] = commit
;
883 for (i
= 0; i
< num_rev
; i
++)
884 rev_mask
[i
] = rev
[i
]->object
.flags
;
887 join_revs(&list
, &seen
, num_rev
, extra
);
889 commit_list_sort_by_date(&seen
);
892 ret
= show_merge_base(seen
, num_rev
);
897 ret
= show_independent(rev
, num_rev
, rev_mask
);
901 /* Show list; --more=-1 means list-only */
902 if (1 < num_rev
|| extra
< 0) {
903 for (i
= 0; i
< num_rev
; i
++) {
905 int is_head
= rev_is_head(head
, ref_name
[i
]) &&
906 oideq(&head_oid
, &rev
[i
]->object
.oid
);
909 is_head
? '*' : ' ', ref_name
[i
]);
911 for (j
= 0; j
< i
; j
++)
913 printf("%s%c%s [%s] ",
916 get_color_reset_code(), ref_name
[i
]);
920 /* header lines never need name */
921 show_one_commit(rev
[i
], 1);
930 for (i
= 0; i
< num_rev
; i
++)
940 /* Sort topologically */
941 sort_in_topological_order(&seen
, sort_order
);
943 /* Give names to commits */
944 if (!sha1_name
&& !no_name
)
945 name_commits(seen
, rev
, ref_name
, num_rev
);
947 all_mask
= ((1u << (REV_SHIFT
+ num_rev
)) - 1);
948 all_revs
= all_mask
& ~((1u << REV_SHIFT
) - 1);
950 for (struct commit_list
*l
= seen
; l
; l
= l
->next
) {
951 struct commit
*commit
= l
->item
;
952 int this_flag
= commit
->object
.flags
;
953 int is_merge_point
= ((this_flag
& all_revs
) == all_revs
);
955 shown_merge_point
|= is_merge_point
;
958 int is_merge
= !!(commit
->parents
&&
959 commit
->parents
->next
);
962 (this_flag
& (1u << REV_SHIFT
)))
964 if (!sparse
&& is_merge
&&
965 omit_in_dense(commit
, rev
, num_rev
))
967 for (i
= 0; i
< num_rev
; i
++) {
969 if (!(this_flag
& (1u << (i
+ REV_SHIFT
))))
973 else if (i
== head_at
)
982 mark
, get_color_reset_code());
986 show_one_commit(commit
, no_name
);
988 if (shown_merge_point
&& --extra
< 0)
995 for (size_t i
= 0; i
< ARRAY_SIZE(reflog_msg
); i
++)
997 free_commit_list(seen
);
998 free_commit_list(list
);