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
39a3cb6bba
commit
19610c1c51
1 file changed
+3
-10
+3
-10
@@ -71,8 +71,7 @@ void _error(const int shouldDebug, const int condition, const char *type, const
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void _warn(const int condition, const char *file, const int line, const char *function,
|
void _warn(const int condition, const char *file, const int line, const char *function, const char *message, ...) { // use for warnings that should always be shown
|
||||||
const char *message, ...) { // use for warnings that should always be shown
|
|
||||||
if (condition) {
|
if (condition) {
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
@@ -83,9 +82,7 @@ void _warn(const int condition, const char *file, const int line, const char *fu
|
|||||||
int h, m, s;
|
int h, m, s;
|
||||||
getCurrentTime(&h, &m, &s);
|
getCurrentTime(&h, &m, &s);
|
||||||
|
|
||||||
fprintf(stdout,
|
fprintf(stdout, "\e[0;33m[WARNING -- %d:%d:%d] From file %s line %d function %s:\e[0m\n", h, m, s, file, line, function);
|
||||||
"\e[0;33m[WARNING -- %d:%d:%d] From file %s line %d function %s:\e[0m\n",
|
|
||||||
h, m, s, file, line, function);
|
|
||||||
|
|
||||||
vfprintf(stdout, message, args);
|
vfprintf(stdout, message, args);
|
||||||
|
|
||||||
@@ -141,8 +138,7 @@ static void slowGitWarning(struct timespec start, int *wasShown) {
|
|||||||
struct timespec now;
|
struct timespec now;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
double elapsed = (double)(now.tv_sec - start.tv_sec)
|
double elapsed = (double)(now.tv_sec - start.tv_sec) + (double)(now.tv_nsec - start.tv_nsec) / 1e9;
|
||||||
+ (double)(now.tv_nsec - start.tv_nsec) / 1e9;
|
|
||||||
|
|
||||||
warn(elapsed > 0.3, "Git operations are taking too much time. You drive might be slow. Please do not stop the program.");
|
warn(elapsed > 0.3, "Git operations are taking too much time. You drive might be slow. Please do not stop the program.");
|
||||||
if (elapsed > 0.3) {
|
if (elapsed > 0.3) {
|
||||||
@@ -218,19 +214,16 @@ void gitBackupUpdate(const char *path, const char *vault, const char *signatureN
|
|||||||
error(return_code, "program", "Failed to open Git repository\n%s", git_error_last()->message);
|
error(return_code, "program", "Failed to open Git repository\n%s", git_error_last()->message);
|
||||||
slowGitWarning(start, &slowGitWarningAlreadyShown);
|
slowGitWarning(start, &slowGitWarningAlreadyShown);
|
||||||
|
|
||||||
|
|
||||||
/* Get the index */
|
/* Get the index */
|
||||||
return_code = git_repository_index(&index, repo);
|
return_code = git_repository_index(&index, repo);
|
||||||
error(return_code, "program", "Failed to get Git index\n%s", git_error_last()->message);
|
error(return_code, "program", "Failed to get Git index\n%s", git_error_last()->message);
|
||||||
slowGitWarning(start, &slowGitWarningAlreadyShown);
|
slowGitWarning(start, &slowGitWarningAlreadyShown);
|
||||||
|
|
||||||
|
|
||||||
/* git add . */
|
/* git add . */
|
||||||
return_code = git_index_add_all(index, NULL, 0, NULL, NULL);
|
return_code = git_index_add_all(index, NULL, 0, NULL, NULL);
|
||||||
error(return_code, "program", "Failed to add files\n%s", git_error_last()->message);
|
error(return_code, "program", "Failed to add files\n%s", git_error_last()->message);
|
||||||
slowGitWarning(start, &slowGitWarningAlreadyShown);
|
slowGitWarning(start, &slowGitWarningAlreadyShown);
|
||||||
|
|
||||||
|
|
||||||
return_code = git_index_write(index);
|
return_code = git_index_write(index);
|
||||||
error(return_code, "program", "Failed to write index\n%s", git_error_last()->message);
|
error(return_code, "program", "Failed to write index\n%s", git_error_last()->message);
|
||||||
slowGitWarning(start, &slowGitWarningAlreadyShown);
|
slowGitWarning(start, &slowGitWarningAlreadyShown);
|
||||||
|
|||||||
Reference in new issue
Block a user