[PATCH v9 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

[PATCH v9 29/44] refs.c: make lock_ref_sha1 static

2014-05-15 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 6151c3c..733dfb3 100644 --- a/refs.c +++ b/refs.c @@ -2126,7

[PATCH v9 08/44] update-ref.c: log transaction error from the update_ref

2014-05-15 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. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- builtin/update-ref.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff

[PATCH v9 10/44] refs.c: change ref_transaction_update() to do error checking and return status

2014-05-15 Thread Ronnie Sahlberg
on failure. Also check for BUGs during update and die(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 | 12 +++- refs.c | 18 -- refs.h | 14

[PATCH v9 32/44] refs.c: remove the update_ref_write function

2014-05-15 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 v9 19/44] refs.c: change update_ref to use a transaction

2014-05-15 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 7276b9f..5e82695 100644 --- a/refs.c +++ b/refs.c @@ -3447,11

[PATCH v9 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..5534138

[PATCH v9 02/44] refs.c: allow passing NULL to ref_transaction_free

2014-05-15 Thread Ronnie Sahlberg
. } 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 --- a/refs.c +++ b/refs.c @@ -3312,6 +3312,9 @@ static void ref_transaction_free(struct ref_transaction *transaction) {

[PATCH v9 13/44] tag.c: use ref transactions when doing updates

2014-05-15 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..b05f9a5 100644 --- a/builtin/tag.c +++ b/builtin/tag.c

[PATCH v9 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 v9 41/44] refs.c: add a new flag for transaction delete for refs we know are packed only

2014-05-15 Thread Ronnie Sahlberg
: Ronnie Sahlberg --- refs.c | 23 +++ 1 file changed, 23 insertions(+) diff --git a/refs.c b/refs.c index 87113af..6299b3d 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 v9 15/44] commit.c: use ref transactions for updates

2014-05-15 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. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- builtin/commit.c | 23 ++- 1 file changed, 10 insertions(+), 13

Re: [PATCH v8 21/44] refs.c: ref_transaction_commit should not free the transaction

2014-05-16 Thread Ronnie Sahlberg
On Thu, May 15, 2014 at 5:20 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > >> Change ref_transaction_commit so that it does not free the transaction. >> Instead require that a caller will end a transaction by either calling >> ref_transaction_rollback or ref_tra

Re: [PATCH v8 21/44] refs.c: ref_transaction_commit should not free the transaction

2014-05-16 Thread Ronnie Sahlberg
On Fri, May 16, 2014 at 8:02 AM, Ronnie Sahlberg wrote: > On Thu, May 15, 2014 at 5:20 PM, Jonathan Nieder wrote: >> Ronnie Sahlberg wrote: >> >>> Change ref_transaction_commit so that it does not free the transaction. >>> Instead require that a caller will en

[PATCH v10 06/44] refs.c: add an err argument to delete_ref_loose

2014-05-16 Thread Ronnie Sahlberg
unlink_or_err that we can call from delete_ref_loose. This function is similar to unlink_or_warn except that we can pass it an err argument. If err is non-NULL the function will populate err instead of printing a warning(). Signed-off-by: Ronnie Sahlberg --- refs.c | 39

[PATCH v10 00/44] Use ref transactions for all ref updates

2014-05-16 Thread Ronnie Sahlberg
garbage pointer for current_head->object.sha1 and relied on the fact that ref_transaction_update would not try to dereference this pointer if !!current_head was 0. - Updated commit message for the walker_fetch change to try to justify why the change in locking semantics should not be harm

[PATCH v10 16/44] sequencer.c: use ref transactions for all ref updates

2014-05-16 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..b047fb8 100644 --- a/sequencer.c +++ b/sequencer.c

[PATCH v10 18/44] branch.c: use ref transaction for all ref updates

2014-05-16 Thread Ronnie Sahlberg
lock_any_ref_for_update/write_ref_sha1 did not protect against the ref already existing. I.e. one thread could end up overwriting a branch even if the forcing flag is false. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- branch.c | 29 +++-- 1 file changed, 15

[PATCH v10 21/44] refs.c: ref_transaction_commit should not free the transaction

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

[PATCH v10 19/44] refs.c: change update_ref to use a transaction

2014-05-16 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 a588194..78312b5 100644 --- a/refs.c +++ b/refs.c @@ -3442,11

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

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

[PATCH v10 35/44] refs.c: make delete_ref use a transaction

2014-05-16 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 v10 13/44] tag.c: use ref transactions when doing updates

