summaryrefslogtreecommitdiff
path: root/builtin/gc.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/gc.c')
-rw-r--r--builtin/gc.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/builtin/gc.c b/builtin/gc.c
index bcef6a4c8d..8e60ef1eab 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -470,7 +470,8 @@ static const char *lock_repo_for_gc(int force, pid_t* ret_pid)
/*
* Returns 0 if there was no previous error and gc can proceed, 1 if
* gc should not proceed due to an error in the last run. Prints a
- * message and returns -1 if an error occurred while reading gc.log
+ * message and returns with a non-[01] status code if an error occurred
+ * while reading gc.log
*/
static int report_last_gc_error(void)
{
@@ -484,7 +485,7 @@ static int report_last_gc_error(void)
if (errno == ENOENT)
goto done;
- ret = error_errno(_("cannot stat '%s'"), gc_log_path);
+ ret = die_message_errno(_("cannot stat '%s'"), gc_log_path);
goto done;
}
@@ -493,7 +494,7 @@ static int report_last_gc_error(void)
len = strbuf_read_file(&sb, gc_log_path, 0);
if (len < 0)
- ret = error_errno(_("cannot read '%s'"), gc_log_path);
+ ret = die_message_errno(_("cannot read '%s'"), gc_log_path);
else if (len > 0) {
/*
* A previous gc failed. Report the error, and don't
@@ -611,12 +612,13 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
}
if (detach_auto) {
int ret = report_last_gc_error();
- if (ret < 0)
- /* an I/O error occurred, already reported */
- exit(128);
+
if (ret == 1)
/* Last gc --auto failed. Skip this one. */
return 0;
+ else if (ret)
+ /* an I/O error occurred, already reported */
+ return ret;
if (lock_repo_for_gc(force, &pid))
return 0;