diff options
| author | Sebastian Henke <s.henke@henke-informatik.de> | 2019-10-11 12:44:09 +0200 |
|---|---|---|
| committer | Sebastian Henke <s.henke@henke-informatik.de> | 2019-10-17 13:25:36 +0200 |
| commit | 47531f47334d8b14f6f3ad30a780565c657e4698 (patch) | |
| tree | 1c3f754e03c9b2f68e01094c7482d74f9289fe1a /src | |
| parent | ef5a3851fdece852569ffebf3537883223744a7a (diff) | |
| download | libgit2-47531f47334d8b14f6f3ad30a780565c657e4698.tar.gz | |
refs: unlock unmodified refs on transaction commit
Refs which are locked in a transaction without an altered target,
still should to be unlocked on `git_transaction_commit`.
`git_transaction_free` also unlocks refs but the moment of calling of `git_transaction_free`
cannot be controlled in all situations.
Some binding libs call `git_transaction_free` on garbage collection or not at all if the
application exits before and don't provide public access to `git_transaction_free`.
It is better to release locks as soon as possible.
Diffstat (limited to 'src')
| -rw-r--r-- | src/transaction.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/transaction.c b/src/transaction.c index 5dd7f42db..7367d1240 100644 --- a/src/transaction.c +++ b/src/transaction.c @@ -334,7 +334,13 @@ int git_transaction_commit(git_transaction *tx) return error; } - if (node->ref_type != GIT_REFERENCE_INVALID) { + if (node->ref_type == GIT_REFERENCE_INVALID) { + /* ref was locked but not modified */ + if ((error = git_refdb_unlock(tx->db, node->payload, false, false, NULL, NULL, NULL)) < 0) { + return error; + } + node->committed = true; + } else { if ((error = update_target(tx->db, node)) < 0) return error; } |
