1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-26 21:06:15 +02:00
git/usage.c
Linus Torvalds 5d1a5c02e8 [PATCH] Better error reporting for "git status"
Instead of "git status" ignoring (and hiding) potential errors from the
"git-update-index" call, make it exit if it fails, and show the error.

In order to do this, use the "-q" flag (to ignore not-up-to-date files)
and add a new "--unmerged" flag that allows unmerged entries in the index
without any errors.

This also avoids marking the index "changed" if an entry isn't actually
modified, and makes sure that we exit with an understandable error message
if the index is corrupt or unreadable. "read_cache()" no longer returns an
error for the caller to check.

Finally, make die() and usage() exit with recognizable error codes, if we
ever want to check the failure reason in scripts.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-01 23:55:47 -07:00

40 lines
629 B
C

/*
* GIT - The information manager from hell
*
* Copyright (C) Linus Torvalds, 2005
*/
#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(129);
}
void die(const char *err, ...)
{
va_list params;
va_start(params, err);
report("fatal: ", err, params);
va_end(params);
exit(128);
}
int error(const char *err, ...)
{
va_list params;
va_start(params, err);
report("error: ", err, params);
va_end(params);
return -1;
}