2014-05-16 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..b05f9a5 100644 --- a/builtin/tag.c +++ b/builtin/tag.c

[PATCH v10 41/44] refs.c: add a new flag for transaction delete for refs we know are packed only

2014-05-16 Thread Ronnie Sahlberg
: Ronnie Sahlberg --- refs.c | 23 +++ 1 file changed, 23 insertions(+) diff --git a/refs.c b/refs.c index 564feb6..c5d41bb 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 v10 23/44] fetch.c: change s_update_ref to use a ref transaction

2014-05-16 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..8cf70cd 100644 --- a/builtin/fetch.c +++ b

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

2014-05-16 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 cb3f5af..9c76c73 100644 --- a/fast-import.c +++ b/fast-import.c @@ -1735,15 +1735,22 @@ static void dump_tags(void

[PATCH v10 27/44] walker.c: use ref transaction for ref updates

2014-05-16 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 v10 44/44] refs.c: remove forward declaration of write_ref_sha1

2014-05-16 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 71e3059..bf84306 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 v10 42/44] refs.c: pass a skip list to name_conflict_fn

2014-05-16 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 v10 32/44] refs.c: remove the update_ref_write function

2014-05-16 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 v10 43/44] refs.c: make rename_ref use a transaction

2014-05-16 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 3967333..71e3059

[PATCH v10 38/44] refs.c: pack all refs before we start to rename a ref

2014-05-16 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 v10 33/44] refs.c: remove lock_ref_sha1

2014-05-16 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 v10 39/44] refs.c: move the check for valid refname to lock_ref_sha1_basic

2014-05-16 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 f4899e0..f63a356 100644 --- a/refs.c

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

2014-05-16 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 v10 40/44] refs.c: call lock_ref_sha1_basic directly from commit

2014-05-16 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 f63a356..564feb6 100644 --- a/refs.c

[PATCH v10 29/44] refs.c: make lock_ref_sha1 static

2014-05-16 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 93e2cd2..2d9789f 100644 --- a/refs.c +++ b/refs.c @@ -2126,7

[PATCH v10 09/44] refs.c: remove the onerr argument to ref_transaction_commit

2014-05-16 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. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- builtin/update-ref.c | 3 +-- refs.c | 22

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

2014-05-16 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 v10 25/44] receive-pack.c: use a reference transaction for updating the refs

2014-05-16 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..5534138

[PATCH v10 08/44] update-ref.c: log transaction error from the update_ref

2014-05-16 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. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- builtin/update-ref.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff

[PATCH v10 07/44] refs.c: make update_ref_write update a strbuf on failure

2014-05-16 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. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- refs.c | 9 ++--- 1

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

2014-05-16 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 266a792..93e2cd2 100644 --- a/refs.c +++ b/refs.c @@ -251,6 +251,8

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

2014-05-16 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 v10 02/44] refs.c: allow passing NULL to ref_transaction_free

2014-05-16 Thread Ronnie Sahlberg
. } 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 3b7e604..6357089 100644 --- a/refs.c +++ b/refs.c @@ -3312,6 +3312,9 @@ void ref_transaction_free(struct ref_transaction *transaction) {

[PATCH v10 34/44] refs.c: make prune_ref use a transaction to delete the ref

2014-05-16 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 v10 20/44] refs.c: free the transaction before returning when number of updates is 0

2014-05-16 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 v10 15/44] commit.c: use ref transactions for updates

2014-05-16 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. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- builtin/commit.c | 23 ++- 1 file changed, 10 insertions(+), 13

[PATCH v10 12/44] refs.c: ref_transaction_delete to check for error and return status

2014-05-16 Thread Ronnie Sahlberg
updated on failure. Signed-off-by: Ronnie Sahlberg --- builtin/update-ref.c | 5 +++-- refs.c | 16 +++- refs.h | 12 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/builtin/update-ref.c b/builtin/update-ref.c index e9c216e..cdb71a8

[PATCH v10 10/44] refs.c: change ref_transaction_update() to do error checking and return status

