Example #1
0
        private void doCheckout(GitSharp.Core.Ref branch)
        {
            if (branch == null)
            {
                throw new ArgumentNullException("branch", "Cannot checkout; no HEAD advertised by remote");
            }
            var repo = Repository._internal_repo;

            if (!Constants.HEAD.Equals(branch.getName()))
            {
                RefUpdate u1 = repo.UpdateRef(Constants.HEAD);
                u1.disableRefLog();
                u1.link(branch.getName());
            }

            GitSharp.Core.Commit commit = repo.MapCommit(branch.ObjectId);
            RefUpdate            u      = repo.UpdateRef(Constants.HEAD);

            u.NewObjectId = commit.CommitId;
            u.forceUpdate();
            GitIndex index = new GitIndex(repo);

            GitSharp.Core.Tree tree = commit.TreeEntry;
            WorkDirCheckout    co   = new WorkDirCheckout(repo, repo.WorkingDirectory, index, tree);

            co.checkout();
            index.write();
        }