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();
        }
Example #2
0
        /// <summary>
        /// Check out this branch into the working directory and have HEAD point to it.
        /// </summary>
        public void Checkout()
        {
            var       db = _repo._internal_repo;
            RefUpdate u  = db.UpdateRef(Constants.HEAD);

            u.link(RefName);
            Reset(ResetBehavior.Hard);
        }
Example #3
0
        private void writeSymref(String src, String dst)
        {
            RefUpdate u = db.UpdateRef(src);

            switch (u.link(dst))
            {
            case RefUpdate.RefUpdateResult.NEW:
            case RefUpdate.RefUpdateResult.FORCED:
            case RefUpdate.RefUpdateResult.NO_CHANGE:
                break;

            default:
                Assert.Fail("link " + src + " to " + dst);
                break;
            }
        }