7 int save_commit_buffer
= 1;
12 * the number of children of the associated commit
13 * that also occur in the list being sorted.
15 unsigned int indegree
;
18 * reference to original list item that we will re-use
21 struct commit_list
* list_item
;
25 const char *commit_type
= "commit";
32 { "raw", 1, CMIT_FMT_RAW
},
33 { "medium", 1, CMIT_FMT_MEDIUM
},
34 { "short", 1, CMIT_FMT_SHORT
},
35 { "email", 1, CMIT_FMT_EMAIL
},
36 { "full", 5, CMIT_FMT_FULL
},
37 { "fuller", 5, CMIT_FMT_FULLER
},
38 { "oneline", 1, CMIT_FMT_ONELINE
},
41 enum cmit_fmt
get_commit_format(const char *arg
)
46 return CMIT_FMT_DEFAULT
;
49 for (i
= 0; i
< ARRAY_SIZE(cmt_fmts
); i
++) {
50 if (!strncmp(arg
, cmt_fmts
[i
].n
, cmt_fmts
[i
].cmp_len
))
54 die("invalid --pretty format: %s", arg
);
57 static struct commit
*check_commit(struct object
*obj
,
58 const unsigned char *sha1
,
61 if (obj
->type
!= OBJ_COMMIT
) {
63 error("Object %s is a %s, not a commit",
64 sha1_to_hex(sha1
), typename(obj
->type
));
67 return (struct commit
*) obj
;
70 struct commit
*lookup_commit_reference_gently(const unsigned char *sha1
,
73 struct object
*obj
= deref_tag(parse_object(sha1
), NULL
, 0);
77 return check_commit(obj
, sha1
, quiet
);
80 struct commit
*lookup_commit_reference(const unsigned char *sha1
)
82 return lookup_commit_reference_gently(sha1
, 0);
85 struct commit
*lookup_commit(const unsigned char *sha1
)
87 struct object
*obj
= lookup_object(sha1
);
89 struct commit
*ret
= alloc_commit_node();
90 created_object(sha1
, &ret
->object
);
91 ret
->object
.type
= OBJ_COMMIT
;
95 obj
->type
= OBJ_COMMIT
;
96 return check_commit(obj
, sha1
, 0);
99 static unsigned long parse_commit_date(const char *buf
)
103 if (memcmp(buf
, "author", 6))
105 while (*buf
++ != '\n')
107 if (memcmp(buf
, "committer", 9))
109 while (*buf
++ != '>')
111 date
= strtoul(buf
, NULL
, 10);
112 if (date
== ULONG_MAX
)
117 static struct commit_graft
**commit_graft
;
118 static int commit_graft_alloc
, commit_graft_nr
;
120 static int commit_graft_pos(const unsigned char *sha1
)
124 hi
= commit_graft_nr
;
126 int mi
= (lo
+ hi
) / 2;
127 struct commit_graft
*graft
= commit_graft
[mi
];
128 int cmp
= hashcmp(sha1
, graft
->sha1
);
139 int register_commit_graft(struct commit_graft
*graft
, int ignore_dups
)
141 int pos
= commit_graft_pos(graft
->sha1
);
147 free(commit_graft
[pos
]);
148 commit_graft
[pos
] = graft
;
153 if (commit_graft_alloc
<= ++commit_graft_nr
) {
154 commit_graft_alloc
= alloc_nr(commit_graft_alloc
);
155 commit_graft
= xrealloc(commit_graft
,
156 sizeof(*commit_graft
) *
159 if (pos
< commit_graft_nr
)
160 memmove(commit_graft
+ pos
+ 1,
162 (commit_graft_nr
- pos
- 1) *
163 sizeof(*commit_graft
));
164 commit_graft
[pos
] = graft
;
168 struct commit_graft
*read_graft_line(char *buf
, int len
)
170 /* The format is just "Commit Parent1 Parent2 ...\n" */
172 struct commit_graft
*graft
= NULL
;
174 if (buf
[len
-1] == '\n')
176 if (buf
[0] == '#' || buf
[0] == '\0')
178 if ((len
+ 1) % 41) {
180 error("bad graft data: %s", buf
);
184 i
= (len
+ 1) / 41 - 1;
185 graft
= xmalloc(sizeof(*graft
) + 20 * i
);
186 graft
->nr_parent
= i
;
187 if (get_sha1_hex(buf
, graft
->sha1
))
189 for (i
= 40; i
< len
; i
+= 41) {
192 if (get_sha1_hex(buf
+ i
+ 1, graft
->parent
[i
/41]))
198 int read_graft_file(const char *graft_file
)
200 FILE *fp
= fopen(graft_file
, "r");
204 while (fgets(buf
, sizeof(buf
), fp
)) {
205 /* The format is just "Commit Parent1 Parent2 ...\n" */
206 int len
= strlen(buf
);
207 struct commit_graft
*graft
= read_graft_line(buf
, len
);
210 if (register_commit_graft(graft
, 1))
211 error("duplicate graft data: %s", buf
);
217 static void prepare_commit_graft(void)
219 static int commit_graft_prepared
;
222 if (commit_graft_prepared
)
224 graft_file
= get_graft_file();
225 read_graft_file(graft_file
);
226 /* make sure shallows are read */
227 is_repository_shallow();
228 commit_graft_prepared
= 1;
231 static struct commit_graft
*lookup_commit_graft(const unsigned char *sha1
)
234 prepare_commit_graft();
235 pos
= commit_graft_pos(sha1
);
238 return commit_graft
[pos
];
241 int write_shallow_commits(int fd
, int use_pack_protocol
)
244 for (i
= 0; i
< commit_graft_nr
; i
++)
245 if (commit_graft
[i
]->nr_parent
< 0) {
247 sha1_to_hex(commit_graft
[i
]->sha1
);
249 if (use_pack_protocol
)
250 packet_write(fd
, "shallow %s", hex
);
259 int unregister_shallow(const unsigned char *sha1
)
261 int pos
= commit_graft_pos(sha1
);
264 if (pos
+ 1 < commit_graft_nr
)
265 memcpy(commit_graft
+ pos
, commit_graft
+ pos
+ 1,
266 sizeof(struct commit_graft
*)
267 * (commit_graft_nr
- pos
- 1));
272 int parse_commit_buffer(struct commit
*item
, void *buffer
, unsigned long size
)
275 char *bufptr
= buffer
;
276 unsigned char parent
[20];
277 struct commit_list
**pptr
;
278 struct commit_graft
*graft
;
281 if (item
->object
.parsed
)
283 item
->object
.parsed
= 1;
285 if (tail
<= bufptr
+ 5 || memcmp(bufptr
, "tree ", 5))
286 return error("bogus commit object %s", sha1_to_hex(item
->object
.sha1
));
287 if (tail
<= bufptr
+ 45 || get_sha1_hex(bufptr
+ 5, parent
) < 0)
288 return error("bad tree pointer in commit %s",
289 sha1_to_hex(item
->object
.sha1
));
290 item
->tree
= lookup_tree(parent
);
293 bufptr
+= 46; /* "tree " + "hex sha1" + "\n" */
294 pptr
= &item
->parents
;
296 graft
= lookup_commit_graft(item
->object
.sha1
);
297 while (bufptr
+ 48 < tail
&& !memcmp(bufptr
, "parent ", 7)) {
298 struct commit
*new_parent
;
300 if (tail
<= bufptr
+ 48 ||
301 get_sha1_hex(bufptr
+ 7, parent
) ||
303 return error("bad parents in commit %s", sha1_to_hex(item
->object
.sha1
));
307 new_parent
= lookup_commit(parent
);
309 pptr
= &commit_list_insert(new_parent
, pptr
)->next
;
315 struct commit
*new_parent
;
316 for (i
= 0; i
< graft
->nr_parent
; i
++) {
317 new_parent
= lookup_commit(graft
->parent
[i
]);
320 pptr
= &commit_list_insert(new_parent
, pptr
)->next
;
324 item
->date
= parse_commit_date(bufptr
);
326 if (track_object_refs
) {
328 struct commit_list
*p
;
329 struct object_refs
*refs
= alloc_object_refs(n_refs
);
331 refs
->ref
[i
++] = &item
->tree
->object
;
332 for (p
= item
->parents
; p
; p
= p
->next
)
333 refs
->ref
[i
++] = &p
->item
->object
;
334 set_object_refs(&item
->object
, refs
);
340 int parse_commit(struct commit
*item
)
347 if (item
->object
.parsed
)
349 buffer
= read_sha1_file(item
->object
.sha1
, type
, &size
);
351 return error("Could not read %s",
352 sha1_to_hex(item
->object
.sha1
));
353 if (strcmp(type
, commit_type
)) {
355 return error("Object %s not a commit",
356 sha1_to_hex(item
->object
.sha1
));
358 ret
= parse_commit_buffer(item
, buffer
, size
);
359 if (save_commit_buffer
&& !ret
) {
360 item
->buffer
= buffer
;
367 struct commit_list
*commit_list_insert(struct commit
*item
, struct commit_list
**list_p
)
369 struct commit_list
*new_list
= xmalloc(sizeof(struct commit_list
));
370 new_list
->item
= item
;
371 new_list
->next
= *list_p
;
376 void free_commit_list(struct commit_list
*list
)
379 struct commit_list
*temp
= list
;
385 struct commit_list
* insert_by_date(struct commit
*item
, struct commit_list
**list
)
387 struct commit_list
**pp
= list
;
388 struct commit_list
*p
;
389 while ((p
= *pp
) != NULL
) {
390 if (p
->item
->date
< item
->date
) {
395 return commit_list_insert(item
, pp
);
399 void sort_by_date(struct commit_list
**list
)
401 struct commit_list
*ret
= NULL
;
403 insert_by_date((*list
)->item
, &ret
);
404 *list
= (*list
)->next
;
409 struct commit
*pop_most_recent_commit(struct commit_list
**list
,
412 struct commit
*ret
= (*list
)->item
;
413 struct commit_list
*parents
= ret
->parents
;
414 struct commit_list
*old
= *list
;
416 *list
= (*list
)->next
;
420 struct commit
*commit
= parents
->item
;
421 parse_commit(commit
);
422 if (!(commit
->object
.flags
& mark
)) {
423 commit
->object
.flags
|= mark
;
424 insert_by_date(commit
, list
);
426 parents
= parents
->next
;
431 void clear_commit_marks(struct commit
*commit
, unsigned int mark
)
433 struct commit_list
*parents
;
435 commit
->object
.flags
&= ~mark
;
436 parents
= commit
->parents
;
438 struct commit
*parent
= parents
->item
;
440 /* Have we already cleared this? */
441 if (mark
& parent
->object
.flags
)
442 clear_commit_marks(parent
, mark
);
443 parents
= parents
->next
;
448 * Generic support for pretty-printing the header
450 static int get_one_line(const char *msg
, unsigned long len
)
465 static int is_rfc2047_special(char ch
)
467 return ((ch
& 0x80) || (ch
== '=') || (ch
== '?') || (ch
== '_'));
470 static int add_rfc2047(char *buf
, const char *line
, int len
)
474 static const char q_utf8
[] = "=?utf-8?q?";
476 for (i
= needquote
= 0; !needquote
&& i
< len
; i
++) {
477 unsigned ch
= line
[i
];
481 (ch
== '=' && line
[i
+1] == '?'))
485 return sprintf(buf
, "%.*s", len
, line
);
487 memcpy(bp
, q_utf8
, sizeof(q_utf8
)-1);
488 bp
+= sizeof(q_utf8
)-1;
489 for (i
= 0; i
< len
; i
++) {
490 unsigned ch
= line
[i
] & 0xFF;
491 if (is_rfc2047_special(ch
)) {
492 sprintf(bp
, "=%02X", ch
);
505 static int add_user_info(const char *what
, enum cmit_fmt fmt
, char *buf
,
506 const char *line
, int relative_date
)
512 const char *filler
= " ";
514 if (fmt
== CMIT_FMT_ONELINE
)
516 date
= strchr(line
, '>');
519 namelen
= ++date
- line
;
520 time
= strtoul(date
, &date
, 10);
521 tz
= strtol(date
, NULL
, 10);
523 if (fmt
== CMIT_FMT_EMAIL
) {
524 char *name_tail
= strchr(line
, '<');
525 int display_name_length
;
528 while (line
< name_tail
&& isspace(name_tail
[-1]))
530 display_name_length
= name_tail
- line
;
532 strcpy(buf
, "From: ");
534 ret
+= add_rfc2047(buf
+ ret
, line
, display_name_length
);
535 memcpy(buf
+ ret
, name_tail
, namelen
- display_name_length
);
536 ret
+= namelen
- display_name_length
;
540 ret
= sprintf(buf
, "%s: %.*s%.*s\n", what
,
541 (fmt
== CMIT_FMT_FULLER
) ? 4 : 0,
542 filler
, namelen
, line
);
545 case CMIT_FMT_MEDIUM
:
546 ret
+= sprintf(buf
+ ret
, "Date: %s\n",
547 show_date(time
, tz
, relative_date
));
550 ret
+= sprintf(buf
+ ret
, "Date: %s\n",
551 show_rfc2822_date(time
, tz
));
553 case CMIT_FMT_FULLER
:
554 ret
+= sprintf(buf
+ ret
, "%sDate: %s\n", what
,
555 show_date(time
, tz
, relative_date
));
564 static int is_empty_line(const char *line
, int *len_p
)
567 while (len
&& isspace(line
[len
-1]))
573 static int add_merge_info(enum cmit_fmt fmt
, char *buf
, const struct commit
*commit
, int abbrev
)
575 struct commit_list
*parent
= commit
->parents
;
578 if ((fmt
== CMIT_FMT_ONELINE
) || (fmt
== CMIT_FMT_EMAIL
) ||
579 !parent
|| !parent
->next
)
582 offset
= sprintf(buf
, "Merge:");
585 struct commit
*p
= parent
->item
;
586 const char *hex
= NULL
;
589 hex
= find_unique_abbrev(p
->object
.sha1
, abbrev
);
591 hex
= sha1_to_hex(p
->object
.sha1
);
592 dots
= (abbrev
&& strlen(hex
) != 40) ? "..." : "";
593 parent
= parent
->next
;
595 offset
+= sprintf(buf
+ offset
, " %s%s", hex
, dots
);
597 buf
[offset
++] = '\n';
601 static char *get_header(const struct commit
*commit
, const char *key
)
603 int key_len
= strlen(key
);
604 const char *line
= commit
->buffer
;
607 const char *eol
= strchr(line
, '\n'), *next
;
612 eol
= line
+ strlen(line
);
616 if (!strncmp(line
, key
, key_len
) && line
[key_len
] == ' ') {
617 int len
= eol
- line
- key_len
;
618 char *ret
= xmalloc(len
);
619 memcpy(ret
, line
+ key_len
+ 1, len
- 1);
627 static char *logmsg_reencode(const struct commit
*commit
)
631 char *output_encoding
= (git_log_output_encoding
632 ? git_log_output_encoding
633 : git_commit_encoding
);
635 if (!output_encoding
)
636 output_encoding
= "utf-8";
637 else if (!*output_encoding
)
639 encoding
= get_header(commit
, "encoding");
640 if (!encoding
|| !strcmp(encoding
, output_encoding
)) {
644 out
= reencode_string(commit
->buffer
, output_encoding
, encoding
);
651 unsigned long pretty_print_commit(enum cmit_fmt fmt
,
652 const struct commit
*commit
,
654 char *buf
, unsigned long space
,
655 int abbrev
, const char *subject
,
656 const char *after_subject
,
659 int hdr
= 1, body
= 0;
660 unsigned long offset
= 0;
662 int parents_shown
= 0;
663 const char *msg
= commit
->buffer
;
664 int plain_non_ascii
= 0;
665 char *reencoded
= logmsg_reencode(commit
);
670 if (fmt
== CMIT_FMT_ONELINE
|| fmt
== CMIT_FMT_EMAIL
)
673 /* After-subject is used to pass in Content-Type: multipart
674 * MIME header; in that case we do not have to do the
675 * plaintext content type even if the commit message has
676 * non 7-bit ASCII character. Otherwise, check if we need
677 * to say this is not a 7-bit ASCII.
679 if (fmt
== CMIT_FMT_EMAIL
&& !after_subject
) {
682 for (in_body
= i
= 0; (ch
= msg
[i
]) && i
< len
; i
++) {
684 /* author could be non 7-bit ASCII but
685 * the log may be so; skip over the
689 i
+ 1 < len
&& msg
[i
+1] == '\n')
692 else if (ch
& 0x80) {
700 const char *line
= msg
;
701 int linelen
= get_one_line(msg
, len
);
707 * We want some slop for indentation and a possible
708 * final "...". Thus the "+ 20".
710 if (offset
+ linelen
+ 20 > space
) {
711 memcpy(buf
+ offset
, " ...\n", 8);
721 if ((fmt
!= CMIT_FMT_ONELINE
) && !subject
)
722 buf
[offset
++] = '\n';
725 if (fmt
== CMIT_FMT_RAW
) {
726 memcpy(buf
+ offset
, line
, linelen
);
730 if (!memcmp(line
, "parent ", 7)) {
732 die("bad parent line in commit");
736 if (!parents_shown
) {
737 offset
+= add_merge_info(fmt
, buf
+ offset
,
743 * MEDIUM == DEFAULT shows only author with dates.
744 * FULL shows both authors but not dates.
745 * FULLER shows both authors and dates.
747 if (!memcmp(line
, "author ", 7))
748 offset
+= add_user_info("Author", fmt
,
752 if (!memcmp(line
, "committer ", 10) &&
753 (fmt
== CMIT_FMT_FULL
|| fmt
== CMIT_FMT_FULLER
))
754 offset
+= add_user_info("Commit", fmt
,
764 if (is_empty_line(line
, &linelen
)) {
769 if (fmt
== CMIT_FMT_SHORT
)
774 int slen
= strlen(subject
);
775 memcpy(buf
+ offset
, subject
, slen
);
777 offset
+= add_rfc2047(buf
+ offset
, line
, linelen
);
780 memset(buf
+ offset
, ' ', indent
);
781 memcpy(buf
+ offset
+ indent
, line
, linelen
);
782 offset
+= linelen
+ indent
;
784 buf
[offset
++] = '\n';
785 if (fmt
== CMIT_FMT_ONELINE
)
787 if (subject
&& plain_non_ascii
) {
788 static const char header
[] =
789 "Content-Type: text/plain; charset=UTF-8\n"
790 "Content-Transfer-Encoding: 8bit\n";
791 memcpy(buf
+ offset
, header
, sizeof(header
)-1);
792 offset
+= sizeof(header
)-1;
795 int slen
= strlen(after_subject
);
796 if (slen
> space
- offset
- 1)
797 slen
= space
- offset
- 1;
798 memcpy(buf
+ offset
, after_subject
, slen
);
800 after_subject
= NULL
;
804 while (offset
&& isspace(buf
[offset
-1]))
806 /* Make sure there is an EOLN for the non-oneline case */
807 if (fmt
!= CMIT_FMT_ONELINE
)
808 buf
[offset
++] = '\n';
810 * make sure there is another EOLN to separate the headers from whatever
811 * body the caller appends if we haven't already written a body
813 if (fmt
== CMIT_FMT_EMAIL
&& !body
)
814 buf
[offset
++] = '\n';
821 struct commit
*pop_commit(struct commit_list
**stack
)
823 struct commit_list
*top
= *stack
;
824 struct commit
*item
= top
? top
->item
: NULL
;
833 int count_parents(struct commit
* commit
)
836 struct commit_list
* parents
= commit
->parents
;
837 for (count
= 0; parents
; parents
= parents
->next
,count
++)
842 void topo_sort_default_setter(struct commit
*c
, void *data
)
847 void *topo_sort_default_getter(struct commit
*c
)
853 * Performs an in-place topological sort on the list supplied.
855 void sort_in_topological_order(struct commit_list
** list
, int lifo
)
857 sort_in_topological_order_fn(list
, lifo
, topo_sort_default_setter
,
858 topo_sort_default_getter
);
861 void sort_in_topological_order_fn(struct commit_list
** list
, int lifo
,
862 topo_sort_set_fn_t setter
,
863 topo_sort_get_fn_t getter
)
865 struct commit_list
* next
= *list
;
866 struct commit_list
* work
= NULL
, **insert
;
867 struct commit_list
** pptr
= list
;
868 struct sort_node
* nodes
;
869 struct sort_node
* next_nodes
;
872 /* determine the size of the list */
880 /* allocate an array to help sort the list */
881 nodes
= xcalloc(count
, sizeof(*nodes
));
882 /* link the list to the array */
886 next_nodes
->list_item
= next
;
887 setter(next
->item
, next_nodes
);
891 /* update the indegree */
894 struct commit_list
* parents
= next
->item
->parents
;
896 struct commit
* parent
=parents
->item
;
897 struct sort_node
* pn
= (struct sort_node
*) getter(parent
);
901 parents
=parents
->next
;
908 * tips are nodes not reachable from any other node in the list
910 * the tips serve as a starting set for the work queue.
915 struct sort_node
* node
= (struct sort_node
*) getter(next
->item
);
917 if (node
->indegree
== 0) {
918 insert
= &commit_list_insert(next
->item
, insert
)->next
;
923 /* process the list in topological order */
927 struct commit
* work_item
= pop_commit(&work
);
928 struct sort_node
* work_node
= (struct sort_node
*) getter(work_item
);
929 struct commit_list
* parents
= work_item
->parents
;
932 struct commit
* parent
=parents
->item
;
933 struct sort_node
* pn
= (struct sort_node
*) getter(parent
);
937 * parents are only enqueued for emission
938 * when all their children have been emitted thereby
939 * guaranteeing topological order.
944 insert_by_date(parent
, &work
);
946 commit_list_insert(parent
, &work
);
949 parents
=parents
->next
;
952 * work_item is a commit all of whose children
953 * have already been emitted. we can emit it now.
955 *pptr
= work_node
->list_item
;
956 pptr
= &(*pptr
)->next
;
958 setter(work_item
, NULL
);
963 /* merge-rebase stuff */
965 /* bits #0..15 in revision.h */
966 #define PARENT1 (1u<<16)
967 #define PARENT2 (1u<<17)
968 #define STALE (1u<<18)
969 #define RESULT (1u<<19)
971 static struct commit
*interesting(struct commit_list
*list
)
974 struct commit
*commit
= list
->item
;
976 if (commit
->object
.flags
& STALE
)
983 static struct commit_list
*merge_bases(struct commit
*one
, struct commit
*two
)
985 struct commit_list
*list
= NULL
;
986 struct commit_list
*result
= NULL
;
989 /* We do not mark this even with RESULT so we do not
990 * have to clean it up.
992 return commit_list_insert(one
, &result
);
997 one
->object
.flags
|= PARENT1
;
998 two
->object
.flags
|= PARENT2
;
999 insert_by_date(one
, &list
);
1000 insert_by_date(two
, &list
);
1002 while (interesting(list
)) {
1003 struct commit
*commit
;
1004 struct commit_list
*parents
;
1005 struct commit_list
*n
;
1008 commit
= list
->item
;
1013 flags
= commit
->object
.flags
& (PARENT1
| PARENT2
| STALE
);
1014 if (flags
== (PARENT1
| PARENT2
)) {
1015 if (!(commit
->object
.flags
& RESULT
)) {
1016 commit
->object
.flags
|= RESULT
;
1017 insert_by_date(commit
, &result
);
1019 /* Mark parents of a found merge stale */
1022 parents
= commit
->parents
;
1024 struct commit
*p
= parents
->item
;
1025 parents
= parents
->next
;
1026 if ((p
->object
.flags
& flags
) == flags
)
1029 p
->object
.flags
|= flags
;
1030 insert_by_date(p
, &list
);
1034 /* Clean up the result to remove stale ones */
1035 list
= result
; result
= NULL
;
1037 struct commit_list
*n
= list
->next
;
1038 if (!(list
->item
->object
.flags
& STALE
))
1039 insert_by_date(list
->item
, &result
);
1046 struct commit_list
*get_merge_bases(struct commit
*one
,
1050 const unsigned all_flags
= (PARENT1
| PARENT2
| STALE
| RESULT
);
1051 struct commit_list
*list
;
1052 struct commit
**rslt
;
1053 struct commit_list
*result
;
1056 result
= merge_bases(one
, two
);
1059 if (!result
|| !result
->next
) {
1061 clear_commit_marks(one
, all_flags
);
1062 clear_commit_marks(two
, all_flags
);
1067 /* There are more than one */
1074 rslt
= xcalloc(cnt
, sizeof(*rslt
));
1075 for (list
= result
, i
= 0; list
; list
= list
->next
)
1076 rslt
[i
++] = list
->item
;
1077 free_commit_list(result
);
1079 clear_commit_marks(one
, all_flags
);
1080 clear_commit_marks(two
, all_flags
);
1081 for (i
= 0; i
< cnt
- 1; i
++) {
1082 for (j
= i
+1; j
< cnt
; j
++) {
1083 if (!rslt
[i
] || !rslt
[j
])
1085 result
= merge_bases(rslt
[i
], rslt
[j
]);
1086 clear_commit_marks(rslt
[i
], all_flags
);
1087 clear_commit_marks(rslt
[j
], all_flags
);
1088 for (list
= result
; list
; list
= list
->next
) {
1089 if (rslt
[i
] == list
->item
)
1091 if (rslt
[j
] == list
->item
)
1097 /* Surviving ones in rslt[] are the independent results */
1099 for (i
= 0; i
< cnt
; i
++) {
1101 insert_by_date(rslt
[i
], &result
);
1107 int in_merge_bases(struct commit
*rev1
, struct commit
*rev2
)
1109 struct commit_list
*bases
, *b
;
1112 bases
= get_merge_bases(rev1
, rev2
, 1);
1113 for (b
= bases
; b
; b
= b
->next
) {
1114 if (!hashcmp(rev1
->object
.sha1
, b
->item
->object
.sha1
)) {
1120 free_commit_list(bases
);