TrackGit
ShowConflicts.cpp
Go to the documentation of this file.
1 
8 #include "ShowConflicts.h"
9 #include "../Utils.h"
10 
11 #include <InterfaceKit.h>
12 
13 #include <git2.h>
14 
15 
21  :
22  GitCommand()
23 {
24  fRepoPath = repoPath;
25 }
26 
27 
32 void
34 {
35  git_repository* repo;
36  git_index* index;
37  int ret = 0;
38 
39  // Init repo
40  ret = git_repository_open_ext(&repo, fRepoPath.String(), 0, NULL);
41  if (ret < 0)
42  goto ret;
43 
44  // Init index
45  ret = git_repository_index(&index, repo);
46  if (ret < 0)
47  goto ret;
48 
49  output_conflicts(index);
50 ret:
51  if (ret < 0) {
52  const git_error* er = giterr_last();
53  printf("Error %d : %s\n", er->klass, er->message);
54 
55  BString buffer("Error : %s");
56  buffer.ReplaceFirst("%s", er->message);
57  BAlert *alert = new BAlert("", buffer.String(), "Cancel",
58  0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
59  alert->Go();
60  }
61  git_repository_free(repo);
62  git_libgit2_shutdown();
63 }
void output_conflicts(git_index *index)
Shows conflicts in current repo index in a window.
Definition: Utils.cpp:248
BString fRepoPath
The repo path where ShowConflicts option is selected.
Definition: ShowConflicts.h:23
GitCommand Class.
Definition: GitCommand.h:20
Header file of ShowConflicts command.
virtual void Execute()
ShowConflicts command excution.
ShowConflicts(BString)
ShowConflicts command constructor.