MCPcopy Create free account
hub / github.com/git/git / cherry_pick_list

Function cherry_pick_list

revision.c:1217–1293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1215}
1216
1217static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
1218{
1219 struct commit_list *p;
1220 int left_count = 0, right_count = 0;
1221 int left_first;
1222 struct patch_ids ids;
1223 unsigned cherry_flag;
1224
1225 /* First count the commits on the left and on the right */
1226 for (p = list; p; p = p->next) {
1227 struct commit *commit = p->item;
1228 unsigned flags = commit->object.flags;
1229 if (flags & BOUNDARY)
1230 ;
1231 else if (flags & SYMMETRIC_LEFT)
1232 left_count++;
1233 else
1234 right_count++;
1235 }
1236
1237 if (!left_count || !right_count)
1238 return;
1239
1240 left_first = left_count < right_count;
1241 init_patch_ids(revs->repo, &ids);
1242 ids.diffopts.pathspec = revs->diffopt.pathspec;
1243
1244 /* Compute patch-ids for one side */
1245 for (p = list; p; p = p->next) {
1246 struct commit *commit = p->item;
1247 unsigned flags = commit->object.flags;
1248
1249 if (flags & BOUNDARY)
1250 continue;
1251 /*
1252 * If we have fewer left, left_first is set and we omit
1253 * commits on the right branch in this loop. If we have
1254 * fewer right, we skip the left ones.
1255 */
1256 if (left_first != !!(flags & SYMMETRIC_LEFT))
1257 continue;
1258 add_commit_patch_id(commit, &ids);
1259 }
1260
1261 /* either cherry_mark or cherry_pick are true */
1262 cherry_flag = revs->cherry_mark ? PATCHSAME : SHOWN;
1263
1264 /* Check the other side */
1265 for (p = list; p; p = p->next) {
1266 struct commit *commit = p->item;
1267 struct patch_id *id;
1268 unsigned flags = commit->object.flags;
1269
1270 if (flags & BOUNDARY)
1271 continue;
1272 /*
1273 * If we have fewer left, left_first is set and we omit
1274 * commits on the left branch in this loop.

Callers 1

limit_listFunction · 0.85

Calls 5

init_patch_idsFunction · 0.85
add_commit_patch_idFunction · 0.85
patch_id_iter_firstFunction · 0.85
patch_id_iter_nextFunction · 0.85
free_patch_idsFunction · 0.85

Tested by

no test coverage detected