Re: [PATCH 03/16] refs: add methods for the ref iterators

2016-01-04 Thread Ronnie Sahlberg
On Sat, Jan 2, 2016 at 4:06 PM, David Aguilar wrote: > Apologies for the late review, and this review should probably > go on patch 01 or 02 but I don't have it in my mbox atm... > > On Wed, Dec 02, 2015 at 07:35:08PM -0500, David Turner wrote: >> From: Ronnie Sahlbe

Re: [PATCH v6 02/42] refs.c: allow passing NULL to ref_transaction_free

2014-05-13 Thread Ronnie Sahlberg
On Tue, May 13, 2014 at 3:44 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > >> Allow ref_transaction_free to be called with NULL and in extension allow >> ref_transaction_rollback to be called for a NULL transaction. > > In extension = as a result? > > Makes

Re: [PATCH] contrib: remote-helpers: add move warnings (v2.0)

2014-05-13 Thread Ronnie Sahlberg
On Tue, May 13, 2014 at 3:22 PM, Felipe Contreras wrote: > Junio C Hamano wrote: >> Felipe Contreras writes: >> >> > The tools are now maintained out-of-tree, and they have a regression in >> > v2.0. >> >> You seem not to understand at all what a regression is. >> >> My understanding is that vers

Re: [PATCH v6 02/42] refs.c: allow passing NULL to ref_transaction_free

2014-05-14 Thread Ronnie Sahlberg
Thanks. I changed the commit message. On Tue, May 13, 2014 at 3:44 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > >> Allow ref_transaction_free to be called with NULL and in extension allow >> ref_transaction_rollback to be called for a NULL transaction. > > In

Re: [PATCH v6 03/42] refs.c: add a strbuf argument to ref_transaction_commit for error logging

2014-05-14 Thread Ronnie Sahlberg
Thanks. Comment added and whitespace fixed. On Tue, May 13, 2014 at 4:10 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > >> Add a strbuf argument to _commit so that we can pass an error string back to >> the caller. So that we can do error logging from the caller instead

Re: [PATCH v6 04/42] refs.c: make ref_update_reject_duplicates take a strbuf argument for errors

2014-05-14 Thread Ronnie Sahlberg
Thanks. I updated the commit message to highlight that this means the error string can now be passed all the way back to the caller. On Tue, May 13, 2014 at 5:04 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > >> Make ref_update_reject_duplicates return any error that occu

Re: [PATCH] contrib: remote-helpers: add move warnings (v2.0)

2014-05-14 Thread Ronnie Sahlberg
On Tue, May 13, 2014 at 4:37 PM, Felipe Contreras wrote: > Ronnie Sahlberg wrote: >> Could you please calm down and adjust your behavior. This constant >> hostility and rudeness makes the mailing list very unpleasant. > > I explaind that to him multiple times. In the ma

[PATCH v7 10/42] refs.c: ref_transaction_delete to check for error and return status

2014-05-14 Thread Ronnie Sahlberg
Change ref_transaction_delete() to do basic error checking and return non-zero of error. Update all callers to check the return for ref_transaction_delete(). There are currently no conditions in _delete that will return error but there will be in the future. Signed-off-by: Ronnie Sahlberg

[PATCH v7 15/42] fast-import.c: change update_branch to use ref transactions

2014-05-14 Thread Ronnie Sahlberg
Change update_branch() to use ref transactions for updates. Signed-off-by: Ronnie Sahlberg --- fast-import.c | 22 ++ 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/fast-import.c b/fast-import.c index 6707a66..79d219b 100644 --- a/fast-import.c +++ b/fast

[PATCH v7 17/42] refs.c: change update_ref to use a transaction

2014-05-14 Thread Ronnie Sahlberg
Change the update_ref helper function to use a ref transaction internally. Signed-off-by: Ronnie Sahlberg --- refs.c | 25 + 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/refs.c b/refs.c index 64e3d53..55aa5a9 100644 --- a/refs.c +++ b/refs.c @@ -3405,11

[PATCH v7 19/42] refs.c: ref_transaction_commit should not free the transaction

