diff --git a/GitTfs/Commands/Subtree.cs b/GitTfs/Commands/Subtree.cs index 7c2e9667..213a0a58 100644 --- a/GitTfs/Commands/Subtree.cs +++ b/GitTfs/Commands/Subtree.cs @@ -155,12 +155,11 @@ namespace Sep.Git.Tfs.Commands {2}", Prefix, remote.MaxCommitHash, msg); - List args = new List(){"subtree", "add", + _globals.Repository.CommandNoisy( + "subtree", "add", "--prefix=" + p, string.Format("-m {0}", msg), - remote.RemoteRef - }; - command(args); + remote.RemoteRef); //update the owner remote to point at the commit where the newly created subtree was merged. var commit = _globals.Repository.GetCurrentCommit(); @@ -184,8 +183,7 @@ namespace Sep.Git.Tfs.Commands if (result == GitTfsExitCodes.OK) { var p = Prefix.Replace(" ", "\\ "); - List args = new List(){ "subtree", "merge", "--prefix=" + p, remote.RemoteRef }; - command(args); + _globals.Repository.CommandNoisy("subtree", "merge", "--prefix=" + p, remote.RemoteRef); result = GitTfsExitCodes.OK; } @@ -197,10 +195,8 @@ namespace Sep.Git.Tfs.Commands ValidatePrefix(); var p = Prefix.Replace(" ", "\\ "); - List args = new List() { "subtree", "split", "--prefix=" + p, "-b", p }; - command(args); - args = new List() { "checkout", p }; - command(args); + _globals.Repository.CommandNoisy("subtree", "split", "--prefix=" + p, "-b", p); + _globals.Repository.CommandNoisy("checkout", p); //update subtree refs if needed var owners = _globals.Repository.GetLastParentTfsCommits("HEAD").Where(x => !x.Remote.IsSubtree && x.Remote.TfsRepositoryPath == null).ToList(); @@ -224,12 +220,5 @@ namespace Sep.Git.Tfs.Commands .WithRecommendation("Add the subtree using 'git tfs subtree add -p= [tfs-server] [tfs-repository]'"); } } - - - private void command(List args) - { - _stdout.WriteLine("git " + string.Join(" ", args)); - _globals.Repository.CommandNoisy(args.ToArray()); - } } } diff --git a/GitTfs/Core/TfsWriter.cs b/GitTfs/Core/TfsWriter.cs index 6a5d97f1..6f660f0d 100644 --- a/GitTfs/Core/TfsWriter.cs +++ b/GitTfs/Core/TfsWriter.cs @@ -23,15 +23,15 @@ namespace Sep.Git.Tfs.Core if (_globals.UserSpecifiedRemoteId != null) tfsParents = tfsParents.Where(changeset => changeset.Remote.Id == _globals.UserSpecifiedRemoteId); - return WriteWith(tfsParents.ToList(), write); + return WriteWith(tfsParents, write); } - private int WriteWith(List tfsParents, Func write) + private int WriteWith(IEnumerable tfsParents, Func write) { - switch (tfsParents.Count) + switch (tfsParents.Count()) { case 1: - var changeset = tfsParents[0]; + var changeset = tfsParents.First(); return write(changeset); case 0: _stdout.WriteLine("No TFS parents found!"); @@ -40,7 +40,7 @@ namespace Sep.Git.Tfs.Core //try looking for the non-subtree changesets if (tfsParents.Any(x => x.Remote.IsSubtree)) { - return WriteWith(tfsParents.Where(x => !x.Remote.IsSubtree).ToList(), write); + return WriteWith(tfsParents.Where(x => !x.Remote.IsSubtree), write); } _stdout.WriteLine("More than one parent found! Use -i to choose the correct parent from: ");