-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Writing conflicting git_merge_trees result index? #1567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think you'll have to do it manually. You can get index entries for your conflicting files using I hope this helps you. |
Thanks for the quick reply! However, I've already figured out how to write the OURS and THEIRS files; that wasn't my question. I'll clarify. With git, if I run into a merge conflict, the merge doesn't finish. I can see the conflicting files by calling Right now I'm trying to figure out how to 'save' the state of the merge in progress, and I've been assuming it involves updating the index. Here's what I've tried so far:
I must be missing something - any thoughts? |
Ever figure this out suskin? I have exactly the same problem. |
Sorry for the late reply - but writing Check out #1007 for more information. This is a PR, it's not merged, so it's probably got plenty of bugs. Note, though, that this is what is shipping in unnamed commercial IDEs to do a merge of branches. |
Thanks for the info. So I tried copying entries from the merged index into the repo's index with: for (unsigned int i = 0; i < git_index_entrycount(MergedIndex); ++i) {
const git_index_entry *entry = git_index_get_byindex(MergedIndex, 0);
if (git_index_entry_stage(entry) > 0) {
continue;
}
GIT_CALL(git_index_add(RepoIndex, entry));
}
// Add all conflicts.
GitConflictIterator ConflictIterator;
GIT_CALL(git_index_conflict_iterator_new(&ConflictIterator, MergedIndex));
for(;;) {
const git_index_entry *ancestor;
const git_index_entry *ours;
const git_index_entry *theirs;
if (git_index_conflict_next(&ancestor, &ours, &theirs, ConflictIterator) !=
0) {
break;
}
GIT_CALL(git_index_conflict_add(RepoIndex, ancestor, ours, theirs));
}
GIT_CALL(git_index_write(RepoIndex)); Is this the right approach? I realize the problem suskin was having with |
You can use |
Hey guys,
I'm working on implementing a pull-like operation which, on encountering merge conflicts, always writes THEIRS and OURS files to disk for the user to use to resolve the conflicts. After an attempted merge, I'd like to be able to easily record which files are conflicting so that it's easy to complete the merge after the user has intervened, similar to how git handles this situation. What is the recommended way of doing this?
I was expecting to be able to write the result from git_merge_trees to disk to accomplish this, but passing it to git_index_write_tree_to fails because it won't write an index to disk if it contains conflicts. Should I be modifying the index in some fashion before writing it out, or is there another approach I should take?
Thanks for the help.
The text was updated successfully, but these errors were encountered: