diff options
Diffstat (limited to 'XD.c')
-rw-r--r-- | XD.c | 28 |
1 files changed, 15 insertions, 13 deletions
@@ -9,6 +9,8 @@ #include <git2.h> #endif +#define P(X) fwrite(X, 1, 1, stdout) + #ifdef ERR void l(const char *fmt, ...) @@ -182,25 +184,25 @@ main(int argc, char *argv[]) if (git_ok) { /* change the eyes depending on the current git repo's status */ if (has_stashes(repo)) { - printf("8"); /* goggle eyes if we have some stashed changes */ + P("8"); /* goggle eyes if we have some stashed changes */ } else if (git_repository_is_empty(repo)) { - printf("B"); /* sunglasses if we're in a new repo with no HEAD */ + P("B"); /* sunglasses if we're in a new repo with no HEAD */ } else { - printf(";"); /* wink when we're in a git repo */ + P(";"); /* wink when we're in a git repo */ } /* change the nose depending on the current git repo's status */ if (has_staged(repo)) { - printf("*"); /* change to broken nose for staged changes */ + P("*"); /* change to broken nose for staged changes */ } else if (has_untracked(repo)) { - printf("^"); /* add a little nose when there are untracked changes in the repo */ + P("^"); /* add a little nose when there are untracked changes in the repo */ } else if (git_repository_head_detached(repo)) { - printf("-"); /* add a minus nose when the HEAD is detached */ + P("-"); /* add a minus nose when the HEAD is detached */ } } else #endif if (1) { - printf(":"); + P(":"); } /* get exit code from user args */ @@ -211,14 +213,14 @@ main(int argc, char *argv[]) /* change mouth based on exit code */ if (code >= 0) { switch (code) { - case 0: printf(")"); break; /* all good */ - case 130: printf("O"); break; /* Ctrl-c pressed (SIGTERM) */ - case 126: printf("P"); break; /* permission denied */ - case 127: printf("/"); break; /* command not found */ - default: printf("("); break; /* all other codes (usually the program saying it has failed) */ + case 0: P(")"); break; /* all good */ + case 130: P("O"); break; /* Ctrl-c pressed (SIGTERM) */ + case 126: P("P"); break; /* permission denied */ + case 127: P("/"); break; /* command not found */ + default: P("("); break; /* all other codes (usually the program saying it has failed) */ } } else { - printf("|"); /* no code info */ + P("|"); /* no code info */ } #ifdef GIT |