summaryrefslogtreecommitdiff
path: root/usage.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-18 13:04:43 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-18 13:04:43 -0700
commit0fcfd160b0495c0881e142c546c4418b8cea7e93 (patch)
tree21bdf6702f0dfe75fc7caa3882da7bb34b0bc4bf /usage.c
parent0a02ce72d9ab78d061b2cc919bc15e36fe620ddc (diff)
downloadgit-0fcfd160b0495c0881e142c546c4418b8cea7e93.tar.gz
Split up read-cache.c into more logical clumps.
Do the usage and error reporting in "usage.c", and the sha1 file accesses in "sha1_file.c". Small, nice, easily separated parts. Good.
Diffstat (limited to 'usage.c')
-rw-r--r--usage.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/usage.c b/usage.c
new file mode 100644
index 0000000000..e774d2ef32
--- /dev/null
+++ b/usage.c
@@ -0,0 +1,40 @@
+/*
+ * GIT - The information manager from hell
+ *
+ * Copyright (C) Linus Torvalds, 2005
+ */
+#include <stdarg.h>
+#include "cache.h"
+
+static void report(const char *prefix, const char *err, va_list params)
+{
+ fputs(prefix, stderr);
+ vfprintf(stderr, err, params);
+ fputs("\n", stderr);
+}
+
+void usage(const char *err)
+{
+ fprintf(stderr, "usage: %s\n", err);
+ exit(1);
+}
+
+void die(const char *err, ...)
+{
+ va_list params;
+
+ va_start(params, err);
+ report("fatal: ", err, params);
+ va_end(params);
+ exit(1);
+}
+
+int error(const char *err, ...)
+{
+ va_list params;
+
+ va_start(params, err);
+ report("error: ", err, params);
+ va_end(params);
+ return -1;
+}