Skip to content
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

Fix missing merge parent #628

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions GitTfs.VsCommon/TfsHelper.Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public virtual int FindMergeChangesetParent(string path, long targetChangeset, G
{
var targetVersion = new ChangesetVersionSpec((int)targetChangeset);
var mergeInfo = VersionControl.QueryMerges(null, null, path, targetVersion, targetVersion, targetVersion, RecursionType.Full);
if (mergeInfo.Length == 0) return -1;
Copy link

Choose a reason for hiding this comment

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

technically you should just return targetChangeset. the subsequent FindCommitByChangesetId will not find any and fall through accordingly. the real fix is avoiding the empty mergeInfo.Max(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. I wasn’t sure how things worked and what should be returned, but returning an error indication and then testing for it seemed like a sure cure. But I like your method better.

return mergeInfo.Max(x => x.SourceVersion);
}

Expand Down
10 changes: 10 additions & 0 deletions GitTfs/Core/GitTfsRemote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,16 @@ public IFetchResult FetchWithMerge(long mergeChangesetId, bool stopOnFailMergeCo
private bool ProcessMergeChangeset(ITfsChangeset changeset, bool stopOnFailMergeCommit, ref string parentCommit)
Copy link

Choose a reason for hiding this comment

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

this file can be left unchanged

{
var parentChangesetId = Tfs.FindMergeChangesetParent(TfsRepositoryPath, changeset.Summary.ChangesetId, this);
if (parentChangesetId < 1) // Handle missing merge parent info
{
if (stopOnFailMergeCommit)
{
return false;
}
stdout.WriteLine("warning: this changeset " + changeset.Summary.ChangesetId +
" is a merge changeset. But git-tfs is unable to determine the parent changeset.");
return true;
}
var shaParent = Repository.FindCommitHashByChangesetId(parentChangesetId);
if (shaParent == null)
shaParent = FindMergedRemoteAndFetch(parentChangesetId, stopOnFailMergeCommit);
Expand Down