2014-05-14 Thread Ronnie Sahlberg
!!oldval) || ref_transaction_commit(&t, action, &err)) { ref_transaction_rollback(t); ... die/return ... ref_transaction_free(transaction); Signed-off-by: Ronnie Sahlberg --- branch.c | 1 + builtin/commit.c | 1 + builtin/replace.

[PATCH v7 16/42] branch.c: use ref transaction for all ref updates

2014-05-14 Thread Ronnie Sahlberg
lock_any_ref_for_update/write_ref_sha1 did not protect against the ref already existsing. I.e. one thread could end up overwriting a branch even if the forcing flag is false. Signed-off-by: Ronnie Sahlberg --- branch.c | 30 -- 1 file changed, 16 insertions(+), 14 deletions(-) diff

[PATCH v7 36/42] refs.c: pack all refs before we start to rename a ref

2014-05-14 Thread Ronnie Sahlberg
This means that most loose refs will no longer be present after the rename which triggered a test failure since it assumes the file for an unrelated ref would still be present after the rename. Signed-off-by: Ronnie Sahlberg --- refs.c| 3 +++ t/t3200-branch.sh | 2 +- 2 files

[PATCH v7 38/42] refs.c: call lock_ref_sha1_basic directly from commit

2014-05-14 Thread Ronnie Sahlberg
Skip using the lock_any_ref_for_update wrapper and call lock_ref_sha1_basic directly from the commit function. Signed-off-by: Ronnie Sahlberg --- refs.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/refs.c b/refs.c index 6556417..a376dd6 100644 --- a/refs.c

[PATCH v7 37/42] refs.c: move the check for valid refname to lock_ref_sha1_basic

2014-05-14 Thread Ronnie Sahlberg
caller and we will soon make changes to the signature to lock_ref_sha1_basic that we do not want to expose to that caller. Signed-off-by: Ronnie Sahlberg --- refs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/refs.c b/refs.c index 157a094..6556417 100644 --- a/refs.c

[PATCH v7 31/42] refs.c: remove lock_ref_sha1

2014-05-14 Thread Ronnie Sahlberg
lock_ref_sha1 was only called from one place in refc.c and only provided a check that the refname was sane before adding back the initial "refs/" part of the ref path name, the initial "refs/" that this caller had already stripped off before calling lock_ref_sha1. Signed-off

[PATCH v7 34/42] refs.c: pass the ref log message to _create/delete/update instead of _commit

2014-05-14 Thread Ronnie Sahlberg
Change the reference transactions so that we pass the reflog message through to the create/delete/update function instead of the commit message. This allows for individual messages for each change in a multi ref transaction. Signed-off-by: Ronnie Sahlberg --- branch.c | 6

[PATCH v7 35/42] refs.c: pass NULL as *flags to read_ref_full

2014-05-14 Thread Ronnie Sahlberg
We call read_ref_full with a pointer to flags from rename_ref but since we never actually use the returned flags we can just pass NULL here instead. Signed-off-by: Ronnie Sahlberg --- refs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/refs.c b/refs.c index 9ac9f38

[PATCH v7 32/42] refs.c: make prune_ref use a transaction to delete the ref

2014-05-14 Thread Ronnie Sahlberg
Change prune_ref to delete the ref using a ref transaction. To do this we also need to add a new flag REF_ISPRUNING that will tell the transaction that we do not want to delete this ref from the packed refs. This flag is private to refs.c and not exposed to external callers. Signed-off-by: Ronnie

[PATCH v7 42/42] refs.c: remove forward declaration of write_ref_sha1

2014-05-14 Thread Ronnie Sahlberg
Signed-off-by: Ronnie Sahlberg --- refs.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/refs.c b/refs.c index 8e12386..aed700b 100644 --- a/refs.c +++ b/refs.c @@ -260,8 +260,6 @@ struct ref_entry { }; static void read_loose_refs(const char *dirname, struct ref_dir *dir); -static int

[PATCH v7 23/42] receive-pack.c: use a reference transaction for updating the refs

2014-05-14 Thread Ronnie Sahlberg
Wrap all the ref updates inside a transaction to make the update atomic. Signed-off-by: Ronnie Sahlberg --- builtin/receive-pack.c | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index c323081..d580176

[PATCH v7 33/42] refs.c: make delete_ref use a transaction

2014-05-14 Thread Ronnie Sahlberg
Change delete_ref to use a ref transaction for the deletion. At the same time since we no longer have any callers of repack_without_ref we can now delete this function. Signed-off-by: Ronnie Sahlberg --- refs.c | 31 ++- 1 file changed, 10 insertions(+), 21 deletions

[PATCH v7 22/42] fetch.c: use a single ref transaction for all ref updates

2014-05-14 Thread Ronnie Sahlberg
re correct, since if there was a problem we would not even try to commit the transaction but need to highlight this change in how/what errors are reported. This change in what error is returned only occurs if there are multiple refs that fail to update and only some, but not all, of them fail due

[PATCH v7 21/42] fetch.c: change s_update_ref to use a ref transaction

2014-05-14 Thread Ronnie Sahlberg
Change s_update_ref to use a ref transaction for the ref update. Signed-off-by: Ronnie Sahlberg --- builtin/fetch.c | 17 + 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index a93c893..b41d7b7 100644 --- a/builtin/fetch.c +++ b

[PATCH v7 28/42] refs.c: add transaction.status and track OPEN/CLOSED/ERROR

2014-05-14 Thread Ronnie Sahlberg
Track the status of a transaction in a new status field. Check the field for sanity, i.e. that status must be OPEN when _commit/_create/_delete or _update is called or else die(BUG:...) Signed-off-by: Ronnie Sahlberg --- refs.c | 37 + 1 file changed, 33

[PATCH v7 14/42] sequencer.c: use ref transactions for all ref updates

2014-05-14 Thread Ronnie Sahlberg
Change to use ref transactions for all updates to refs. Signed-off-by: Ronnie Sahlberg --- sequencer.c | 24 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/sequencer.c b/sequencer.c index 0a80c58..9282a12 100644 --- a/sequencer.c +++ b/sequencer.c

[PATCH v7 30/42] refs.c: remove the update_ref_write function

2014-05-14 Thread Ronnie Sahlberg
Since we only call update_ref_write from a single place and we only call it with onerr==QUIET_ON_ERR we can just as well get rid of it and just call write_ref_sha1 directly. Signed-off-by: Ronnie Sahlberg --- refs.c | 35 +-- 1 file changed, 9 insertions(+), 26

[PATCH v7 29/42] refs.c: remove the update_ref_lock function

2014-05-14 Thread Ronnie Sahlberg
Since we now only call update_ref_lock with onerr==QUIET_ON_ERR we no longer need this function and can replace it with just calling lock_any_ref_for_update directly. Signed-off-by: Ronnie Sahlberg --- refs.c | 30 ++ 1 file changed, 6 insertions(+), 24 deletions

[PATCH v7 41/42] refs.c: make rename_ref use a transaction

2014-05-14 Thread Ronnie Sahlberg
Change rename_ref to use a single transaction to perform the ref rename. Signed-off-by: Ronnie Sahlberg --- refs.c | 73 ++ 1 file changed, 20 insertions(+), 53 deletions(-) diff --git a/refs.c b/refs.c index 7569f4e..8e12386

[PATCH v7 25/42] walker.c: use ref transaction for ref updates

2014-05-14 Thread Ronnie Sahlberg
) repository which likely means that the type of collissions that the previous locking would protect against and cause the fetch to fail for to be even more rare. Signed-off-by: Ronnie Sahlberg --- walker.c | 51 ++- 1 file changed, 26 insertions(+), 25

[PATCH v7 27/42] refs.c: make lock_ref_sha1 static

2014-05-14 Thread Ronnie Sahlberg
No external callers reference lock_ref_sha1 any more so lets declare it static. Signed-off-by: Ronnie Sahlberg --- refs.c | 2 +- refs.h | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/refs.c b/refs.c index 0e88197..b7fa79b 100644 --- a/refs.c +++ b/refs.c @@ -2126,7

[PATCH v7 40/42] refs.c: pass a skip list to name_conflict_fn

2014-05-14 Thread Ronnie Sahlberg
will delete m from the packed ref 3, the transaction will create conflicting m/m For this case we want to be able to lock and create m/m since we know that the conflict is only transient. I.e. the conflict will be automatically resolved by the transaction when it deletes m. Signed-off-by: Ronnie

[PATCH v7 39/42] refs.c: add a new flag for transaction delete for refs we know are packed only

2014-05-14 Thread Ronnie Sahlberg
: Ronnie Sahlberg --- refs.c | 23 +++ 1 file changed, 23 insertions(+) diff --git a/refs.c b/refs.c index a376dd6..6b8b7fe 100644 --- a/refs.c +++ b/refs.c @@ -33,6 +33,10 @@ static inline int bad_ref_char(int ch) * pruned. */ #define REF_ISPRUNING 0x0100 +/** Deletion of a

[PATCH v7 26/42] refs.c: make write_ref_sha1 static

2014-05-14 Thread Ronnie Sahlberg
No external users call write_ref_sha1 any more so lets declare it static. Signed-off-by: Ronnie Sahlberg --- refs.c | 4 +++- refs.h | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/refs.c b/refs.c index 4673cf4..0e88197 100644 --- a/refs.c +++ b/refs.c @@ -251,6 +251,8

[PATCH v7 24/42] fast-import.c: use a ref transaction when dumping tags

