refs: allow log-only updates
The refs infrastructure learns about log-only ref updates, which only update the reflog. Later, we will use this to separate symbolic reference resolution from ref updating. Signed-off-by: David Turner <dturner@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
This commit is contained in:
parent
8bb0455367
commit
d99aa884df
@ -2683,7 +2683,7 @@ static int commit_ref_update(struct ref_lock *lock,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (commit_ref(lock)) {
|
if (!(flags & REF_LOG_ONLY) && commit_ref(lock)) {
|
||||||
strbuf_addf(err, "couldn't set '%s'", lock->ref_name);
|
strbuf_addf(err, "couldn't set '%s'", lock->ref_name);
|
||||||
unlock_ref(lock);
|
unlock_ref(lock);
|
||||||
return -1;
|
return -1;
|
||||||
@ -3101,7 +3101,8 @@ int ref_transaction_commit(struct ref_transaction *transaction,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if ((update->flags & REF_HAVE_NEW) &&
|
if ((update->flags & REF_HAVE_NEW) &&
|
||||||
!(update->flags & REF_DELETING)) {
|
!(update->flags & REF_DELETING) &&
|
||||||
|
!(update->flags & REF_LOG_ONLY)) {
|
||||||
int overwriting_symref = ((update->type & REF_ISSYMREF) &&
|
int overwriting_symref = ((update->type & REF_ISSYMREF) &&
|
||||||
(update->flags & REF_NODEREF));
|
(update->flags & REF_NODEREF));
|
||||||
|
|
||||||
@ -3133,8 +3134,9 @@ int ref_transaction_commit(struct ref_transaction *transaction,
|
|||||||
}
|
}
|
||||||
if (!(update->flags & REF_NEEDS_COMMIT)) {
|
if (!(update->flags & REF_NEEDS_COMMIT)) {
|
||||||
/*
|
/*
|
||||||
* We didn't have to write anything to the lockfile.
|
* We didn't call write_ref_to_lockfile(), so
|
||||||
* Close it to free up the file descriptor:
|
* the lockfile is still open. Close it to
|
||||||
|
* free up the file descriptor:
|
||||||
*/
|
*/
|
||||||
if (close_ref(update->lock)) {
|
if (close_ref(update->lock)) {
|
||||||
strbuf_addf(err, "couldn't close '%s.lock'",
|
strbuf_addf(err, "couldn't close '%s.lock'",
|
||||||
@ -3149,7 +3151,8 @@ int ref_transaction_commit(struct ref_transaction *transaction,
|
|||||||
for (i = 0; i < transaction->nr; i++) {
|
for (i = 0; i < transaction->nr; i++) {
|
||||||
struct ref_update *update = transaction->updates[i];
|
struct ref_update *update = transaction->updates[i];
|
||||||
|
|
||||||
if (update->flags & REF_NEEDS_COMMIT) {
|
if (update->flags & REF_NEEDS_COMMIT ||
|
||||||
|
update->flags & REF_LOG_ONLY) {
|
||||||
if (commit_ref_update(update->lock,
|
if (commit_ref_update(update->lock,
|
||||||
update->new_sha1, update->msg,
|
update->new_sha1, update->msg,
|
||||||
update->flags, err)) {
|
update->flags, err)) {
|
||||||
@ -3168,7 +3171,8 @@ int ref_transaction_commit(struct ref_transaction *transaction,
|
|||||||
for (i = 0; i < transaction->nr; i++) {
|
for (i = 0; i < transaction->nr; i++) {
|
||||||
struct ref_update *update = transaction->updates[i];
|
struct ref_update *update = transaction->updates[i];
|
||||||
|
|
||||||
if (update->flags & REF_DELETING) {
|
if (update->flags & REF_DELETING &&
|
||||||
|
!(update->flags & REF_LOG_ONLY)) {
|
||||||
if (delete_ref_loose(update->lock, update->type, err)) {
|
if (delete_ref_loose(update->lock, update->type, err)) {
|
||||||
ret = TRANSACTION_GENERIC_ERROR;
|
ret = TRANSACTION_GENERIC_ERROR;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -42,6 +42,13 @@
|
|||||||
* value to ref_update::flags
|
* value to ref_update::flags
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Used as a flag in ref_update::flags when we want to log a ref
|
||||||
|
* update but not actually perform it. This is used when a symbolic
|
||||||
|
* ref update is split up.
|
||||||
|
*/
|
||||||
|
#define REF_LOG_ONLY 0x80
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return true iff refname is minimally safe. "Safe" here means that
|
* Return true iff refname is minimally safe. "Safe" here means that
|
||||||
* deleting a loose reference by this name will not do any damage, for
|
* deleting a loose reference by this name will not do any damage, for
|
||||||
|
Loading…
Reference in New Issue
Block a user