Skip to content

ace-design/git-merge-adv

Repository files navigation

Git Merge ADV

Table of Contents
  1. Project Description
  2. Getting Started
  3. Contacts
  4. Acknowledgments
  5. Licence

Project Description

Rationale

Source code merging has always been an issue for developers. When colloborating on complex projects, developers must inevitably use multiple branches, which is the cause for numerous merge conflicts. These conflicts often waste a lot of their time.

Existing 3-way merge algorithms developed by Git rely on textual difference, which often leads it to incorrectly resolve the conflicts or cause merge conflicts.

Other 3-way merge algorithms such as JDime or Spork take a strucutred approach which use Abstract Syntax Trees, however are limited in the scope in which they can be used.

As such, our purpose is to develop a new 3-way merge tool for Python and Java Source Code.

Developed Data Structure

Mainly focused on Java & Python code to develop a general data structure that can represent statically & dynamically typed languages.

We used the CST (Concrete Syntax Tree) generated by Tree-Sitter (for Java), and the AST (Abstract Syntax Tree) generated using Python's ast library to provide the prelimary code structures. We then queried the Syntax Trees to construct our Abstract Data Structure.

This is relevant to CompressedTree and MethodUnion tools.

Selective Set Union

Our tools use the following heuristics:

Built with:

  • Python

Getting Started

Required Modules

  • Before using any tool or any script, install all the dependencies using pipenv

    pipenv install
    
  • Then, start a pipenv shell from which you can navigate the project, and run any scripts:

    pipenv shell
    

Usage

  • The extracting-scripts directory contains all the tools needed to extract case studies from various github repositories
  • The merge-algorithms directory includes all the merge tools that were developed in this project. The two main tools being CompressedTree and MethodUnion.
  • The demos directory includes all the case studies that were tested, and the overall results obtained from this project. It also contains the next steps for the MethodUnion tool, that we couldn't yet get to.

Tool Prerequisites

Run Tools:

python3 <path to alg init.py> --left <left parent path> --right <right parent path> --base <base file path> --out <output file>
  • Assumption: Input files are of correct syntax. Tools will not work with incorrect syntax.

Git-Integration

  1. Create a .gitattributes file in your repo
  2. add following lines to it
*.java merge=gitadv
*.py merge=gitadv 
  1. Run command git config --global --edit
  2. Add following lines to config file
[merge "gitadv"]
name = gitadv
driver = python3 /path/to/repo/git-merge-adv/merge-algorithms/CompressedTree/init.py --left %A --right %B --base %O --output %A --file %P

Contacts

  • Sebastien Mosser - mossers@mcmaster.ca
  • Madhur Jain - 21112002mj@gmail.com
  • Nirmal Chaudhari - chaudn12@mcmaster.ca

Acknowledgements

Licence

Distributed under the MIT License. See LICENSE.txt for more information.

Releases

No releases published

Packages

No packages published

Languages