Re: [PATCH v4 12/21] refs: allow log-only updates

2016-02-11 Thread Michael Haggerty
On 02/05/2016 08:44 PM, David Turner wrote:
> 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.

This looks good. I assume it will get some testing later in the series.

> [...]
> diff --git a/refs/refs-internal.h b/refs/refs-internal.h
> index fc5d1db..b5d0ab8 100644
> --- a/refs/refs-internal.h
> +++ b/refs/refs-internal.h
> @@ -42,6 +42,8 @@
>   * value to ref_update::flags
>   */
>  
> +#define REF_LOG_ONLY 0x80
> +

Please add a comment explaining the meaning/purpose of this flag.

> [...]

Michael

-- 
Michael Haggerty
mhag...@alum.mit.edu

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 12/21] refs: allow log-only updates

2016-02-11 Thread David Turner
On Thu, 2016-02-11 at 11:03 +0100, Michael Haggerty wrote:
> On 02/05/2016 08:44 PM, David Turner wrote:
> > 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.
> 
> This looks good. I assume it will get some testing later in the
> series.

The existing tests cover this pretty well, I think.  It's not intended
to have user-visible results, so it's hard to specifically test. 

> > [...]
> > diff --git a/refs/refs-internal.h b/refs/refs-internal.h
> > index fc5d1db..b5d0ab8 100644
> > --- a/refs/refs-internal.h
> > +++ b/refs/refs-internal.h
> > @@ -42,6 +42,8 @@
> >   * value to ref_update::flags
> >   */
> >  
> > +#define REF_LOG_ONLY 0x80
> > +
> 
> Please add a comment explaining the meaning/purpose of this flag.

Commented, thanks.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 12/21] refs: allow log-only updates

2016-02-05 Thread David Turner
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 
---
 refs/files-backend.c | 15 ++-
 refs/refs-internal.h |  2 ++
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/refs/files-backend.c b/refs/files-backend.c
index 0ad60bc..0fdcdc7 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -2845,7 +2845,7 @@ static int commit_ref_update(struct ref_lock *lock,
}
}
}
-   if (commit_ref(lock)) {
+   if (!(flags & REF_LOG_ONLY) && commit_ref(lock)) {
error("Couldn't set %s", lock->ref_name);
unlock_ref(lock);
return -1;
@@ -3199,7 +3199,8 @@ static int files_transaction_commit(struct 
ref_transaction *transaction,
goto cleanup;
}
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) 
&&
  (update->flags & 
REF_NODEREF));
 
@@ -3229,7 +3230,9 @@ static int files_transaction_commit(struct 
ref_transaction *transaction,
update->flags |= REF_NEEDS_COMMIT;
}
}
-   if (!(update->flags & REF_NEEDS_COMMIT)) {
+
+   if (!(update->flags & REF_LOG_ONLY) &&
+   !(update->flags & REF_NEEDS_COMMIT)) {
/*
 * We didn't have to write anything to the lockfile.
 * Close it to free up the file descriptor:
@@ -3246,7 +3249,8 @@ static int files_transaction_commit(struct 
ref_transaction *transaction,
for (i = 0; i < n; i++) {
struct ref_update *update = updates[i];
 
-   if (update->flags & REF_NEEDS_COMMIT) {
+   if (update->flags & REF_NEEDS_COMMIT ||
+   update->flags & REF_LOG_ONLY) {
if (commit_ref_update(update->backend_data,
  update->new_sha1, update->msg,
  update->flags, err)) {
@@ -3266,7 +3270,8 @@ static int files_transaction_commit(struct 
ref_transaction *transaction,
struct ref_update *update = updates[i];
struct ref_lock *lock = update->backend_data;
 
-   if (update->flags & REF_DELETING) {
+   if (update->flags & REF_DELETING &&
+   !(update->flags & REF_LOG_ONLY)) {
if (delete_ref_loose(lock, update->type, err)) {
ret = TRANSACTION_GENERIC_ERROR;
goto cleanup;
diff --git a/refs/refs-internal.h b/refs/refs-internal.h
index fc5d1db..b5d0ab8 100644
--- a/refs/refs-internal.h
+++ b/refs/refs-internal.h
@@ -42,6 +42,8 @@
  * value to ref_update::flags
  */
 
+#define REF_LOG_ONLY 0x80
+
 /*
  * Return true iff refname is minimally safe. "Safe" here means that
  * deleting a loose reference by this name will not do any damage, for
-- 
2.4.2.749.g730654d-twtrsrc

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html