2014-05-16 Thread Ronnie Sahlberg
on failure. Also check for BUGs during update and die(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 | 12 +++- refs.c | 18 -- refs.h | 14

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

2014-05-16 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 v10 05/44] refs.c: make ref_update_reject_duplicates take a strbuf argument for errors

2014-05-16 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 v10 30/44] refs.c: add transaction.status and track OPEN/CLOSED/ERROR

2014-05-16 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 | 26 +- 1 file changed, 25 insertions

[PATCH v10 14/44] replace.c: use the ref transaction functions for updates

2014-05-16 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..e8932cd 100644 --- a/builtin/replace.c +++ b/builtin

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

2014-05-16 Thread Ronnie Sahlberg
ref_transaction_update() in which case this change is required. Reviewed-by: Jonathan Nieder 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 48573e3..3b7e604 100644 --- a/refs.c +++ b

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

2014-05-16 Thread Ronnie Sahlberg
updated on failure. Signed-off-by: Ronnie Sahlberg --- builtin/update-ref.c | 4 +++- refs.c | 18 -- refs.h | 12 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/builtin/update-ref.c b/builtin/update-ref.c index 9f328b2

[PATCH v10 36/44] refs.c: pass the ref log message to _create/delete/update instead of _commit

2014-05-16 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 | 4

[PATCH v10 37/44] refs.c: pass NULL as *flags to read_ref_full

2014-05-16 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 98f3c85

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

2014-05-16 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

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

