refs.c: allow passing NULL to ref_transaction_free

Allow ref_transaction_free(NULL) as a no-op. This makes ref_transaction_free
easier to use and more similar to plain 'free'.

In particular, it lets us rollback unconditionally as part of cleanup code
after setting 'transaction = NULL' if a transaction has been committed or
rolled back already.

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Acked-by: Michael Haggerty <mhagger@alum.mit.edu>
This commit is contained in:
Ronnie Sahlberg 2014-06-20 07:42:45 -07:00 коммит произвёл Junio C Hamano
Родитель f1c9350ad7
Коммит 1b07255c95
1 изменённых файлов: 3 добавлений и 0 удалений

3
refs.c
Просмотреть файл

@ -3338,6 +3338,9 @@ void ref_transaction_free(struct ref_transaction *transaction)
{
int i;
if (!transaction)
return;
for (i = 0; i < transaction->nr; i++)
free(transaction->updates[i]);