Commit fe3992aa188e91e01ce893eae2b2695e568cb59f

Thomas de Grivel 2021-01-07T11:49:32

better error messages, fix number of arguments

diff --git a/git-auth.c b/git-auth.c
index c9d0063..c533541 100644
--- a/git-auth.c
+++ b/git-auth.c
@@ -152,13 +152,19 @@ int main (int argc, char **argv)
         const char *git_auth_id;
         int auth_ok;
         const char *cmd_argv[3];
-        if (argc != 4)
+        if (argc != 3) {
+                fprintf(stderr, "git-auth: wrong number of arguments.\n");
                 usage(argv[0]);
-        if (strcmp(argv[1], "-c"))
+        }
+        if (strcmp(argv[1], "-c")) {
+                fprintf(stderr, "expected -c as first argument.\n");
                 usage(argv[0]);
+        }
         git_auth_id = getenv(GIT_AUTH_ID_ENV);
-        if (!git_auth_id)
+        if (!git_auth_id) {
+                fprintf(stderr, "missing %s.\n", GIT_AUTH_ID_ENV);
                 usage(argv[0]);
+        }
         openlog(argv[0], LOG_PID, LOG_AUTH);
         log_args("NEW", argc, (const char **) argv);
         cmd_argv[0] = git_auth_id;