2014-05-14 Thread Ronnie Sahlberg
Signed-off-by: Ronnie Sahlberg --- fast-import.c | 17 - 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/fast-import.c b/fast-import.c index 3e356da..5587cf6 100644 --- a/fast-import.c +++ b/fast-import.c @@ -1736,15 +1736,22 @@ static void dump_tags(void

[PATCH v7 08/42] refs.c: change ref_transaction_update() to do error checking and return status

2014-05-14 Thread Ronnie Sahlberg
(BUG:...) if we are calling _update with have_old but the old_sha1 pointer is NULL. Signed-off-by: Ronnie Sahlberg --- builtin/update-ref.c | 10 ++ refs.c | 9 +++-- refs.h | 11 ++- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a

[PATCH v7 07/42] refs.c: remove the onerr argument to ref_transaction_commit

2014-05-14 Thread Ronnie Sahlberg
Since all callers now use QUIET_ON_ERR we no longer need to provide an onerr argument any more. Remove the onerr argument from the ref_transaction_commit signature. Signed-off-by: Ronnie Sahlberg --- builtin/update-ref.c | 3 +-- refs.c | 22 +++--- refs.h

[PATCH v7 11/42] tag.c: use ref transactions when doing updates

2014-05-14 Thread Ronnie Sahlberg
Change tag.c to use ref transactions for all ref updates. Signed-off-by: Ronnie Sahlberg --- builtin/tag.c | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/builtin/tag.c b/builtin/tag.c index c6e8a71..bf2a5c3 100644 --- a/builtin/tag.c +++ b/builtin/tag.c

[PATCH v7 09/42] refs.c: change ref_transaction_create to do error checking and return status

2014-05-14 Thread Ronnie Sahlberg
Do basic error checking in ref_transaction_create() and make it return non-zero on error. Update all callers to check the result of ref_transaction_create(). There are currently no conditions in _create that will return error but there will be in the future. Signed-off-by: Ronnie Sahlberg

[PATCH v7 00/42] Use ref transactions for all ref updates

2014-05-14 Thread Ronnie Sahlberg
why the change in locking semantics should not be harmful. Ronnie Sahlberg (42): refs.c: constify the sha arguments for ref_transaction_create|delete|update refs.c: allow passing NULL to ref_transaction_free refs.c: add a strbuf argument to ref_transaction_commit for erro

[PATCH v7 06/42] refs.c: make update_ref_write update a strbuf on failure

2014-05-14 Thread Ronnie Sahlberg
Change update_ref_write to also update an error strbuf on failure. This makes the error available to ref_transaction_commit callers if the transaction failed due to update_ref_sha1/write_ref_sha1 failures. Signed-off-by: Ronnie Sahlberg --- refs.c | 9 ++--- 1 file changed, 6 insertions

[PATCH v7 01/42] refs.c: constify the sha arguments for ref_transaction_create|delete|update

2014-05-14 Thread Ronnie Sahlberg
ref_transaction_update() in which case this change is required. Signed-off-by: Ronnie Sahlberg --- refs.c | 7 --- refs.h | 7 --- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/refs.c b/refs.c index 6898263..2114748 100644 --- a/refs.c +++ b/refs.c @@ -3338,7 +3338,8

[PATCH v7 12/42] replace.c: use the ref transaction functions for updates

2014-05-14 Thread Ronnie Sahlberg
Update replace.c to use ref transactions for updates. Signed-off-by: Ronnie Sahlberg --- builtin/replace.c | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/builtin/replace.c b/builtin/replace.c index 3da1bae..11dc2e1 100644 --- a/builtin/replace.c +++ b/builtin

[PATCH v7 13/42] commit.c: use ref transactions for updates

2014-05-14 Thread Ronnie Sahlberg
Change commit.c to use ref transactions for all ref updates. Make sure we pass a NULL pointer to ref_transaction_update if have_old is false. Signed-off-by: Ronnie Sahlberg --- builtin/commit.c | 23 ++- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/builtin

[PATCH v7 03/42] refs.c: add a strbuf argument to ref_transaction_commit for error logging

2014-05-14 Thread Ronnie Sahlberg
finally remove the onerr argument completely. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- builtin/update-ref.c | 2 +- refs.c | 6 +- refs.h | 5 - 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/builtin/update-ref.c b

[PATCH v7 02/42] refs.c: allow passing NULL to ref_transaction_free

2014-05-14 Thread Ronnie Sahlberg
t() then transaction is untouched and then ref_transaction_rollback(transaction) will rollback the failed transaction. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- refs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/refs.c b/refs.c index 2114748..88d73c8 100644 ---

[PATCH v7 18/42] refs.c: free the transaction before returning when number of updates is 0

2014-05-14 Thread Ronnie Sahlberg
We have to free the transaction before returning in the early check for 'return early if number of updates == 0' or else the following code would create a memory leak with the transaction never being freed : t = ref_transaction_begin() ref_transaction_commit(t) Signed-off-

[PATCH v7 20/42] fetch.c: clear errno before calling functions that might set it

2014-05-14 Thread Ronnie Sahlberg
unrelated ENOTDIR may cause us to return the wrong error. Clear errno before calling any functions if we check errno afterwards. Also skip initializing a static variable to 0. Statics live in .bss and are all automatically initialized to 0. Signed-off-by: Ronnie Sahlberg --- builtin/fetch.c | 4

[PATCH v7 05/42] update-ref.c: log transaction error from the update_ref

2014-05-14 Thread Ronnie Sahlberg
Call ref_transaction_commit with QUIET_ON_ERR and use the strbuf that is returned to print a log message if/after the transaction fails. Signed-off-by: Ronnie Sahlberg --- builtin/update-ref.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/builtin/update-ref.c b

[PATCH v7 04/42] refs.c: make ref_update_reject_duplicates take a strbuf argument for errors

2014-05-14 Thread Ronnie Sahlberg
Make ref_update_reject_duplicates return any error that occurs through a new strbuf argument. This means that when a transaction commit fails in this function we will now be able to pass a helpful error message back to the caller. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg

[PATCH 29/31] refs.c: allow passing raw git_committer_info as email to _update_reflog

2014-05-14 Thread Ronnie Sahlberg
-by: Ronnie Sahlberg Conflicts: refs.c --- refs.c | 20 refs.h | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/refs.c b/refs.c index 8129b20..46a31c1 100644 --- a/refs.c +++ b/refs.c @@ -3396,14 +3396,18 @@ int transaction_update_reflog(struct

[PATCH 08/31] refs.c: only write reflog update if msg is non-NULL

2014-05-14 Thread Ronnie Sahlberg
When performing a reflog transaction update, only write to the reflog iff msg is non-NULL. This can then be combined with REFLOG_TRUNCATE to perform an update that only truncates but does not write. Signed-off-by: Ronnie Sahlberg --- refs.c | 8 +--- refs.h | 1 + 2 files changed, 6

[PATCH 30/31] refs.c: move ref_update and other definitions to earlier in the file

2014-05-14 Thread Ronnie Sahlberg
Move the struct ref_update definition and some enums to earlier in the file. This does not change any actual code or definitions but just moves them to a different place in the code since we will soon reference some of these from the rename_ref function. Signed-off-by: Ronnie Sahlberg Conflicts

[PATCH 15/31] refs.c: lock the ref during _update instead of during _commit

2014-05-14 Thread Ronnie Sahlberg
: Ronnie Sahlberg --- refs.c | 18 ++ 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/refs.c b/refs.c index 8212d77..b006238 100644 --- a/refs.c +++ b/refs.c @@ -3438,6 +3438,16 @@ int transaction_update_sha1(struct ref_transaction *transaction

[PATCH 31/31] refs.c: use the transaction to manage the reflog in rename_refs

2014-05-14 Thread Ronnie Sahlberg
store for refs, such as a database. Signed-off-by: Ronnie Sahlberg --- refs.c | 62 ++ 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/refs.c b/refs.c index bcce8fe..829c89a 100644 --- a/refs.c +++ b/refs.c @@ -2633,6

[PATCH 27/31] refs.c: remove the function lock_any_ref_for_update

2014-05-14 Thread Ronnie Sahlberg
We no longer need the function lock_any_ref_for_update so lets remove it. Signed-off-by: Ronnie Sahlberg --- refs.c | 7 --- refs.h | 4 2 files changed, 11 deletions(-) diff --git a/refs.c b/refs.c index 0cb4ae8..918cda3 100644 --- a/refs.c +++ b/refs.c @@ -2167,13 +2167,6 @@ static

[PATCH 18/31] refs.c: return immediately from _commit if the transaction has an error

2014-05-14 Thread Ronnie Sahlberg
x27;t need to do anything at all in _commit than return failure. Signed-off-by: Ronnie Sahlberg --- refs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/refs.c b/refs.c index 8b09258..93f01e8 100644 --- a/refs.c +++ b/refs.c @@ -3558,6 +3558,9 @@ int transaction_commit(struct ref_transa

[PATCH 05/31] refs.c: add a function to append a reflog entry to a fd

2014-05-14 Thread Ronnie Sahlberg
only a single place where we write a reflog entry to a file instead of the current two places (log_ref_write and builtin/reflog.c). Signed-off-by: Ronnie Sahlberg --- refs.c | 48 ++-- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/refs.c

[PATCH 01/31] refs.c make ref_transaction_create a wrapper to ref_transaction_update

2014-05-14 Thread Ronnie Sahlberg
Signed-off-by: Ronnie Sahlberg --- refs.c | 13 +++-- refs.h | 7 --- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/refs.c b/refs.c index aed700b..fe195dd 100644 --- a/refs.c +++ b/refs.c @@ -3354,17 +3354,10 @@ int ref_transaction_create(struct ref_transaction

[PATCH 28/31] refs.c: make struct ref_lock private to refs.c

2014-05-14 Thread Ronnie Sahlberg
We no longer need to expose the ref_lock structure to any external callers. Make it private to refs.c. Signed-off-by: Ronnie Sahlberg --- refs.c | 9 + refs.h | 9 - 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/refs.c b/refs.c index 918cda3..8129b20 100644

[PATCH 22/31] refs.c: release all remaining locks during transaction_free

2014-05-14 Thread Ronnie Sahlberg
transaction */ transaction_update_sha1(t, ref, ...) /* will fail since ref was locked above */ Signed-off-by: Ronnie Sahlberg --- refs.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/refs.c b/refs.c index 87cdd91..17feec5 100644 --- a/refs.c +++ b/refs.c @@ -3325,6

[PATCH 24/31] refs.c: make unlock_ref static

2014-05-14 Thread Ronnie Sahlberg
We no longer need to export unlock_ref. Make the function static. Signed-off-by: Ronnie Sahlberg --- refs.c | 20 ++-- refs.h | 3 --- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/refs.c b/refs.c index 17feec5..6933036 100644 --- a/refs.c +++ b/refs.c

[PATCH 13/31] refs.c: update the list of deleted refs during _update instead of _commit

2014-05-14 Thread Ronnie Sahlberg
When deleting refs during a transaction, update the list of the refs to be deleted already during _update instead of waiting until the _commit stage. Signed-off-by: Ronnie Sahlberg --- refs.c | 16 +++- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/refs.c b/refs.c

[PATCH 25/31] refs.c: make close_ref static

2014-05-14 Thread Ronnie Sahlberg
We no longer need to export close_ref. Make the function static. Signed-off-by: Ronnie Sahlberg --- refs.c | 2 +- refs.h | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/refs.c b/refs.c index 6933036..a430b22 100644 --- a/refs.c +++ b/refs.c @@ -2668,7 +2668,7 @@ int

[PATCH 20/31] refs.c: check for lock conflicts already in _update

2014-05-14 Thread Ronnie Sahlberg
eck for duplicates during _commit so all that code can be removed too. Signed-off-by: Ronnie Sahlberg --- refs.c | 85 +- 1 file changed, 42 insertions(+), 43 deletions(-) diff --git a/refs.c b/refs.c index 93f01e8..76cab6e 100

[PATCH 17/31] refs.c: make _update_reflog take an error argument

2014-05-14 Thread Ronnie Sahlberg
Add a strbug argument to the update reflog transaction call so we can return an error string back to the caller on failure. Signed-off-by: Ronnie Sahlberg --- builtin/reflog.c | 6 -- refs.c | 3 ++- refs.h | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff

[PATCH 12/31] refs.c: track the refnames we are deleting in the transaction structure

2014-05-14 Thread Ronnie Sahlberg
Track the names of the refs we are deleting in the ref_transaction structure instead of building an array of names during _commit. Signed-off-by: Ronnie Sahlberg --- refs.c | 35 +++ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/refs.c b/refs.c

[PATCH 21/31] refs.c allow multiple updates of the same ref in a transaction

2014-05-14 Thread Ronnie Sahlberg
such as this still fails: update ref a c update ref b b update ref c c Signed-off-by: Ronnie Sahlberg --- refs.c| 23 +-- t/t1400-update-ref.sh | 23 +-- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/refs.c b/refs.c

[PATCH 07/31] refs.c: add a flag to allow reflog updates to truncate the log

2014-05-14 Thread Ronnie Sahlberg
Add a flag that allows us to truncate the reflog before we write the update. Signed-off-by: Ronnie Sahlberg --- refs.c | 12 ++-- refs.h | 4 +++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/refs.c b/refs.c index d8a1568..a8b583a 100644 --- a/refs.c +++ b/refs.c

[PATCH 11/31] refs.c: null terminate the string in copy_msg

2014-05-14 Thread Ronnie Sahlberg
Signed-off-by: Ronnie Sahlberg --- refs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/refs.c b/refs.c index 5a5f9df..58bbf1b 100644 --- a/refs.c +++ b/refs.c @@ -2707,6 +2707,7 @@ static int copy_msg(char *buf, const char *msg) while (buf < cp && is

[PATCH 09/31] refs.c: allow multiple reflog updates during a single transaction

2014-05-14 Thread Ronnie Sahlberg
code such as: t = transaction_begin() transaction_reflog_update(t, "foo", REFLOG_TRUNCATE, NULL); loop-over-somehting... transaction_reflog_update(t, "foo", 0, ); transaction_commit(t) where we first truncate the reflog and then build the new content one line at a time. S

[PATCH 26/31] refs.c: make commit_ref static

2014-05-14 Thread Ronnie Sahlberg
We no longer need to export commit_ref. Make the function static. Signed-off-by: Ronnie Sahlberg --- refs.c | 2 +- refs.h | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/refs.c b/refs.c index a430b22..0cb4ae8 100644 --- a/refs.c +++ b/refs.c @@ -2676,7 +2676,7 @@ static

[PATCH 19/31] tests: move tests for -z update/delete/verify to after the ref is created

2014-05-14 Thread Ronnie Sahlberg
ould break after the next patch). Move these tests further down in the test to occur after we have created refs/heads/a so that there is only one error condition in the test and that we no longer depend on in which order the checks for error occur. Signed-off-by: Ronnie Sahlberg --- t/t1400-upd

[PATCH 14/31] refs.c: return error instead of dying when locking fails during transaction

2014-05-14 Thread Ronnie Sahlberg
Change lock_ref_sha1_basic to return an error instead of dying when we fail to lock a file during a transaction. Signed-off-by: Ronnie Sahlberg --- refs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/refs.c b/refs.c index 3249576..8212d77 100644 --- a/refs.c +++ b/refs.c

[PATCH 23/31] reflog.c: use the existing transaction to also lock and update the ref

2014-05-14 Thread Ronnie Sahlberg
reflog.c has a transaction for updating the reflog. Use this transaction also for locking the ref itself and updating the ref instead of locking the file directly and writing to it. This now completely eliminates the refs and reflog implementation from reflog.c. Signed-off-by: Ronnie Sahlberg

[PATCH 16/31] refs.c: add an error argument to create/delete/update just like commit

2014-05-14 Thread Ronnie Sahlberg
similarly. Signed-off-by: Ronnie Sahlberg --- branch.c | 3 ++- builtin/commit.c | 2 +- builtin/fetch.c| 2 +- builtin/receive-pack.c | 3 ++- builtin/replace.c | 2 +- builtin/tag.c | 2 +- builtin/update-ref.c | 20 fast

[PATCH 06/31] refs.c: add a transaction function to append a reflog entry

2014-05-14 Thread Ronnie Sahlberg
Define a new transaction update type, UPDATE_LOG, and a new function transaction_update_reflog. This function will lock the reflog and append an entry to it during transaction commit. Signed-off-by: Ronnie Sahlberg Conflicts: refs.h --- refs.c | 107

[PATCH 00/31] Finish implementing ref and reflog transactions

2014-05-14 Thread Ronnie Sahlberg
backends such as a TDB database. Ronnie Sahlberg (31): refs.c make ref_transaction_create a wrapper to ref_transaction_update refs.c: make ref_transaction_delete a wrapper for ref_transaction_update refs.c: rename the transaction functions refs.c: add a new update_type field to ref_update

[PATCH 10/31] reflog.c: use a reflog transaction when writing during expire

2014-05-14 Thread Ronnie Sahlberg
Use a transaction when doing the updates of the reflog during expire_reflog. Signed-off-by: Ronnie Sahlberg --- builtin/reflog.c | 54 ++ refs.c | 4 ++-- 2 files changed, 24 insertions(+), 34 deletions(-) diff --git a/builtin

[PATCH 03/31] refs.c: rename the transaction functions

2014-05-14 Thread Ronnie Sahlberg
Rename the transaction functions. Remove the leading ref_ from the names and append _sha1 to the names for functions that create/delete/update sha1 refs. Signed-off-by: Ronnie Sahlberg --- branch.c | 10 +++--- builtin/commit.c | 14 builtin/fetch.c| 10

[PATCH 04/31] refs.c: add a new update_type field to ref_update

2014-05-14 Thread Ronnie Sahlberg
Add a field that describes what type of update this refers to. For now the only type is UPDATE_SHA1 but we will soon add more types. Signed-off-by: Ronnie Sahlberg --- refs.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/refs.c b/refs.c index 6785fa6..018062d

[PATCH 02/31] refs.c: make ref_transaction_delete a wrapper for ref_transaction_update

2014-05-14 Thread Ronnie Sahlberg
We want to allow to delete a ref even if it only exists as a packed ref so we must tweak the REF_ISPACKONLY test in _update so it only applies to the non-delete case. Signed-off-by: Ronnie Sahlberg --- refs.c | 17 ++--- refs.h | 2 +- 2 files changed, 7 insertions(+), 12 deletions

Re: [PATCH v6 05/42] update-ref.c: log transaction error from the update_ref

2014-05-15 Thread Ronnie Sahlberg
On Wed, May 14, 2014 at 3:08 PM, Jonathan Nieder wrote: > Hi, > > Ronnie Sahlberg wrote: > >> --- a/builtin/update-ref.c >> +++ b/builtin/update-ref.c >> @@ -342,6 +342,7 @@ int cmd_update_ref(int argc, const char **argv, const >> char *prefix) > [...] >

Re: [PATCH v6 08/42] refs.c: change ref_transaction_update() to do error checking and return status

2014-05-15 Thread Ronnie Sahlberg
On Wed, May 14, 2014 at 4:40 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > >> Update ref_transaction_update() do some basic error checking and return >> true on error. Update all callers to check ref_transaction_update() for >> error. >> There are currently

Re: [PATCH v6 09/42] refs.c: change ref_transaction_create to do error checking and return status

2014-05-15 Thread Ronnie Sahlberg
On Wed, May 14, 2014 at 5:04 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > >> Do basic error checking in ref_transaction_create() and make it return >> status. Update all callers to check the result of ref_transaction_create() >> There are currently no conditi

Re: [PATCH v6 10/42] refs.c: ref_transaction_delete to check for error and return status

2014-05-15 Thread Ronnie Sahlberg
On Wed, May 14, 2014 at 5:19 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > >> Change ref_transaction_delete() to do basic error checking and return >> status. Update all callers to check the return for ref_transaction_delete() >> There are currently no conditi

Re: [PATCH v6 11/42] tag.c: use ref transactions when doing updates

2014-05-15 Thread Ronnie Sahlberg
On Wed, May 14, 2014 at 5:27 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > >> --- a/builtin/tag.c >> +++ b/builtin/tag.c >> @@ -701,11 +702,12 @@ int cmd_tag(int argc, const char **argv, const char >> *prefix) >> if (annotate) >>

Re: [PATCH v6 12/42] replace.c: use the ref transaction functions for updates

2014-05-15 Thread Ronnie Sahlberg
On Wed, May 14, 2014 at 5:30 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > > [...] >> +++ b/builtin/replace.c > [...] >> @@ -157,11 +158,12 @@ static int replace_object(const char *object_ref, >> const char *replace_ref, >> else if (!force) &

Re: [PATCH v6 13/42] commit.c: use ref transactions for updates

2014-05-15 Thread Ronnie Sahlberg
On Wed, May 14, 2014 at 6:11 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > > [...] >> +++ b/builtin/commit.c >> @@ -1541,11 +1541,12 @@ int cmd_commit(int argc, const char **argv, const >> char *prefix) > [...] >> @@ -1667,16 +1668,6 @@ int cmd_commi

[PATCH v8 04/44] refs.c: add an err argument to repack_without_refs

2014-05-15 Thread Ronnie Sahlberg
Update repack_without_refs to take an err argument and update it if there is a failure. Pass the err variable from ref_transaction_commit to this function so that callers can print a meaningful error message if _commit fails due to a problem in repack_without_refs. Signed-off-by: Ronnie Sahlberg

[PATCH v8 01/44] refs.c: constify the sha arguments for ref_transaction_create|delete|update

2014-05-15 Thread Ronnie Sahlberg
ref_transaction_update() in which case this change is required. Signed-off-by: Ronnie Sahlberg --- refs.c | 7 --- refs.h | 7 --- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/refs.c b/refs.c index 6898263..2114748 100644 --- a/refs.c +++ b/refs.c @@ -3338,7 +3338,8

[PATCH v8 25/44] receive-pack.c: use a reference transaction for updating the refs

2014-05-15 Thread Ronnie Sahlberg
Wrap all the ref updates inside a transaction to make the update atomic. Signed-off-by: Ronnie Sahlberg --- builtin/receive-pack.c | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index c323081..d580176

[PATCH v8 20/44] refs.c: free the transaction before returning when number of updates is 0

2014-05-15 Thread Ronnie Sahlberg
We have to free the transaction before returning in the early check for 'return early if number of updates == 0' or else the following code would create a memory leak with the transaction never being freed : t = ref_transaction_begin() ref_transaction_commit(t) Signed-off-

[PATCH v8 22/44] fetch.c: clear errno before calling functions that might set it

2014-05-15 Thread Ronnie Sahlberg
unrelated ENOTDIR may cause us to return the wrong error. Clear errno before calling any functions if we check errno afterwards. Also skip initializing a static variable to 0. Statics live in .bss and are all automatically initialized to 0. Signed-off-by: Ronnie Sahlberg --- builtin/fetch.c | 4

[PATCH v8 24/44] fetch.c: use a single ref transaction for all ref updates

2014-05-15 Thread Ronnie Sahlberg
re correct, since if there was a problem we would not even try to commit the transaction but need to highlight this change in how/what errors are reported. This change in what error is returned only occurs if there are multiple refs that fail to update and only some, but not all, of them fail due

[PATCH v8 17/44] fast-import.c: change update_branch to use ref transactions

2014-05-15 Thread Ronnie Sahlberg
Change update_branch() to use ref transactions for updates. Signed-off-by: Ronnie Sahlberg --- fast-import.c | 22 ++ 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/fast-import.c b/fast-import.c index 6707a66..79d219b 100644 --- a/fast-import.c +++ b/fast

[PATCH v8 28/44] refs.c: make write_ref_sha1 static

2014-05-15 Thread Ronnie Sahlberg
No external users call write_ref_sha1 any more so lets declare it static. Signed-off-by: Ronnie Sahlberg --- refs.c | 4 +++- refs.h | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/refs.c b/refs.c index 82a8d4e..e5729ad 100644 --- a/refs.c +++ b/refs.c @@ -251,6 +251,8

[PATCH v8 26/44] fast-import.c: use a ref transaction when dumping tags

2014-05-15 Thread Ronnie Sahlberg
Signed-off-by: Ronnie Sahlberg --- fast-import.c | 17 - 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/fast-import.c b/fast-import.c index 3e356da..5587cf6 100644 --- a/fast-import.c +++ b/fast-import.c @@ -1736,15 +1736,22 @@ static void dump_tags(void

[PATCH v8 11/44] refs.c: change ref_transaction_create to do error checking and return status

2014-05-15 Thread Ronnie Sahlberg
Do basic error checking in ref_transaction_create() and make it return non-zero on error. Update all callers to check the result of ref_transaction_create(). There are currently no conditions in _create that will return error but there will be in the future. Signed-off-by: Ronnie Sahlberg

[PATCH v8 31/44] refs.c: remove the update_ref_lock function

2014-05-15 Thread Ronnie Sahlberg
Since we now only call update_ref_lock with onerr==QUIET_ON_ERR we no longer need this function and can replace it with just calling lock_any_ref_for_update directly. Signed-off-by: Ronnie Sahlberg --- refs.c | 30 ++ 1 file changed, 6 insertions(+), 24 deletions

  1   2   3   4   5   6   7   8   9   10   >