2014-05-16 Thread Ronnie Sahlberg
t;)); - return 1; + return STORE_REF_ERROR_OTHER; } } To make it more clear that this function returns a specific error and not just a generic not-zero. On Fri, May 16, 2014 at 11:33 AM, Jonathan Nieder wrote: > (cc-ing peff, who may remember this STORE_REF_ERROR_D

Re: [PATCH v8 23/44] fetch.c: change s_update_ref to use a ref transaction

2014-05-16 Thread Ronnie Sahlberg
On Fri, May 16, 2014 at 12:12 PM, Jonathan Nieder wrote: > (+cc: peff for STORE_REF_ERROR_DF_CONFLICT expertise) > Ronnie Sahlberg wrote: > >> --- a/builtin/fetch.c >> +++ b/builtin/fetch.c >> @@ -375,7 +375,7 @@ static int s_update_ref(const char *action, &

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

2014-05-19 Thread Ronnie Sahlberg
On Fri, May 16, 2014 at 3:52 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > >> Change store_updated_refs to use a single ref transaction for all refs that >> are updated during the fetch. This makes the fetch more atomic when update >> failures occur. > > F

Re: [PATCH v8 23/44] fetch.c: change s_update_ref to use a ref transaction

2014-05-19 Thread Ronnie Sahlberg
On Fri, May 16, 2014 at 3:54 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > >> --- a/builtin/fetch.c >> +++ b/builtin/fetch.c > [...] >> @@ -384,15 +384,16 @@ static int s_update_ref(const char *action, >> snprintf(msg, sizeof(msg), "%s: %s

Re: [PATCH v10 13/44] tag.c: use ref transactions when doing updates

2014-05-19 Thread Ronnie Sahlberg
On Sat, May 17, 2014 at 6:09 AM, Michael Haggerty wrote: > On 05/16/2014 07:37 PM, Ronnie Sahlberg wrote: >> Change tag.c to use ref transactions for all ref updates. >> >> Signed-off-by: Ronnie Sahlberg >> --- >> builtin/tag.c | 14 -- >&

Re: [PATCH v10 18/44] branch.c: use ref transaction for all ref updates

2014-05-19 Thread Ronnie Sahlberg
On Sat, May 17, 2014 at 6:33 AM, Michael Haggerty wrote: > On 05/16/2014 07:37 PM, Ronnie Sahlberg wrote: >> Change create_branch to use a ref transaction when creating the new branch. >> ref_transaction_create will check that the ref does not already exist and >> fail >

Re: [PATCH v10 13/44] tag.c: use ref transactions when doing updates

2014-05-19 Thread Ronnie Sahlberg
I have moved the patch to add &err to ref_transaction_begin to the current patch series. Please see https://github.com/rsahlberg/git/tree/ref-transactions On Mon, May 19, 2014 at 10:16 AM, Ronnie Sahlberg wrote: > On Sat, May 17, 2014 at 6:09 AM, Michael Haggerty > wrote: >>

Re: [PATCH v10 14/44] replace.c: use the ref transaction functions for updates

2014-05-19 Thread Ronnie Sahlberg
014 07:37 PM, Ronnie Sahlberg wrote: >> 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 --g

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

2014-05-19 Thread Ronnie Sahlberg
On Sat, May 17, 2014 at 8:35 AM, Michael Haggerty wrote: > On 05/16/2014 07:37 PM, Ronnie Sahlberg wrote: >> Wrap all the ref updates inside a transaction to make the update atomic. >> >> Signed-off-by: Ronnie Sahlberg >> --- >> builtin/receive-pack.c | 2

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

2014-05-19 Thread Ronnie Sahlberg
On Fri, May 16, 2014 at 2:24 PM, Junio C Hamano wrote: > Ronnie Sahlberg writes: > >> 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 trun

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

2014-05-19 Thread Ronnie Sahlberg
On Fri, May 16, 2014 at 3:01 PM, Eric Sunshine wrote: > On Fri, May 16, 2014 at 5:35 PM, Junio C Hamano wrote: >> Ronnie Sahlberg writes: >> >>> Allow to make multiple reflog updates to the same ref during a transaction. >>> This means we only need to lock

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

2014-05-19 Thread Ronnie Sahlberg
On Fri, May 16, 2014 at 2:35 PM, Junio C Hamano wrote: > Ronnie Sahlberg writes: > >> Allow to make multiple reflog updates to the same ref during a transaction. >> This means we only need to lock the reflog once, during the first update that >> touches the reflog, and

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

2014-05-19 Thread Ronnie Sahlberg
On Fri, May 16, 2014 at 2:15 PM, Junio C Hamano wrote: > Ronnie Sahlberg writes: > >> 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. >> ..

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

2014-05-19 Thread Ronnie Sahlberg
On Fri, May 16, 2014 at 2:20 PM, Junio C Hamano wrote: > Ronnie Sahlberg writes: > >> Add a flag that allows us to truncate the reflog before we write the update. >> >> Signed-off-by: Ronnie Sahlberg >> --- > > Until we read the callers it is hard to see ho

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

2014-05-20 Thread Ronnie Sahlberg
On Tue, May 20, 2014 at 12:42 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > >> Wrap all the ref updates inside a transaction to make the update atomic. > > Interesting. > > [...] >> --- a/builtin/receive-pack.c >> +++ b/builtin/receive-pac

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

2014-05-20 Thread Ronnie Sahlberg
On Tue, May 20, 2014 at 1:38 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > >> [Subject: fast-import.c: use a ref transaction when dumping tags] > > This seems like an odd thing to do: either it would make sense to have > a single transaction for all imported refs s

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

2014-05-21 Thread Ronnie Sahlberg
Thanks! On Tue, May 20, 2014 at 5:51 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > >> No external users call write_ref_sha1 any more so lets declare it static. > > Yay! > > [...] >> +++ b/refs.c >> @@ -251,6 +251,8 @@ struct ref_entry { > [...] >

Re: [PATCH v8 27/44] walker.c: use ref transaction for ref updates

2014-05-21 Thread Ronnie Sahlberg
On Tue, May 20, 2014 at 5:46 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > >> This changes the locking slightly for walker_fetch. Previously the code would >> lock all refs before writing them but now we do not lock the refs until the >> commit stage. There is

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

2014-05-21 Thread Ronnie Sahlberg
On Tue, May 20, 2014 at 1:37 PM, Ronnie Sahlberg wrote: > On Tue, May 20, 2014 at 12:42 PM, Jonathan Nieder wrote: >> Ronnie Sahlberg wrote: >> >>> Wrap all the ref updates inside a transaction to make the update atomic. >> >> Interesting. >> >>

Re: [PATCH v8 30/44] refs.c: add transaction.status and track OPEN/CLOSED/ERROR

2014-05-21 Thread Ronnie Sahlberg
Please pull my ref-transactions branch. On Wed, May 21, 2014 at 3:00 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > >> --- a/refs.c >> +++ b/refs.c >> @@ -3308,6 +3308,12 @@ struct ref_update { >> const char refname[FLEX_ARRAY]; >> }

Re: [PATCH v8 35/44] refs.c: make delete_ref use a transaction

2014-05-22 Thread Ronnie Sahlberg
On Wed, May 21, 2014 at 4:22 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > >> --- a/refs.c >> +++ b/refs.c > [...] >> @@ -2515,24 +2510,18 @@ static int delete_ref_loose(struct ref_lock *lock, >> int flag, struct strbuf *err) >> >> int delete

Re: [PATCH v8 36/44] refs.c: pass the ref log message to _create/delete/update instead of _commit

2014-05-22 Thread Ronnie Sahlberg
On Wed, May 21, 2014 at 4:47 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > >> Change the reference transactions so that we pass the reflog message >> through to the create/delete/update function instead of the commit message. > > Nice. > > [...] >> --

Re: [PATCH v8 38/44] refs.c: pack all refs before we start to rename a ref

2014-05-22 Thread Ronnie Sahlberg
On Wed, May 21, 2014 at 4:57 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > >> This means that most loose refs will no longer be present after the rename > > Is this to handle the "git branch -m foo/bar foo" case or for some other > purpose

Re: [PATCH v8 35/44] refs.c: make delete_ref use a transaction

2014-05-22 Thread Ronnie Sahlberg
On Thu, May 22, 2014 at 8:32 AM, Ronnie Sahlberg wrote: > On Wed, May 21, 2014 at 4:22 PM, Jonathan Nieder wrote: >> Ronnie Sahlberg wrote: >> >>> --- a/refs.c >>> +++ b/refs.c >> [...] >>> @@ -2515,24 +2510,18 @@ static int delete_ref_loose(str

Re: [PATCH v8 32/44] refs.c: remove the update_ref_write function

2014-05-22 Thread Ronnie Sahlberg
On Wed, May 21, 2014 at 3:07 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > >> +++ b/refs.c > [...] >> @@ -3518,14 +3499,16 @@ int ref_transaction_commit(struct ref_transaction >> *transaction, >> struct ref_update *update = updates[i]; >

Re: [PATCH v8 34/44] refs.c: make prune_ref use a transaction to delete the ref

2014-05-22 Thread Ronnie Sahlberg
Added a comment that any flags >=0x100 are reserved for internal use. On Wed, May 21, 2014 at 4:01 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > >> Change prune_ref to delete the ref using a ref transaction. To do this we >> also >> need to add a new flag R

Re: [PATCH v8 30/44] refs.c: add transaction.status and track OPEN/CLOSED/ERROR

2014-05-22 Thread Ronnie Sahlberg
On Wed, May 21, 2014 at 3:22 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > >> Please pull my ref-transactions branch. > > I'm at bd5736cb (2014-05-21 13:46) now. > >> On Wed, May 21, 2014 at 3:00 PM, Jonathan Nieder wrote: >>> Ronnie Sahlberg wro

Re: [PATCH v8 39/44] refs.c: move the check for valid refname to lock_ref_sha1_basic

2014-05-22 Thread Ronnie Sahlberg
On Wed, May 21, 2014 at 6:42 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: >> --- a/refs.c >> +++ b/refs.c >> @@ -2044,6 +2044,9 @@ static struct ref_lock *lock_ref_sha1_basic(const char >> *refname, >> int missing = 0; >> int

Re: [PATCH v8 39/44] refs.c: move the check for valid refname to lock_ref_sha1_basic

2014-05-22 Thread Ronnie Sahlberg
On Thu, May 22, 2014 at 10:44 AM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: >> On Wed, May 21, 2014 at 6:42 PM, Jonathan Nieder wrote: > >>> $ git rev-parse HEAD >.git/refs/heads/foo..bar >>> $ git branch -m foo..bar something-saner >&

Re: [PATCH v8 38/44] refs.c: pack all refs before we start to rename a ref

2014-05-22 Thread Ronnie Sahlberg
On Thu, May 22, 2014 at 10:51 AM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: >> On Wed, May 21, 2014 at 4:57 PM, Jonathan Nieder wrote: >>> Ronnie Sahlberg wrote: > >>>> This means that most loose refs will no longer be present after the rename >>>

Re: [PATCH v8 41/44] refs.c: add a new flag for transaction delete for refs we know are packed only

2014-05-22 Thread Ronnie Sahlberg
On Thu, May 22, 2014 at 11:17 AM, Jonathan Nieder wrote: > Hi, > > Ronnie Sahlberg wrote: > >> Add a new flag REF_ISPACKONLY that we can use in ref_transaction_delete. >> This flag indicates that the ref does not exist as a loose ref andf only as >> a packed re

Re: [PATCH v8 41/44] refs.c: add a new flag for transaction delete for refs we know are packed only

2014-05-22 Thread Ronnie Sahlberg
w us to have rename_ref becoming reasonably implementation agnostic, aside for that it wants to lstat the ref to see if it is a soft link, and re-use the code for other refs backends. Please see the ref-transaction branch. On Thu, May 22, 2014 at 12:12 PM, Ronnie Sahlberg wrote: > On Thu, May

Re: [PATCH v8 41/44] refs.c: add a new flag for transaction delete for refs we know are packed only

2014-05-23 Thread Ronnie Sahlberg
On Thu, May 22, 2014 at 4:53 PM, Jonathan Nieder wrote: > Jonathan Nieder wrote: >> Ronnie Sahlberg wrote: > >>> I hate rename_ref :-) >>> >>> I have reworked the transaction code to special case the deletion of >>> the old ref for n/n -> n and

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

2014-05-23 Thread Ronnie Sahlberg
On Fri, May 23, 2014 at 6:49 AM, Michael Haggerty wrote: > On 05/19/2014 09:02 PM, Ronnie Sahlberg wrote: >> On Sat, May 17, 2014 at 8:35 AM, Michael Haggerty >> wrote: >>> On 05/16/2014 07:37 PM, Ronnie Sahlberg wrote: >>>> Wrap all the ref updates ins

Re: [PATCH v8 42/44] refs.c: pass a skip list to name_conflict_fn

2014-05-27 Thread Ronnie Sahlberg
On Thu, May 22, 2014 at 12:27 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > >> --- a/refs.c >> +++ b/refs.c >> @@ -798,11 +798,19 @@ struct name_conflict_cb { >> const char *refname; >> const char *oldrefname; >> const char

Re: [PATCH v8 00/44] Use ref transactions for all ref updates

2014-05-27 Thread Ronnie Sahlberg
On Thu, May 22, 2014 at 4:08 PM, Jonathan Nieder wrote: > Ronnie Sahlberg wrote: > >> This patch series can also be found at >> https://github.com/rsahlberg/git/tree/ref-transactions > > Continuing with the review of 65a1cb7b (2014-05-22 12:08): > > 11/40 change

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

2014-05-27 Thread Ronnie Sahlberg
On Sat, May 17, 2014 at 7:56 AM, Michael Haggerty wrote: > On 05/16/2014 07:37 PM, Ronnie Sahlberg wrote: >> In s_update_ref there are two calls that when they fail we return an error >> based on the errno value. In particular we want to return a specific error >> if ENOTDIR

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

2014-05-27 Thread Ronnie Sahlberg
On Sat, May 17, 2014 at 5:40 AM, Michael Haggerty wrote: > On 05/16/2014 07:36 PM, Ronnie Sahlberg wrote: >> 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 tha

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

2014-05-27 Thread Ronnie Sahlberg
On Fri, May 23, 2014 at 2:02 PM, Michael Haggerty wrote: > On 05/23/2014 06:14 PM, Ronnie Sahlberg wrote: >> On Fri, May 23, 2014 at 6:49 AM, Michael Haggerty >> wrote: >>> [...] >>> When I combine these two lines of thought, it suggests to me that we >&g

[PATCH v11 00/41] Use ref transactions

2014-05-27 Thread Ronnie Sahlberg
reflogs but all that will go in a different patch series. Version 11: - Updates after JNs review of the series. Ronnie Sahlberg (41): refs.c: remove ref_transaction_rollback refs.c: ref_transaction_commit should not free the transaction refs.c: constify the sha arguments for

[PATCH v11 34/41] refs.c: pass NULL as *flags to read_ref_full

2014-05-27 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. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- refs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/refs.c

<    1   2   3   4   5   6   7   8   9   10   >