TrackGit
Commit.cpp
Go to the documentation of this file.
1 
8 #include "Commit.h"
9 #include "../UI/CommitWindow.h"
10 #include "../Utils.h"
11 
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <git2.h>
15 
16 
21 Commit::Commit(BString repo)
22 {
23  fRepo = repo;
24  fCommitWindow = NULL;
25 }
26 
27 
31 void
33 {
34 }
35 
36 
43 {
44  if (fCommitWindow == NULL)
46  return fCommitWindow;
47 }
48 
49 
56 int
57 Commit::DoCommit(BString repoPath, BString message)
58 {
59  git_repository* repo;
60  git_index* index;
61  int ret = 0;
62 
63  git_libgit2_init();
64 
65  // Init repo
66  ret = git_repository_open_ext(&repo, repoPath.String(), 0, NULL);
67  if (ret < 0)
68  return ret;
69 
70  // Init index
71  ret = git_repository_index(&index, repo);
72  if (ret < 0)
73  goto ret;
74 
75  ret = create_commit(repo, index, message.String());
76 ret:
77  git_repository_free(repo);
78 
79  git_libgit2_shutdown();
80 
81  return ret;
82 }
Header file of Commit command.
virtual TrackGitWindow * GetWindow()
This returns pointer to the commit window.
Definition: Commit.cpp:42
virtual void Execute()
Commit command execution.
Definition: Commit.cpp:32
int create_commit(git_repository *repo, git_index *index, const char *message)
Creates a commit on given repo, index and message.
Definition: Utils.cpp:186
Commit(BString)
Commit class constructor.
Definition: Commit.cpp:21
The Commit Window class.
Definition: CommitWindow.h:26
TrackGitWindow * fCommitWindow
The Commit Window.
Definition: Commit.h:26
static int DoCommit(BString, BString)
This function commits to given repo with given message.
Definition: Commit.cpp:57
BString fRepo
The repo/directory where command is called.
Definition: Commit.h:22
The TrackGit Window class.