]> git.ipfire.org Git - thirdparty/git.git/blobdiff - usage.c
contrib/subtree: ensure only one rev is provided
[thirdparty/git.git] / usage.c
diff --git a/usage.c b/usage.c
index cc803336bd5e6761b7fd50c33dba5aa9f734c4ba..2fdb20086bd695eaad57ef7574ce4e02655e96c1 100644 (file)
--- a/usage.c
+++ b/usage.c
@@ -22,17 +22,48 @@ void vreportf(const char *prefix, const char *err, va_list params)
 static NORETURN void usage_builtin(const char *err, va_list params)
 {
        vreportf("usage: ", err, params);
+
+       /*
+        * When we detect a usage error *before* the command dispatch in
+        * cmd_main(), we don't know what verb to report.  Force it to this
+        * to facilitate post-processing.
+        */
+       trace2_cmd_name("_usage_");
+
+       /*
+        * Currently, the (err, params) are usually just the static usage
+        * string which isn't very useful here.  Usually, the call site
+        * manually calls fprintf(stderr,...) with the actual detailed
+        * syntax error before calling usage().
+        *
+        * TODO It would be nice to update the call sites to pass both
+        * the static usage string and the detailed error message.
+        */
+
        exit(129);
 }
 
 static NORETURN void die_builtin(const char *err, va_list params)
 {
+       /*
+        * We call this trace2 function first and expect it to va_copy 'params'
+        * before using it (because an 'ap' can only be walked once).
+        */
+       trace2_cmd_error_va(err, params);
+
        vreportf("fatal: ", err, params);
+
        exit(128);
 }
 
 static void error_builtin(const char *err, va_list params)
 {
+       /*
+        * We call this trace2 function first and expect it to va_copy 'params'
+        * before using it (because an 'ap' can only be walked once).
+        */
+       trace2_cmd_error_va(err, params);
+
        vreportf("error: ", err, params);
 }