refs.c: allow multiple reflog updates during a single transaction
commit5fd1fa7d8520cf03e94fa7d0e9aa8685de0ef63f
authorRonnie Sahlberg <sahlberg@google.com>
Wed, 23 Jul 2014 17:03:50 +0000 (23 10:03 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 Jul 2014 23:08:07 +0000 (23 16:08 -0700)
treeded265c54cb92cc9cb0980c6ea054794f7b957a0
parent020ed65a12838bdead64bc3c5de249d3c8f5cfd8
refs.c: allow multiple reflog updates during a single transaction

Allow to make multiple reflog updates to the same ref during a transaction.
This means we only need to lock the reflog once, during the first update
that touches the reflog, and that all further updates can just write the
reflog entry since the reflog is already locked.

This allows us to write code such as:

t = transaction_begin()
transaction_reflog_update(t, "foo", REFLOG_TRUNCATE, NULL);
loop-over-somehting...
   transaction_reflog_update(t, "foo", 0, <message>);
transaction_commit(t)

where we first truncate the reflog and then build the new content one line at a
time.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c