11 #include <InterfaceKit.h> 38 git_strarray array = {0};
39 array.count = files.size();
40 array.strings = (
char**) malloc(
sizeof(
char*) * array.count);
42 for (
int i=0; i<array.count; i++)
43 array.strings[i] = files[i];
69 git_repository *repo = NULL;
76 ret = git_repository_open(&repo, dirPath.String());
80 ret = git_repository_index(&index, repo);
84 ret = git_index_add_all(index, &array, 0, NULL, NULL);
88 ret = git_index_write(index);
94 git_index_free(index);
95 git_repository_free(repo);
97 git_libgit2_shutdown();
109 const git_error* err = giterr_last();
110 printf(
"Error %d : %s\n", err->klass, err->message);
112 BString buffer(
"Error : %s");
113 buffer.ReplaceFirst(
"%s", err->message);
114 BAlert* alert =
new BAlert(
"", buffer.String(),
"Cancel",
115 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
118 BString buffer(
"Files successfully added to the repository.");
119 BAlert* alert =
new BAlert(
"", buffer.String(),
"OK",
120 0, 0, B_WIDTH_AS_USUAL);
#define APP_SIGN
The Application signature.
BString fDirPath
The current directory where Init option is selected.
vector< char * > fFiles
The list of files to be added.
Add(BString, vector< char *>)
Add command constructor.
static int AddFiles(BString, vector< char *>)
Adds given files into git repository.
static git_strarray InitArray(vector< char *> files)
Initializes git_strarray.
Header file of Add command.
virtual void Execute()
Add command excution.
static void FreeArray(git_strarray)
Frees the allocated strings in git_strarray.