Skip to content

Commit 9b24bb9

Browse files
vdyegitster
authored andcommitted
scalar-delete: do not 'die()' in 'delete_enlistment()'
Rather than exiting with 'die()' when 'delete_enlistment()' encounters an error, return an error code with the appropriate message. There's no need for an abrupt exit with 'die()' in 'delete_enlistment()' because its only caller ('cmd_delete()') properly cleans up allocated resources and returns the 'delete_enlistment()' return value as its own exit code. Signed-off-by: Victoria Dye <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d2a79bc commit 9b24bb9

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

contrib/scalar/scalar.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ static int delete_enlistment(struct strbuf *enlistment)
407407
#endif
408408

409409
if (unregister_dir())
410-
die(_("failed to unregister repository"));
410+
return error(_("failed to unregister repository"));
411411

412412
#ifdef WIN32
413413
/*
@@ -418,13 +418,16 @@ static int delete_enlistment(struct strbuf *enlistment)
418418
path_sep = find_last_dir_sep(enlistment->buf + offset);
419419
strbuf_add(&parent, enlistment->buf,
420420
path_sep ? path_sep - enlistment->buf : offset);
421-
if (chdir(parent.buf) < 0)
422-
die_errno(_("could not switch to '%s'"), parent.buf);
421+
if (chdir(parent.buf) < 0) {
422+
int res = error_errno(_("could not switch to '%s'"), parent.buf);
423+
strbuf_release(&parent);
424+
return res;
425+
}
423426
strbuf_release(&parent);
424427
#endif
425428

426429
if (remove_dir_recursively(enlistment, 0))
427-
die(_("failed to delete enlistment directory"));
430+
return error(_("failed to delete enlistment directory"));
428431

429432
return 0;
430433
}

0 commit comments

Comments
 (0)