git-tfs icon indicating copy to clipboard operation
git-tfs copied to clipboard

Invalid selective merges instead of cherry picks

Open mwisnicki opened this issue 9 years ago • 12 comments

I have converted repository with all branches using --with-branches. Unfortunately the end result is that partial merges from TFS (merge of specific revisions) are converted to git merges which completely break history and ability to merge and diff branches with git.

mwisnicki avatar Jul 21 '15 09:07 mwisnicki

Could you explain more explicitly in which way it "break history and ability to merge and diff branches with git"?

pmiossec avatar Jul 21 '15 09:07 pmiossec

Consider this example:

  1. branch A is created from Trunk
  2. file foo is added to A
  3. someone merges single revision from A to Trunk Now after conversion, git thinks that A is fully merged into Trunk (up to the merge commit). When you try merging Trunk into A, git removes foo since it thinks it was removed from Trunk by merge commit from point 3.

mwisnicki avatar Jul 21 '15 09:07 mwisnicki

Could you test this branch : https://github.com/git-tfs/git-tfs/compare/master...pmiossec:manage_partial_merge

or at least these binaries: https://ci.appveyor.com/api/buildjobs/1g2ekv9lg02ha3gt/artifacts/git-tfs_fac25f51825c9e8d5c264f0631b508dc8d209020.zip

and tell me if it solve your problem?

pmiossec avatar Jul 21 '15 10:07 pmiossec

Thanks for quick fix. I am going to test it now but it will take some time to clone the repo again. I'll report results tomorrow.

mwisnicki avatar Jul 21 '15 11:07 mwisnicki

ok thanks.

pmiossec avatar Jul 21 '15 11:07 pmiossec

BTW can you add a list of merged commits (as git hashes) to commit message ? Maybe something like:

git-tfs-cherry-picks: <commit1> <commit2> ...

or maybe one per line.

mwisnicki avatar Jul 21 '15 11:07 mwisnicki

BTW can you add a list of merged commits (as git hashes) to commit message ?

That's something to do much more complicated that what is managed at the moment. If you need such a thing, I encourage you to dig in the code and propose a pull request. I won't fix all the broken choice of TFVC architecture using the awful tfs api ;)

pmiossec avatar Jul 21 '15 12:07 pmiossec

No difference :( According to Partial documentation it's about whether particular changeset was partially merged, not whether merge includes all changesets from source branch. Perhaps MergeSources object contains right information... Is there a tool that can show complete TFS changeset metadata ?

mwisnicki avatar Jul 22 '15 17:07 mwisnicki

I looked a bit more into this and it seems that there is no metadata in TFVC that distinguishes full merge from a partial one. Instead, I'm detecting cherry picks based on non-empty list of merge candidates. Some initial code is in my repository: https://github.com/git-tfs/git-tfs/compare/master...mwisnicki:manage_partial_merge

mwisnicki avatar Sep 04 '15 15:09 mwisnicki

Sadly my use of GetMergeCandidates to achieve this is wrong. There is no way to look for merge candidates at specific changeset - it always shows status for latest versions of branches.

mwisnicki avatar Sep 08 '15 08:09 mwisnicki

@mwisnicki Did you ever find a solution to this issue? I'm facing this exact issue right now. I've migrated some quite big TFS repos and we did "selective merges" on a regular basis. So the history of our git repo is quite a mess unfortunately.

nk111 avatar Mar 26 '21 13:03 nk111

@nk111 unfortunately no. I had no need to use TFS since then

mwisnicki avatar Mar 26 '21 17:03 mwisnicki