Skip to content

Expand Merge API. #643

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

Merged
merged 2 commits into from
Apr 9, 2014
Merged

Expand Merge API. #643

merged 2 commits into from
Apr 9, 2014

Conversation

jamill
Copy link
Member

@jamill jamill commented Mar 4, 2014

This includes several updates to the Merge API:

  • Refactoring of the merge logic to support different merge workflows.
  • Introduce Pull functionality.
  • Introduce Merge Branch functionality.
  • Adds MergeOptions param, to specify the type of merge and whether to commit it or not
  • Also adds a simple repository to perform merges in, simplying test logic.

Feedback on the API and / or testing approach would be welcome. I was trying to see if including a simple pre-populated merge repository would simplify the testing logic, and I think it does.

TODO:

  • Pull API is still being worked on - need at least more options.
  • Hide unnecessary Properties (e.g. Network.FetchHeads)
  • Incorporate reflog updates
  • Incorporate updates to allow for merging into an orphaned branch
  • Incorporate updates to allow for pulling into an orphaned branch
  • Get tests passing


// Verify that there is a staged entry.
Assert.Equal(1, repoStatus.Count());
Assert.Equal(FileStatus.Staged, repo.Index.RetrieveStatus("a.txt"));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ethomson - This test is currently failing because the entry is Modified. I think core git stages the uncommitted changes. Could this be a slight behavior difference in lg2?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should, too. Possible caching issue with the cache? Are we caching the cache? Hehe.

I was going to step through this, but it looks like the tests aren't quite cloning the merge repository correctly?

            string path = CloneMergeTestRepo();
            using (var repo = new Repository(path))

is failing for me because it can't open the path (it's not fully qualified for me). Travis is having the same issue, it looks like.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it's not the fully qualifiedness. That repo you checked in had line ending changes applied!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, so I think this is a typo of a.txt where it should be looking for staged changes to b.txt. The normal_merge branch only changes b.txt from the common ancestor:

C:\Git\libgit2sharp\LibGit2Sharp.Tests\bin\Debug\TestRepos\b4df86fb\merge_testrepo_wd>git merge --no-commit normal_merge
Automatic merge went well; stopped before committing as requested

C:\Git\libgit2sharp\LibGit2Sharp.Tests\bin\Debug\TestRepos\b4df86fb\merge_testrepo_wd>git status
On branch master
All conflicts fixed but you are still merging.
  (use "git commit" to conclude merge)

Changes to be committed:

        modified:   b.txt

@jamill
Copy link
Member Author

jamill commented Mar 4, 2014

@ethomson Thanks for your assistance with the wrong test logic and getting the test resources set up correctly!

@nulltoken
Copy link
Member

Wat? "Expand Merge API"? My dear @jamill, you should work on this 😉 This should be more like "Bless the world with PULL" or something extatic.

😍

}
}

[Fact(Skip = "Skipping due to libgit2 issue")]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failing due to libgit2/libgit2#2236

@jamill
Copy link
Member Author

jamill commented Apr 3, 2014

@nulltoken There is a lot of stuff in here, I think we should start winding this down. This includes features requested in #663, #662, #633.

@Aimeast
Copy link
Contributor

Aimeast commented Apr 3, 2014

@jamill @nulltoken also #628

public enum FastForwardStrategy
{
/// <summary>
/// Default fast-forward strategy.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we actually describe what the default is? (ie. Favor fast-forward when possible, otherwise create a merge commit)

@nulltoken
Copy link
Member

@jamill Fantastic work 💖 ‼️

@nulltoken
Copy link
Member

@jamill @nulltoken also #628

@Aimeast Are you sure? I'm not sure to see how this PR resolves this CanMerge()-like request.

@jamill @ethomson Is there a way to perform a --dry-run merge (ie. without modifying the index not the workdir)?

@jamill
Copy link
Member Author

jamill commented Apr 4, 2014

@Aimeast Are you sure? I'm not sure to see how this PR resolves this CanMerge() -like request.

This PR does not get you all the way there. I believe that libgit2 exposes the necessary knobs, we just need to hook them up.

@@ -336,6 +321,48 @@ static void DoFetch(RemoteSafeHandle remoteHandle, FetchOptions options, Signatu
}

/// <summary>
/// Pull changes from the configured upstream remote and branch into the current branch.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we also update those xml docs according to what has been done for Merge()

ie. into the current branch -> into the branch pointed at by HEAD.

@nulltoken
Copy link
Member

@jamill Sorry for those additional comments ^^.

Once you're done with them, could you please also update the native binaries with the latest version and squash?

I'm eager to merge this! ❤️

@jamill
Copy link
Member Author

jamill commented Apr 7, 2014

libgit2 has been updated to latest and this this has been squashed into 2 commits. Thanks for the review!

@nulltoken
Copy link
Member

@jamill Could you please also update the NativeMethods.git_submodule_reload() signature (cf. libgit2/libgit2@a15c780#diff-d8ffd9d3638b8260f19e92c71e2ffbcaR504)?

jamill added 2 commits April 9, 2014 15:50
merging branches.

This includes a refactoring of the merge logic to support the new
scenarios. New functionality includes:

- Deprecate Network.Fetchheads, Repository.MergeHeads as these should be
  internal only.

- Introduce ability to pull the configured upstream branch for the current
  branch

- Introduce ability to merge a branch into the current branch.

- Introduce options to control merge behavior. The current exposed options
  include whether to commit the merge commit and the allowed merge types.
@nulltoken nulltoken merged commit c7e11bb into libgit2:vNext Apr 9, 2014
@nulltoken nulltoken added this to the v0.17.0 milestone Apr 10, 2014
@nulltoken
Copy link
Member

@jamill Thank you so much for this 💎

💖

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants