mirror of
https://github.com/tomasriveral/NoteWrapper.git
synced 2026-10-10 08:55:22 +02:00
fix: clang format
This commit is contained in:
1 parent
39a3cb6bba
commit
19610c1c51
1 file changed
+20
-27
+20
-27
@@ -71,27 +71,24 @@ void _error(const int shouldDebug, const int condition, const char *type, const
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
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
|
||||
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
|
||||
if (condition) {
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
|
||||
va_list args;
|
||||
va_start(args, message);
|
||||
va_list args;
|
||||
va_start(args, message);
|
||||
|
||||
int h, m, s;
|
||||
getCurrentTime(&h, &m, &s);
|
||||
int h, m, s;
|
||||
getCurrentTime(&h, &m, &s);
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
vfprintf(stdout, message, args);
|
||||
vfprintf(stdout, message, args);
|
||||
|
||||
fprintf(stdout, "\e[0m\n");
|
||||
fprintf(stdout, "\e[0m\n");
|
||||
|
||||
va_end(args);
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,18 +134,17 @@ static void ensureDir(const char *path, const int shouldDebug) {
|
||||
}
|
||||
|
||||
static void slowGitWarning(struct timespec start, int *wasShown) {
|
||||
if (!*wasShown) {
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
if (!*wasShown) {
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
|
||||
double elapsed = (double)(now.tv_sec - start.tv_sec)
|
||||
+ (double)(now.tv_nsec - start.tv_nsec) / 1e9;
|
||||
double elapsed = (double)(now.tv_sec - start.tv_sec) + (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.");
|
||||
if (elapsed > 0.3) {
|
||||
*wasShown = 1;
|
||||
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) {
|
||||
*wasShown = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ensureGitDirectory(const char *path, const char *vault, const char *signatureName, const char *signatureEmail, const int shouldDebug) {
|
||||
@@ -218,23 +214,20 @@ 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);
|
||||
slowGitWarning(start, &slowGitWarningAlreadyShown);
|
||||
|
||||
|
||||
/* Get the index */
|
||||
return_code = git_repository_index(&index, repo);
|
||||
error(return_code, "program", "Failed to get Git index\n%s", git_error_last()->message);
|
||||
slowGitWarning(start, &slowGitWarningAlreadyShown);
|
||||
|
||||
|
||||
/* git add . */
|
||||
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);
|
||||
slowGitWarning(start, &slowGitWarningAlreadyShown);
|
||||
|
||||
|
||||
return_code = git_index_write(index);
|
||||
error(return_code, "program", "Failed to write index\n%s", git_error_last()->message);
|
||||
slowGitWarning(start, &slowGitWarningAlreadyShown);
|
||||
|
||||
|
||||
/*
|
||||
* Check whether there are changes to commit.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user