How to implement merge conflict preview using libgit2? - libgit2

I'm trying to implement a content management website, in many ways, it's like a simplified github.
the version control and collaboration part is based on git using libgit2.
But I can't find how to implement merge conflict preview, that would tell an user if her change is clean to merge or not and which lines have conflict.
the example here https://github.com/libgit2/libgit2/blob/master/examples/merge.c
performs merging with the git_merge function, however, this function would directly alter the current index.
I also checked a github open source alternative, but I forgot its name now. That project used a library from the eclipse ide, which provides a conflict preview feature.
How should I implement this with libgit2 and is there an example code?

As you noted, the git_merge function mutates the working directory and the index. You can use the git_merge_commits function to do an in-memory merge of two commits and return the resulting index.
You can then iterate over the index looking for conflicts or simply call git_index_has_conflicts if you only want to know if conflicts exist.

Related

How do you modify an npm library you are using in your project?

I'm using ng-bootstrap in my Angular project.
The problem is that ng-bootstrap is still in its early stages and missing lots of functionality. I have added a simple feature within the code in my node_modules/#ng-bootstrap directory.
The trouble is that I worry that if/when there is an update to ng-bootstrap and I update my project with it, my local changes in the functionality will be overwritten and lost.
What are some techniques to deal with this problem?
You've effectively just created your own "branch" of that package. You could submit a pull request if the functionality is something that should be there for everyone. Since you have custom changes, you're responsible for making sure updates don't overwrite them.
If i needed to so something like this, i'd see if there was a way to implement the changes without modifying the ng-bootstrap files themselves. Without knowing what the change is, i can't say how that might be accomplished. One option there is to not use a package manager for that framework, or let the package manager get the "official" files, and then copy them somewhere else that you actually use. You're still responsible for making sure to merge changes in when the framework updates, but at least it won't be automatically overwritten.

IntelliJ: Search structurally in different projects

Structural search in IntelliJ IDEA is not only powerful, but also not trivial at all to get right. Now when I have created a working template of my own, I might want to use it in multiple projects.
I do not see a way to save globally. Is there anything I can do short of copying the relevant bits from one workspace.xml to another?
Unfortunatelly, it's not supported at the moment, please follow this feature request for updates.

Removing numerous annotations automatically in IntelliJ

I have a package that contains lots of classes, each having lots of annotations. Is there any way to delete all the annotations automatically, rather than manually deleting them one by one?
I'm using the latest version of IntelliJ IDEA. I cannot use search and replace, because there are a lot of different annotations.
IntelliJ has a feature called Structural Search and Replace. You could use it to find all annotations and replace with nothing. I have never really used this feature so can't offer you the exact search you need to use. The best I can offer is a link to the documentation for this feature. I am sure this feature can do what you want though:
http://www.jetbrains.com/idea/webhelp/structural-search-and-replace.html

Bazaar merge hook?

i want to run a batch file after a merge operation to resolve certain conflicts automatically.
any ideas?
post_merge_hook will work just fine but i didnt find any references for it existence
thanks
Gil Idelson
There is no post-merge hook in Bazaar. Your best bet is to make a shell alias or batch file which executes the merge and then your conflict resolution tool.
Another alternative is to create a plugin which registers a merge_file_content hook that controls how bzr merges specific files. Since bzr 2.4, there is bundled plugin called news_merge which demonstrates how this can be used. You may also want to read about hooks in the user guide.
Unless the standard merge algorithms really cannot handle your special files correctly, I would recommend the first option.

Is it possible to override the behavior of a merge module

Supposing I have a merge module that installs a file "MyFile.txt" to a certain location, and that I wish to use that merge module, however I want to supply a different copy of "MyFile.txt" from the one supplied with the merge module.
Is it possible to do this? (And for bonus points how can I do this using Wix)
Update: Roughly speaking MyFile.txt is part of a package up component of installable items that we provide to others, they then comine these components with their own to produce an installer.
In the ideal world they would only need to add new files to the output, however this is a replacement for an existing system where they currently have the ability to modify or even replace items (suce as MyFile.txt) in the end installer, and so without the ability to do the same with the merge module the migration path will be difficult.
The packaged up component doesn't need to be a merge module if there is a better solution, however merge modules seemed like the sensible choice and in all other respects provide a very nice re-usable package of installer logic.
It's possible but every technique that I know is a bit of a hack and doesn't scale very well. Can you tell me more about what type of file MyFile.txt is and what the intent of the different flavors of the file? Usually my goal is to never have the same filename twice ( darn component rules ) and then design variation points to support the needs. Sometimes upstream changes to the application are required to do this correctly.