diff options
| author | Junio C Hamano <gitster@pobox.com> | 2022-01-10 11:52:53 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2022-01-10 11:52:53 -0800 |
| commit | 4b51386bbfc5d26e552c3c4be135e31cd2f64b44 (patch) | |
| tree | 5bff7a8a4dee06d92dca0a89976248dc7e571918 /builtin/gc.c | |
| parent | bc61dbac770923a96e2007c3de4027c5d11c6d41 (diff) | |
| parent | f5c39c3268107e1f3def70709d509fd24282832c (diff) | |
| download | git-4b51386bbfc5d26e552c3c4be135e31cd2f64b44.tar.xz | |
Merge branch 'ab/usage-die-message'
Code clean-up to hide vreportf() from public API.
* ab/usage-die-message:
config API: use get_error_routine(), not vreportf()
usage.c + gc: add and use a die_message_errno()
gc: return from cmd_gc(), don't call exit()
usage.c API users: use die_message() for error() + exit 128
usage.c API users: use die_message() for "fatal :" + exit 128
usage.c: add a die_message() routine
Diffstat (limited to 'builtin/gc.c')
| -rw-r--r-- | builtin/gc.c | 14 |
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; |
