/* * Look at a cache entry at "i" and see if it is not conflicting, * conflicting and we are willing to handle, or conflicting and * we are unable to handle, and return the determination in *type. * Return the cache index to be looked at next, by skipping the * stages we have already looked at in this invocation of this * function. */ static int check_one_conflict(int i, int *type) { const struct cache_entry *e = active_cache[i]; if (!ce_stage(e)) { *type = RESOLVED; return i + 1; } *type = PUNTED; while (i < active_nr && ce_stage(active_cache[i]) == 1) i++; /* Only handle regular files with both stages #2 and #3 */ if (i + 1 < active_nr) { const struct cache_entry *e2 = active_cache[i]; const struct cache_entry *e3 = active_cache[i + 1]; if (ce_stage(e2) == 2 && ce_stage(e3) == 3 && ce_same_name(e, e3) && S_ISREG(e2->ce_mode) && S_ISREG(e3->ce_mode)) *type = THREE_STAGED; } /* Skip the entries with the same name */ while (i < active_nr && ce_same_name(e, active_cache[i])) i++; return i; }
static int find_conflict(struct string_list *conflict) { int i; if (read_cache() < 0) return error("Could not read index"); for (i = 0; i+1 < active_nr; i++) { struct cache_entry *e2 = active_cache[i]; struct cache_entry *e3 = active_cache[i+1]; if (ce_stage(e2) == 2 && ce_stage(e3) == 3 && ce_same_name(e2, e3) && S_ISREG(e2->ce_mode) && S_ISREG(e3->ce_mode)) { string_list_insert((const char *)e2->name, conflict); i++; /* skip over both #2 and #3 */ } } return 0; }
static void prepare_show_merge(struct rev_info *revs) { struct commit_list *bases; struct commit *head, *other; unsigned char sha1[20]; const char **prune = NULL; int i, prune_num = 1; /* counting terminating NULL */ if (get_sha1("HEAD", sha1) || !(head = lookup_commit(sha1))) die("--merge without HEAD?"); if (get_sha1("MERGE_HEAD", sha1) || !(other = lookup_commit(sha1))) die("--merge without MERGE_HEAD?"); add_pending_object(revs, &head->object, "HEAD"); add_pending_object(revs, &other->object, "MERGE_HEAD"); bases = get_merge_bases(head, other, 1); add_pending_commit_list(revs, bases, UNINTERESTING); free_commit_list(bases); head->object.flags |= SYMMETRIC_LEFT; if (!active_nr) read_cache(); for (i = 0; i < active_nr; i++) { struct cache_entry *ce = active_cache[i]; if (!ce_stage(ce)) continue; if (ce_path_match(ce, revs->prune_data)) { prune_num++; prune = xrealloc(prune, sizeof(*prune) * prune_num); prune[prune_num-2] = ce->name; prune[prune_num-1] = NULL; } while ((i+1 < active_nr) && ce_same_name(ce, active_cache[i+1])) i++; } revs->prune_data = prune; revs->limited = 1; }