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

Added option to avoid replicating TFS merges during fetch #582

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions GitTfs/Commands/Init.cs
Expand Up @@ -119,6 +119,7 @@ private string[] BuildInitCommand()

private void GitTfsInit(string tfsUrl, string tfsRepositoryPath)
{
globals.Repository.ReplicateTfsMerges = initOptions.ReplicateTfsMerges;
globals.Repository.CreateTfsRemote(new RemoteInfo
{
Id = globals.RemoteId,
Expand Down
2 changes: 2 additions & 0 deletions GitTfs/Commands/InitOptions.cs
Expand Up @@ -27,6 +27,7 @@ public OptionSet OptionSet
{ "ignorecase=", "Ignore case in file paths (default: system default)",
v => GitInitIgnoreCase = ValidateIgnoreCaseValue(v) },
{"bare", "Clone the TFS repository in a bare git repository", v => IsBare = v != null},
{"m|replicateTfsMerges", "Mark TFS merge changesets as merge commits in git", v => ReplicateTfsMerges = v == null || v == "1"},
Copy link
Member

Choose a reason for hiding this comment

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

This branch changes the default from ReplicateTfsMerges = true to ReplicateTfsMerges = false. @ivan-danilov, @pmiossec - what do you think the default behavior should be?

Copy link
Member

Choose a reason for hiding this comment

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

I prefer default value to ReplicateTfsMerges = true...

Copy link
Member

Choose a reason for hiding this comment

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

That would have been my guess. If true is a reasonable default, let's rename the option --ignore-tfs-merges or --no-tfs-merges.

{"workspace=", "Set tfs workspace to a specific folder (a shorter path is better!)", v => WorkspacePath = v},
};
}
Expand Down Expand Up @@ -55,5 +56,6 @@ string ValidateIgnoreCaseValue(string v)
public object GitInitShared { get; set; }
public string GitInitAutoCrlf { get; set; }
public string GitInitIgnoreCase { get; set; }
public bool ReplicateTfsMerges { get; set; }
}
}
10 changes: 10 additions & 0 deletions GitTfs/Core/GitRepository.cs
Expand Up @@ -442,6 +442,16 @@ public bool WorkingCopyHasUnstagedOrUncommitedChanges
}
}

public bool ReplicateTfsMerges
{
get
{
string val = GetConfig("tfs.replicateTfsMerges");
Copy link
Member

Choose a reason for hiding this comment

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

This config value is in a different section that other global git-tfs settings. Please replace "tfs.replicateTfsMerges" with a constant, similar to other config keys in GitTfsConstants.

return val == null || val == "1";
}
set { SetConfig("tfs.replicateTfsMerges", value ? "1" : "0"); }
Copy link
Member

Choose a reason for hiding this comment

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

Let's make this boolean consistent (store "true" or "false" rather than "1" or "0") with the export-metadata option.

}

public void CopyBlob(string sha, string outputFile)
{
Blob blob;
Expand Down
2 changes: 1 addition & 1 deletion GitTfs/Core/GitTfsRemote.cs
Expand Up @@ -319,7 +319,7 @@ public IFetchResult FetchWithMerge(long mergeChangesetId, bool stopOnFailMergeCo
{
count++;
string parentCommitSha = null;
if (changeset.IsMergeChangeset && !ProcessMergeChangeset(changeset, stopOnFailMergeCommit, ref parentCommitSha))
if (Repository.ReplicateTfsMerges && changeset.IsMergeChangeset && !ProcessMergeChangeset(changeset, stopOnFailMergeCommit, ref parentCommitSha))
{
fetchResult.NewChangesetCount = count;
fetchResult.IsSuccess = false;
Expand Down
1 change: 1 addition & 0 deletions GitTfs/Core/IGitRepository.cs
Expand Up @@ -29,6 +29,7 @@ public interface IGitRepository : IGitHelpers
IGitTreeBuilder GetTreeBuilder(string commit);
IEnumerable<IGitChangedFile> GetChangedFiles(string from, string to);
bool WorkingCopyHasUnstagedOrUncommitedChanges { get; }
bool ReplicateTfsMerges { get; set; }
void CopyBlob(string sha, string outputFile);
GitCommit GetCommit(string commitish);
string GetCurrentCommit();
Expand Down