11 #include <InterfaceKit.h> 55 unsigned int is_merge,
void* payload_v) {
58 strcpy(payload->
branch, name);
59 memcpy(&payload->
branch_oid, oid,
sizeof(git_oid));
76 git_repository* repo = NULL;
82 err = git_repository_open(&repo, p->
path);
86 printf(
"Getting remote\n");
87 err = git_remote_lookup(&remote, repo,
"origin");
89 BString buffer(
"Error : No remote found.");
90 BAlert *alert =
new BAlert(
"", buffer.String(),
"Cancel",
91 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
96 printf(
"Fetching...\n");
99 err = git_remote_fetch(remote, NULL, NULL, NULL);
103 err = git_remote_fetch(remote, NULL, NULL, NULL);
110 git_annotated_commit* heads[1];
111 err = git_annotated_commit_lookup(&heads[0], repo, &payload.
branch_oid);
117 git_merge_analysis_t merge_analysis_t;
118 git_merge_preference_t merge_preference_t;
119 err = git_merge_analysis(&merge_analysis_t, &merge_preference_t,
120 repo, (
const git_annotated_commit**)&heads[0], 1);
122 if (merge_analysis_t & GIT_MERGE_ANALYSIS_UP_TO_DATE) {
123 BString buffer(
"Repository up to date.");
124 BAlert *alert =
new BAlert(
"", buffer.String(),
"OK",
125 0, 0, B_WIDTH_AS_USUAL);
128 }
else if (merge_analysis_t & GIT_MERGE_ANALYSIS_FASTFORWARD) {
132 (merge_analysis_t & GIT_MERGE_ANALYSIS_UNBORN));
134 }
else if (merge_analysis_t & GIT_MERGE_ANALYSIS_NORMAL) {
137 git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
138 git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
140 merge_opts.file_flags = GIT_MERGE_FILE_STYLE_DIFF3;
142 checkout_opts.checkout_strategy = GIT_CHECKOUT_FORCE |
143 GIT_CHECKOUT_ALLOW_CONFLICTS;
145 err = git_merge(repo,
146 (
const git_annotated_commit **)&heads[0], 1,
147 &merge_opts, &checkout_opts);
154 err = git_repository_index(&index, repo);
158 if (git_index_has_conflicts(index)) {
166 printf(
"Merge made\n");
171 const git_error* er = giterr_last();
172 printf(
"Error %d : %s\n", er->klass, er->message);
174 BString buffer(
"Error : %s");
175 buffer.ReplaceFirst(
"%s", er->message);
176 BAlert *alert =
new BAlert(
"", buffer.String(),
"Cancel",
177 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
181 git_repository_free(repo);
182 git_libgit2_shutdown();
Pull(BString)
Pull command constructor.
Payload to search for merge branch.
void output_conflicts(git_index *index)
Shows conflicts in current repo index in a window.
virtual void Quit()
The function to Quit the window.
virtual void Execute()
This is where actual calls to libgit2 will go.
int create_commit(git_repository *repo, git_index *index, const char *message)
Creates a commit on given repo, index and message.
virtual TrackGitWindow * GetWindow()
This returns pointer to the Pull window.
static pthread_t DoPull(PullWindow *, const char *)
This spawns thread to perform pull over given repo.
int fetchhead_ref_cb(const char *name, const char *url, const git_oid *oid, unsigned int is_merge, void *payload_v)
This function gets the branch to be merged.
BString fRepo
The repository path where Pull option is selected.
void * DoPullThread(void *arg)
This does git pull on given repository.
TrackGitWindow * fPullWindow
Pull Window.
Header file of Pull command.
The TrackGit Window class.
void SetText(const char *)
This function sets texts of the textview within window.
int perform_fastforward(git_repository *repo, const git_oid *target_oid, int is_unborn)
This performs fastforward on given repo, branch id.
Parameters to pass to pull thread.