mirror of
https://github.com/tomasriveral/NoteWrapper.git
synced 2026-10-10 17:03:04 +02:00
fix: clang format
This commit is contained in:
1 parent
518d4fd09c
commit
df0301fdcd
3 files changed
+11
-57
No files matched your search
+1
-6
@@ -101,12 +101,7 @@ int main(int argc, char *argv[]) {
|
|||||||
const char *error_ptr = cJSON_GetErrorPtr();
|
const char *error_ptr = cJSON_GetErrorPtr();
|
||||||
|
|
||||||
if (error_ptr) {
|
if (error_ptr) {
|
||||||
error(
|
error(1, "program", "JSON parse error near: %.30s", error_ptr);
|
||||||
1,
|
|
||||||
"program",
|
|
||||||
"JSON parse error near: %.30s",
|
|
||||||
error_ptr
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
free(data);
|
free(data);
|
||||||
|
|||||||
+9
-50
@@ -121,7 +121,8 @@ void ensureGitDirectory(const char *path, const char *vault, const char *signatu
|
|||||||
int git_repo_error_code = git_repository_open(&repo, fullPath);
|
int git_repo_error_code = git_repository_open(&repo, fullPath);
|
||||||
if (git_repo_error_code) { // error (most probably that the git repo wasn't initialized)
|
if (git_repo_error_code) { // error (most probably that the git repo wasn't initialized)
|
||||||
int git_init_error_code = git_repository_init(&repo, fullPath, 0); // the 0 indicates that the directory isn't bare. See https://libgit2.org/docs/reference/main/repository/git_repository_init.html
|
int git_init_error_code = git_repository_init(&repo, fullPath, 0); // the 0 indicates that the directory isn't bare. See https://libgit2.org/docs/reference/main/repository/git_repository_init.html
|
||||||
error(git_init_error_code, "program", "git initialization didn't worked. Error code : %d\nSee https://libgit2.org/docs/reference/main/repository/git_repository_init.html for documentation\n\n%s", git_init_error_code, git_error_last()->message);
|
error(git_init_error_code, "program", "git initialization didn't worked. Error code : %d\nSee https://libgit2.org/docs/reference/main/repository/git_repository_init.html for documentation\n\n%s",
|
||||||
|
git_init_error_code, git_error_last()->message);
|
||||||
debug("git repo %s was initialized.", fullPath);
|
debug("git repo %s was initialized.", fullPath);
|
||||||
|
|
||||||
// we need to setup the .gitignore
|
// we need to setup the .gitignore
|
||||||
@@ -196,33 +197,16 @@ void gitBackupUpdate(const char *path, const char *vault, const char *signatureN
|
|||||||
} else {
|
} else {
|
||||||
git_oid head_oid;
|
git_oid head_oid;
|
||||||
|
|
||||||
return_code = git_reference_name_to_id(
|
return_code = git_reference_name_to_id(&head_oid, repo, "HEAD");
|
||||||
&head_oid,
|
|
||||||
repo,
|
|
||||||
"HEAD"
|
|
||||||
);
|
|
||||||
error(return_code, "program", "Failed to get HEAD\n%s", git_error_last()->message);
|
error(return_code, "program", "Failed to get HEAD\n%s", git_error_last()->message);
|
||||||
|
|
||||||
return_code = git_commit_lookup(
|
return_code = git_commit_lookup(&head_commit, repo, &head_oid);
|
||||||
&head_commit,
|
|
||||||
repo,
|
|
||||||
&head_oid
|
|
||||||
);
|
|
||||||
error(return_code, "program", "Failed to lookup HEAD commit\n%s", git_error_last()->message);
|
error(return_code, "program", "Failed to lookup HEAD commit\n%s", git_error_last()->message);
|
||||||
|
|
||||||
return_code = git_commit_tree(
|
return_code = git_commit_tree(&head_tree, head_commit);
|
||||||
&head_tree,
|
|
||||||
head_commit
|
|
||||||
);
|
|
||||||
error(return_code, "program", "Failed to get HEAD tree\n%s", git_error_last()->message);
|
error(return_code, "program", "Failed to get HEAD tree\n%s", git_error_last()->message);
|
||||||
|
|
||||||
return_code = git_diff_tree_to_index(
|
return_code = git_diff_tree_to_index(&diff, repo, head_tree, index, NULL);
|
||||||
&diff,
|
|
||||||
repo,
|
|
||||||
head_tree,
|
|
||||||
index,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
error(return_code, "program", "Failed to create diff\n%s", git_error_last()->message);
|
error(return_code, "program", "Failed to create diff\n%s", git_error_last()->message);
|
||||||
|
|
||||||
@@ -243,39 +227,14 @@ void gitBackupUpdate(const char *path, const char *vault, const char *signatureN
|
|||||||
error(return_code, "program", "Failed to lookup tree\n%s", git_error_last()->message);
|
error(return_code, "program", "Failed to lookup tree\n%s", git_error_last()->message);
|
||||||
|
|
||||||
/* Author/committer */
|
/* Author/committer */
|
||||||
return_code = git_signature_now(
|
return_code = git_signature_now(&signature, signatureName, signatureEmail);
|
||||||
&signature,
|
|
||||||
signatureName,
|
|
||||||
signatureEmail
|
|
||||||
);
|
|
||||||
error(return_code, "program", "Failed to create signature\n%s", git_error_last()->message);
|
error(return_code, "program", "Failed to create signature\n%s", git_error_last()->message);
|
||||||
|
|
||||||
/* Create commit */
|
/* Create commit */
|
||||||
if (git_repository_head_unborn(repo)) {
|
if (git_repository_head_unborn(repo)) {
|
||||||
return_code = git_commit_create_v(
|
return_code = git_commit_create_v(&commit_id, repo, "HEAD", signature, signature, NULL, commitMsg, tree, 0);
|
||||||
&commit_id,
|
|
||||||
repo,
|
|
||||||
"HEAD",
|
|
||||||
signature,
|
|
||||||
signature,
|
|
||||||
NULL,
|
|
||||||
commitMsg,
|
|
||||||
tree,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
return_code = git_commit_create_v(
|
return_code = git_commit_create_v(&commit_id, repo, "HEAD", signature, signature, NULL, commitMsg, tree, 1, head_commit);
|
||||||
&commit_id,
|
|
||||||
repo,
|
|
||||||
"HEAD",
|
|
||||||
signature,
|
|
||||||
signature,
|
|
||||||
NULL,
|
|
||||||
commitMsg,
|
|
||||||
tree,
|
|
||||||
1,
|
|
||||||
head_commit
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
error(return_code, "program", "Failed to create commit\n%s", git_error_last()->message);
|
error(return_code, "program", "Failed to create commit\n%s", git_error_last()->message);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -6,6 +6,7 @@
|
|||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ftw.h>
|
#include <ftw.h>
|
||||||
|
#include <git2.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <ncurses.h>
|
#include <ncurses.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
@@ -17,7 +18,6 @@
|
|||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <git2.h>
|
|
||||||
|
|
||||||
#ifndef VERSION
|
#ifndef VERSION
|
||||||
#define VERSION "dev"
|
#define VERSION "dev"
|
||||||
|
|||||||
Reference in new issue
Block a user