| 1071 | } |
| 1072 | |
| 1073 | static int process_ranges_merge_commit(struct rev_info *rev, struct commit *commit, |
| 1074 | struct line_log_data *range) |
| 1075 | { |
| 1076 | struct line_log_data **cand; |
| 1077 | struct commit_list *p; |
| 1078 | int i; |
| 1079 | int nparents = commit_list_count(commit->parents); |
| 1080 | int ret; |
| 1081 | |
| 1082 | if (nparents > 1 && rev->first_parent_only) |
| 1083 | nparents = 1; |
| 1084 | |
| 1085 | CALLOC_ARRAY(cand, nparents); |
| 1086 | |
| 1087 | for (p = commit->parents, i = 0; |
| 1088 | p && i < nparents; |
| 1089 | p = p->next, i++) { |
| 1090 | struct commit *parent = p->item; |
| 1091 | struct diff_queue_struct diffqueue = DIFF_QUEUE_INIT; |
| 1092 | int changed; |
| 1093 | |
| 1094 | queue_diffs(range, &rev->diffopt, &diffqueue, commit, parent); |
| 1095 | |
| 1096 | changed = process_all_files(&cand[i], rev, &diffqueue, range); |
| 1097 | diff_queue_clear(&diffqueue); |
| 1098 | if (!changed) { |
| 1099 | /* |
| 1100 | * This parent can take all the blame, so we |
| 1101 | * don't follow any other path in history |
| 1102 | */ |
| 1103 | add_line_range(rev, parent, cand[i]); |
| 1104 | commit_list_free(commit->parents); |
| 1105 | commit_list_append(parent, &commit->parents); |
| 1106 | |
| 1107 | ret = 0; |
| 1108 | goto out; |
| 1109 | } |
| 1110 | } |
| 1111 | |
| 1112 | /* |
| 1113 | * No single parent took the blame. We add the candidates |
| 1114 | * from the above loop to the parents. |
| 1115 | */ |
| 1116 | for (p = commit->parents, i = 0; |
| 1117 | p && i < nparents; |
| 1118 | p = p->next, i++) |
| 1119 | add_line_range(rev, p->item, cand[i]); |
| 1120 | |
| 1121 | ret = 1; |
| 1122 | |
| 1123 | out: |
| 1124 | clear_commit_line_range(rev, commit); |
| 1125 | for (i = 0; i < nparents; i++) { |
| 1126 | if (!cand[i]) |
| 1127 | continue; |
| 1128 | line_log_data_clear(cand[i]); |
| 1129 | free(cand[i]); |
| 1130 | } |
no test coverage detected