Commit 6573284
ref_transaction_commit: bail out on failure to remove a ref
When removal of a loose or packed ref fails, bail out instead of
trying to finish the transaction. This way, a single error message
can be printed (instead of multiple messages being concatenated by
mistake) and the operator can try to solve the underlying problem
before there is a chance to muck things up even more.
In particular, when git fails to remove a ref, git goes on to try to
delete the reflog. Exiting early lets us keep the reflog.
When git succeeds in deleting a ref A and fails to remove a ref B, it
goes on to try to delete both reflogs. It would be better to just
remove the reflog for A, but that would be a more invasive change.
Failing early means we keep both reflogs, which puts the operator in a
good position to understand the problem and recover.
A long term goal is to avoid these problems altogether and roll back
the transaction on failure. That kind of transactionality will have
to wait for a later series (the plan for which is to make all
destructive work happen in a single update of the packed-refs file).
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Reviewed-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent fb43bd1 commit 6573284
1 file changed
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3809 | 3809 | | |
3810 | 3810 | | |
3811 | 3811 | | |
3812 | | - | |
| 3812 | + | |
3813 | 3813 | | |
| 3814 | + | |
| 3815 | + | |
3814 | 3816 | | |
3815 | 3817 | | |
3816 | 3818 | | |
3817 | 3819 | | |
3818 | 3820 | | |
3819 | 3821 | | |
3820 | | - | |
| 3822 | + | |
3821 | 3823 | | |
| 3824 | + | |
| 3825 | + | |
3822 | 3826 | | |
3823 | 3827 | | |
3824 | 3828 | | |
| |||
0 commit comments