fix: clang format

This commit is contained in:
tomasr committed 2026-08-18 18:37:15 +02:00
1 parent 39a3cb6bba
commit 19610c1c51
1 file changed
+20 -27
+20 -27
View File
@@ -71,27 +71,24 @@ 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);
va_list args; va_list args;
va_start(args, message); va_start(args, message);
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);
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) { static void slowGitWarning(struct timespec start, int *wasShown) {
if (!*wasShown) { if (!*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) {
*wasShown = 1; *wasShown = 1;
}
} }
}
} }
void ensureGitDirectory(const char *path, const char *vault, const char *signatureName, const char *signatureEmail, const int shouldDebug) { 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); 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);
/* /*
* Check whether there are changes to commit. * Check whether there are changes to commit.
* *