refs.c: add an err argument to delete_ref_loose
Add an err argument to delete_ref_loose so that we can pass a descriptive error string back to the caller. Pass the err argument from transaction commit to this function so that transaction users will have a nice error string if the transaction failed due to delete_ref_loose. Signed-off-by: Ronnie Sahlberg <sahlberg@google.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ronnie Sahlberg committed
May 15, 2014 at 08:25 UTC
dbdcac7d5c5eea314ec4c318a5e88cff427e9f0e
1 file changed
+5
-4
refs.c
+5
-4
@@ -2597,7 +2597,7 @@ int repack_without_refs(const char **refnames, int n, struct strbuf *err)
2597
return ret;
2598
}
2599
2600
-static int delete_ref_loose(struct ref_lock *lock, int flag)
2600
+static int delete_ref_loose(struct ref_lock *lock, int flag, struct strbuf *err)
2601
{
2602
if (!(flag & REF_ISPACKED) || flag & REF_ISSYMREF) {
2603
/*
@@ -2605,9 +2605,9 @@ static int delete_ref_loose(struct ref_lock *lock, int flag)
2605
* lockfile name, minus ".lock":
2606
*/
2607
char *loose_filename = get_locked_file_path(lock->lk);
2608
- int err = unlink_or_warn(loose_filename);
2608
+ int res = unlink_or_msg(loose_filename, err);
2609
free(loose_filename);
2610
- if (err)
2610
+ if (res)
2611
return 1;
2612
}
2613
return 0;
@@ -3658,7 +3658,8 @@ int ref_transaction_commit(struct ref_transaction *transaction,
3658
struct ref_update *update = updates[i];
3659
3660
if (update->lock) {
3661
- ret |= delete_ref_loose(update->lock, update->type);
3661
+ ret |= delete_ref_loose(update->lock, update->type,
3662
+ err);
3663
if (!(update->flags & REF_ISPRUNING))
3664
delnames[delnum++] = update->lock->ref_name;
3665
}