diff options
Diffstat (limited to '')
-rw-r--r-- | XD.c | 43 |
1 files changed, 23 insertions, 20 deletions
@@ -9,24 +9,27 @@ #include <git2.h> #endif +#ifdef ERR void l(const char *fmt, ...) { - #ifdef ERR - va_list ap; - - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); - - if (fmt[0] && fmt[strlen(fmt) - 1] == ':') { - fputc(' ', stderr); - perror(NULL); - } else { - fputc('\n', stderr); - } - #endif + va_list ap; + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + + if (fmt[0] && fmt[strlen(fmt) - 1] == ':') { + fputc(' ', stderr); + perror(NULL); + } else { + fputc('\n', stderr); + } } +#define L(...) l(__VA_ARGS__) +#else +#define L(...) +#endif #ifdef GIT /** @@ -41,17 +44,17 @@ git_repository git_repository *repo; if (git_libgit2_init() < 0) { - l("Failed to initalize libgit2, proceeding without git functionality enabled."); + L("Failed to initalize libgit2, proceeding without git functionality enabled."); return NULL; } if (git_repository_discover(&buf, ".", 0, NULL) < 0) { - l("Failed to discover git repo: %s", git_error_last()->message); + L("Failed to discover git repo: %s", git_error_last()->message); return NULL; } if (git_repository_open(&repo, buf.ptr) < 0) { - l("Failed to open git repo: %s", git_error_last()->message); + L("Failed to open git repo: %s", git_error_last()->message); git_buf_dispose(&buf); return NULL; } @@ -78,7 +81,7 @@ has_stashes(git_repository *repo) git_error_clear(); return 0; } else if (e < GIT_OK) { - l("Error looking up stash reference: %s", git_error_last()->message); + L("Error looking up stash reference: %s", git_error_last()->message); return 0; } else { e = 1; @@ -106,7 +109,7 @@ has_untracked(git_repository *repo) GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX; if (git_status_list_new(&list, repo, &opts) < 0) { - l("Error checking for untracked changes: %s", git_error_last()->message); + L("Error checking for untracked changes: %s", git_error_last()->message); return 0; } @@ -127,7 +130,7 @@ has_staged(git_repository *repo) int i, c, r = 0; if (git_status_list_new(&list, repo, NULL) < 0) { - l("Error checking for staged changes: %s", git_error_last()->message); + L("Error checking for staged changes: %s", git_error_last()->message); return 0; } |