9 #include "../UI/SwitchBranchWindow.h" 45 git_branch_iterator* iterator;
52 ret = git_repository_open_ext(&repo, repoPath.String(), 0, NULL);
56 ret = git_branch_iterator_new(&iterator, repo, GIT_BRANCH_LOCAL);
60 while (git_branch_next(&ref, &type, iterator) == 0)
61 branches.push_back(git_reference_shorthand(ref));
90 git_object* tree = NULL;
91 git_checkout_options
opts;
96 ret = git_repository_open_ext(&repo, repoPath.String(), 0, NULL);
100 git_checkout_init_options(&
opts, GIT_CHECKOUT_OPTIONS_VERSION);
102 ret = git_revparse_single(&tree, repo, branchName.String());
106 ret = git_checkout_tree(repo, tree, &
opts);
110 BString ref(
"refs/heads/%s");
111 ref.ReplaceFirst(
"%s", branchName.String());
112 ret = git_repository_set_head(repo, ref.String());
114 git_repository_free(repo);
116 git_libgit2_shutdown();
virtual TrackGitWindow * GetWindow()
This returns pointer to the Switch Branch window.
Status Options structure.
static int GetBranches(BString, vector< BString > &)
This function gets all the branche names in given repository.
The Switch Branch Window class.
virtual void Execute()
SwitchBranch command execution.
static int DoSwitchBranch(BString, BString)
This function creates a new branch in repo with given name.
TrackGitWindow * fSwitchBranchWindow
The Switch Branch Window.
Header file of Switch Branch command.
SwitchBranch(BString)
SwitchBranch class constructor.
The TrackGit Window class.
BString fRepo
The repo/directory where command is called.