reflog: constify byindex
signature: add a dup function which takes a pool

This will be used by the transaction code.
Introduce reference transactions

A transaction allows you to lock multiple references and set up changes
for them before applying the changes all at once (or as close as the
backend supports).

This can be used for replication purposes, or for making sure some
operations run when the reference is locked and thus cannot be changed.
stash: use a transaction to modify the reflog

The stash is implemented as the refs/stash reference and its reflog. In
order to modify the reflog, we need avoid races by making sure we're the
only ones allowed to modify the reflog.

We achieve this via the transactions API. Locking the reference gives us
exclusive write access, letting us modify and write it without races.
transaction: add documentation
Add changelog for transactions
transaction: rename lock() to lock_ref()

This leaves space for future expansion to locking other resources
without having to change the API for references.
Merge pull request #2448 from libgit2/cmn/reference-transaction

Introduce reference transactions