示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="committishOrBranchSpec"></param>
        /// <param name="name"></param>
        /// <param name="path"></param>
        /// <param name="isLocked"></param>
        /// <returns></returns>
        public virtual Worktree Add(string committishOrBranchSpec, string name, string path, bool isLocked)
        {
            if (string.Equals(committishOrBranchSpec, name))
            {
                // Proxy.git_worktree_add() creates a new branch of name = name, so if we want to checkout a given branch then the 'name' cannot be the same as the target branch
                return(null);
            }

            git_worktree_add_options options = new git_worktree_add_options
            {
                version = 1,
                locked  = Convert.ToInt32(isLocked)
            };

            using (var handle = Proxy.git_worktree_add(repo.Handle, name, path, options))
            {
                var worktree = new Worktree(
                    repo,
                    name,
                    Proxy.git_worktree_is_locked(handle));

                // switch the worktree to the target branch
                using (var repository = worktree.WorktreeRepository)
                {
                    Commands.Checkout(repository, committishOrBranchSpec);
                }
            }



            return(this[name]);
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="path"></param>
        /// <param name="isLocked"></param>
        public virtual Worktree Add(string name, string path, bool isLocked)
        {
            git_worktree_add_options options = new git_worktree_add_options
            {
                version = 1,
                locked  = Convert.ToInt32(isLocked)
            };

            using (var handle = Proxy.git_worktree_add(repo.Handle, name, path, options))
            {
                return(new Worktree(
                           repo,
                           name,
                           Proxy.git_worktree_is_locked(handle)));
            }
        }