[PATCH v3 13/30] rollback_packed_refs(): take a `packed_ref_store *` parameter

2017-07-01 Thread Michael Haggerty
It only cares about the packed-refs part of the reference store. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 15 +++ 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index 5d159620f0..a08d3fbadf 100644 --- a

[PATCH v3 30/30] read_packed_refs(): die if `packed-refs` contains bogus data

2017-07-01 Thread Michael Haggerty
The old code ignored any lines that it didn't understand, including unterminated lines. This is dangerous. Instead, `die()` if the `packed-refs` file contains any unterminated lines or lines that we don't know how to handle. This fixes the tests added in the last commit. Signed-off-b

[PATCH v3 21/30] commit_packed_refs(): report errors rather than dying

2017-07-01 Thread Michael Haggerty
Report errors via a `struct strbuf *err` rather than by calling `die()`. To enable this goal, change `write_packed_entry()` to report errors via a return value and `errno` rather than dying. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 10 +++--- refs/packed-backend.c | 85

[PATCH v3 18/30] packed_read_raw_ref(): new function, replacing `resolve_packed_ref()`

2017-07-01 Thread Michael Haggerty
Add a new function, `packed_read_raw_ref()`, which is nearly a `read_raw_ref_fn`. Use it in place of `resolve_packed_ref()`. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 36 +--- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/refs

[PATCH v3 29/30] t3210: add some tests of bogus packed-refs file contents

2017-07-01 Thread Michael Haggerty
If `packed-refs` contains indecipherable lines, we should emit an error and quit rather than just skipping the lines. Unfortunately, we currently do the latter. Add some failing tests demonstrating the problem. This will be fixed in the next commit. Signed-off-by: Michael Haggerty --- t/t3210

[PATCH v3 26/30] clear_packed_ref_cache(): don't protest if the lock is held

2017-07-01 Thread Michael Haggerty
The existing callers already check that the lock isn't held just before calling `clear_packed_ref_cache()`, and in the near future we want to be able to call this function when the lock is held. Signed-off-by: Michael Haggerty --- refs/packed-backend.c | 2 -- 1 file changed, 2 dele

[PATCH v3 22/30] commit_packed_refs(): use a staging file separate from the lockfile

2017-07-01 Thread Michael Haggerty
shortly. Signed-off-by: Michael Haggerty --- refs/packed-backend.c | 40 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/refs/packed-backend.c b/refs/packed-backend.c index 18ce47fcb7..71f92ed6f0 100644 --- a/refs/packed-backend.c +++ b/refs

[PATCH v3 23/30] packed_refs_lock(): function renamed from lock_packed_refs()

2017-07-01 Thread Michael Haggerty
Rename `lock_packed_refs()` to `packed_refs_lock()` for consistency with how other methods are named. Also, it's about to get some companions. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 4 ++-- refs/packed-backend.c | 10 +- refs/packed-backend.h | 2 +- 3

[PATCH v3 24/30] packed_refs_lock(): report errors via a `struct strbuf *err`

2017-07-01 Thread Michael Haggerty
That way the callers don't have to come up with error messages themselves. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 6 ++ refs/packed-backend.c | 17 +++-- refs/packed-backend.h | 6 +++--- 3 files changed, 16 insertions(+), 13 deletions(-) diff --

[PATCH v3 28/30] repack_without_refs(): don't lock or unlock the packed refs

2017-07-01 Thread Michael Haggerty
will eventually make it possible to fix some longstanding races. The only semantic change here is that `repack_without_refs()` used to forget to release the lock in the `if (!removed)` exit path. That omission is now fixed. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 47

[PATCH v3 27/30] commit_packed_refs(): remove call to `packed_refs_unlock()`

2017-07-01 Thread Michael Haggerty
Instead, change the callers of `commit_packed_refs()` to call `packed_refs_unlock()`. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 2 ++ refs/packed-backend.c | 18 -- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/refs/files-backend.c b/refs

[PATCH v3 25/30] packed_refs_unlock(), packed_refs_is_locked(): new functions

2017-07-01 Thread Michael Haggerty
Add two new public functions, `packed_refs_unlock()` and `packed_refs_is_locked()`, with which callers can manage and query the `packed-refs` lock externally. Call `packed_refs_unlock()` from `commit_packed_refs()` and `rollback_packed_refs()`. Signed-off-by: Michael Haggerty --- refs/packed

Re: reftable: new ref storage format

2017-07-16 Thread Michael Haggerty
Thanks for your reftable proposal. It would solve a lot of scalability problems that we currently have, and do it in a way that is implementable in both C and Java, which is very nice. There are two mostly orthogonal components to your proposal: 1. What does a single reftable file look like? 2. H

Re: [PATCH] files_initial_transaction_commit(): only unlock if locked

2018-01-22 Thread Michael Haggerty
On 01/19/2018 11:14 PM, Junio C Hamano wrote: > Jeff King writes: > >> On Thu, Jan 18, 2018 at 02:38:41PM +0100, Mathias Rav wrote: >> >>> Running git clone --single-branch --mirror -b TAGNAME previously >>> triggered the following error message: >>> >>> fatal: multiple updates for ref 'refs/

Re: [PATCH v3] packed_ref_cache: don't use mmap() for small files

2018-01-24 Thread Michael Haggerty
On 01/22/2018 08:31 PM, Junio C Hamano wrote: > Michael Haggerty writes: > >> `snapshot->buf` can still be NULL if the `packed-refs` file didn't exist >> (see the earlier code path in `load_contents()`). So either that code >> path *also* has to get the `xmalloc

[PATCH 3/6] find_reference_location(): make function safe for empty snapshots

2018-01-24 Thread Michael Haggerty
ed NULL when `mustexist` was false, contrary to its docstring. Change the check and fix the docstring. Signed-off-by: Michael Haggerty --- refs/packed-backend.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/refs/packed-backend.c b/refs/packed-backend.c index 0

[PATCH 4/6] packed_ref_iterator_begin(): make optimization more general

2018-01-24 Thread Michael Haggerty
determined start position is the same as `snapshot->eof`. (This is possible now because the previous commit made `find_reference_location()` robust against empty snapshots.) Signed-off-by: Michael Haggerty --- refs/packed-backend.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deleti

[PATCH 1/6] struct snapshot: store `start` rather than `header_len`

2018-01-24 Thread Michael Haggerty
Store a pointer to the start of the actual references within the `packed-refs` contents rather than storing the length of the header. This is more convenient for most users of this field. Signed-off-by: Michael Haggerty --- refs/packed-backend.c | 64

[PATCH 5/6] load_contents(): don't try to mmap an empty file

2018-01-24 Thread Michael Haggerty
urn 0 without trying to read or mmap the file. Returning 0 also makes `create_snapshot()` exit early, which avoids the technically undefined comparison `NULL < NULL`. Reported-by: Kim Gybels Signed-off-by: Michael Haggerty --- refs/packed-backend.c | 13 ++--- 1 file changed, 6 insertio

[PATCH 0/6] Yet another approach to handling empty snapshots

2018-01-24 Thread Michael Haggerty
4 from this patch series would be worthwhile improvements. Michael Kim Gybels (1): packed_ref_cache: don't use mmap() for small files Michael Haggerty (5): struct snapshot: store `start` rather than `header_len` create_snapshot(): use `xmemdupz()` rather than a strbuf find_reference_

[PATCH 2/6] create_snapshot(): use `xmemdupz()` rather than a strbuf

2018-01-24 Thread Michael Haggerty
It's lighter weight. Signed-off-by: Michael Haggerty --- refs/packed-backend.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/refs/packed-backend.c b/refs/packed-backend.c index b872267f02..08698de6ea 100644 --- a/refs/packed-backend.c +++ b/refs/packed-back

[PATCH 6/6] packed_ref_cache: don't use mmap() for small files

2018-01-24 Thread Michael Haggerty
From: Kim Gybels Take a hint from commit ea68b0ce9f8 (hash-object: don't use mmap() for small files, 2010-02-21) and use read() instead of mmap() for small packed-refs files. Signed-off-by: Kim Gybels Signed-off-by: Junio C Hamano Signed-off-by: Michael Haggerty --- refs/packed-back

Re: make git diff output easier to read - use better diff heuristics

2018-02-13 Thread Michael Haggerty
On Tue, Feb 13, 2018 at 7:25 PM, Σπύρος Βαζαίος wrote: > While I din't have the experience to express an opinion on this > matter, I have to say that the --no-indent-heuristic that Jeff > suggested worked great. > There were more than a handful of cases that this issue happened in my > diff file (

Re: [PATCH] sq_dequote: fix extra consumption of source string

2018-02-18 Thread Michael Haggerty
On Wed, Feb 14, 2018 at 12:41 AM, Jeff King wrote: > This fixes a (probably harmless) parsing problem in > sq_dequote_step(), in which we parse some bogus input > incorrectly rather than complaining that it's bogus. > [...] LGTM. Thanks for taking care of this. Michael

Re: [PATCH v5 04/24] files-backend: convert git_path() to strbuf_git_path()

2017-02-28 Thread Michael Haggerty
On 02/22/2017 03:04 PM, Nguyễn Thái Ngọc Duy wrote: > git_path() and friends are going to be killed in files-backend.c in near > future. And because there's a risk with overwriting buffer in > git_path(), let's convert them all to strbuf_git_path(). We'll have > easier time killing/converting strbu

Re: [PATCH v5 05/24] files-backend: move "logs/" out of TMP_RENAMED_LOG

2017-02-28 Thread Michael Haggerty
On 02/22/2017 03:04 PM, Nguyễn Thái Ngọc Duy wrote: > This makes reflog path building consistent, always in the form of > > strbuf_git_path(sb, "logs/%s", refname); > > It reduces the mental workload a bit in the next patch when that > function call is converted. > > Signed-off-by: Nguyễn Th

Re: [PATCH v5 24/24] t1406: new tests for submodule ref store

2017-02-28 Thread Michael Haggerty
On 02/22/2017 03:04 PM, Nguyễn Thái Ngọc Duy wrote: > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > t/t1406-submodule-ref-store.sh (new +x) | 95 > + > 1 file changed, 95 insertions(+) > create mode 100755 t/t1406-submodule-ref-store.sh > > diff --git a/t/t1406-su

Re: [PATCH v5 07/24] files-backend: add and use files_refname_path()

2017-02-28 Thread Michael Haggerty
On 02/22/2017 03:04 PM, Nguyễn Thái Ngọc Duy wrote: > Keep repo-related path handling in one place. This will make it easier > to add submodule/multiworktree support later. > > This automatically adds the "if submodule then use the submodule version > of git_path" to other call sites too. But it d

Re: [PATCH v5 09/24] refs.c: introduce get_main_ref_store()

2017-02-28 Thread Michael Haggerty
On 02/22/2017 03:04 PM, Nguyễn Thái Ngọc Duy wrote: > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > refs.c | 16 > 1 file changed, 12 insertions(+), 4 deletions(-) > > diff --git a/refs.c b/refs.c > index 81b64b4ed..dab1a21ac 100644 > --- a/refs.c > +++ b/refs.c > @@ -1456,15 +145

Re: [PATCH v5 08/24] files-backend: remove the use of git_path()

2017-02-28 Thread Michael Haggerty
On 02/22/2017 03:04 PM, Nguyễn Thái Ngọc Duy wrote: > Given $GIT_DIR and $GIT_COMMON_DIR, files-backend is now in charge of > deciding what goes where (*). The end goal is to pass $GIT_DIR only. A > refs "view" of a linked worktree is a logical ref store that combines > two files backends together.

Re: [PATCH v5 12/24] refs.c: kill register_ref_store(), add register_submodule_ref_store()

2017-02-28 Thread Michael Haggerty
On 02/22/2017 03:04 PM, Nguyễn Thái Ngọc Duy wrote: > This is the last function in this code (besides public API) that takes > submodule argument and handles both main/submodule cases. Break it down, > move main store registration in get_main_ref_store() and keep the rest > in register_submodule_re

Re: [PATCH v5 13/24] refs.c: make get_main_ref_store() public and use it

2017-02-28 Thread Michael Haggerty
On 02/22/2017 03:04 PM, Nguyễn Thái Ngọc Duy wrote: > get_ref_store() will soon be renamed to get_submodule_ref_store(). > Together with future get_worktree_ref_store(), the three functions > provide an appropriate ref store for different operation modes. New APIs > will be added to operate directl

Re: [PATCH v5 00/24] Remove submodule from files-backend.c

2017-02-28 Thread Michael Haggerty
On 02/22/2017 03:04 PM, Nguyễn Thái Ngọc Duy wrote: > v5 goes a bit longer than v4, basically: I've read through patch 14/24 so far, and they all look good except for the mostly superficial comments that I have sent so far. I like the way this is heading! I'll try to continue tomorrow. Michael

Re: [PATCH v5 14/24] path.c: move some code out of strbuf_git_path_submodule()

2017-02-28 Thread Michael Haggerty
On 02/22/2017 03:04 PM, Nguyễn Thái Ngọc Duy wrote: > refs is learning to avoid path rewriting that is done by > strbuf_git_path_submodule(). Factor out this code so it could be reused > by refs* > > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > path.c | 34 +++---

Re: [PATCH v5 12/24] refs.c: kill register_ref_store(), add register_submodule_ref_store()

2017-03-01 Thread Michael Haggerty
On 03/01/2017 01:00 PM, Duy Nguyen wrote: > On Wed, Mar 1, 2017 at 1:03 AM, Michael Haggerty wrote: >>> struct ref_store *get_ref_store(const char *submodule) >>> { >>> struct strbuf submodule_sb = STRBUF_INIT; >>> @@ -1480,6 +1479,9 @@ str

Re: [PATCH v5 24/24] t1406: new tests for submodule ref store

2017-03-01 Thread Michael Haggerty
On 03/01/2017 01:34 PM, Duy Nguyen wrote: > On Wed, Mar 1, 2017 at 12:34 AM, Michael Haggerty > wrote: >> On 02/22/2017 03:04 PM, Nguyễn Thái Ngọc Duy wrote: >>> Signed-off-by: Nguyễn Thái Ngọc Duy >>> --- >>> t/t14

Re: [PATCH v5 24/24] t1406: new tests for submodule ref store

2017-03-02 Thread Michael Haggerty
On 03/02/2017 07:13 AM, Duy Nguyen wrote: > On Wed, Mar 1, 2017 at 10:11 PM, Michael Haggerty > wrote: >> By trial and error, I found that the test succeeds if I comment out the >> "for_each_reflog()" test. By having that test write its results to >> `/tmp` wh

Re: [PATCH v5 15/24] refs: move submodule code out of files-backend.c

2017-03-03 Thread Michael Haggerty
On 02/22/2017 03:04 PM, Nguyễn Thái Ngọc Duy wrote: > files-backend is now initialized with a $GIT_DIR. Converting a submodule > path to where real submodule gitdir is located is done in get_ref_store(). > > This gives a slight performance improvement for submodules since we > don't convert submod

Re: [PATCH v5 16/24] files-backend: replace submodule_allowed check in files_downcast()

2017-03-03 Thread Michael Haggerty
On 02/22/2017 03:04 PM, Nguyễn Thái Ngọc Duy wrote: > files-backend.c is unlearning submodules. Instead of having a specific > check for submodules to see what operation is allowed, files backend > now takes a set of flags at init. Each operation will check if the > required flags is present before

Re: [PATCH v5 19/24] refs: new transaction related ref-store api

2017-03-03 Thread Michael Haggerty
On 02/22/2017 03:04 PM, Nguyễn Thái Ngọc Duy wrote: > The transaction struct now takes a ref store at creation and will > operate on that ref store alone. > > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > refs.c | 54 > > refs.h

Re: [PATCH v5 20/24] files-backend: avoid ref api targetting main ref store

2017-03-03 Thread Michael Haggerty
On 02/22/2017 03:04 PM, Nguyễn Thái Ngọc Duy wrote: > A small step towards making files-backend works as a non-main ref store > using the newly added store-aware API. > > For the record, `join` and `nm` on refs.o and files-backend.o tell me > that files-backend no longer uses functions that defaul

Re: [PATCH v5 23/24] t1405: some basic tests on main ref store

2017-03-03 Thread Michael Haggerty
On 02/22/2017 03:04 PM, Nguyễn Thái Ngọc Duy wrote: > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > t/t1405-main-ref-store.sh (new +x) | 123 > + > 1 file changed, 123 insertions(+) > create mode 100755 t/t1405-main-ref-store.sh > > diff --git a/t/t1405-main-r

Re: [PATCH v5 00/24] Remove submodule from files-backend.c

2017-03-03 Thread Michael Haggerty
On 02/22/2017 03:04 PM, Nguyễn Thái Ngọc Duy wrote: > v5 goes a bit longer than v4, basically: I've reviewed all of the patches and left a bunch of comments, mostly superficial. I'm very happy about the way it's going, and especially want to say how much I appreciate that you've done so much legwo

Re: [PATCH v5 24/24] t1406: new tests for submodule ref store

2017-03-03 Thread Michael Haggerty
On 02/22/2017 03:04 PM, Nguyễn Thái Ngọc Duy wrote: > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > t/t1406-submodule-ref-store.sh (new +x) | 95 > + > 1 file changed, 95 insertions(+) > create mode 100755 t/t1406-submodule-ref-store.sh I wonder if you could reduc

Re: [PATCH v5 07/24] files-backend: add and use files_refname_path()

2017-03-09 Thread Michael Haggerty
On 02/22/2017 03:04 PM, Nguyễn Thái Ngọc Duy wrote: > Keep repo-related path handling in one place. This will make it easier > to add submodule/multiworktree support later. > > This automatically adds the "if submodule then use the submodule version > of git_path" to other call sites too. But it d

Re: Shared repositories no longer securable against privilege escalation

2017-03-17 Thread Michael Haggerty
soft failure. Alternatively, some form of stale > lockfile handling (currently there is none) could be made to work with > a writable HEAD.lock in a read-only bare repository. > > Obigatory HEAD.lock creation was introduced in the following commit: > > commit 92b1551b1d407

Re: [PATCH v6 02/27] files-backend: make files_log_ref_write() static

2017-03-19 Thread Michael Haggerty
On 03/18/2017 03:03 AM, Nguyễn Thái Ngọc Duy wrote: > Created in 5f3c3a4e6f (files_log_ref_write: new function - 2015-11-10) > but probably never used outside refs-internal.c > > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > refs/files-backend.c | 3 +++ > refs/refs-internal.h | 4 > 2 files

Re: [PATCH v6 03/27] files-backend: delete dead code in files_init_db()

2017-03-19 Thread Michael Haggerty
On 03/18/2017 03:03 AM, Nguyễn Thái Ngọc Duy wrote: > safe_create_dir() can do adjust_shared_perm() internally, and init-db > has always created 'refs' in shared mode since the beginning, > af6e277c5e (git-init-db: initialize shared repositories with --shared - > 2005-12-22). So this code looks lik

Re: [PATCH v6 09/27] files-backend: add and use files_refname_path()

2017-03-19 Thread Michael Haggerty
On 03/18/2017 03:03 AM, Nguyễn Thái Ngọc Duy wrote: > Keep repo-related path handling in one place. This will make it easier > to add submodule/multiworktree support later. > > This automatically adds the "if submodule then use the submodule version > of git_path" to other call sites too. But it d

Re: [PATCH v6 11/27] refs.c: introduce get_main_ref_store()

2017-03-19 Thread Michael Haggerty
On 03/18/2017 03:03 AM, Nguyễn Thái Ngọc Duy wrote: > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > refs.c | 16 > 1 file changed, 12 insertions(+), 4 deletions(-) > > diff --git a/refs.c b/refs.c > index e7606716dd..2637353b72 100644 > --- a/refs.c > +++ b/refs.c > @@ -1456,15 +1

Re: [PATCH v6 16/27] path.c: move some code out of strbuf_git_path_submodule()

2017-03-19 Thread Michael Haggerty
On 03/18/2017 03:03 AM, Nguyễn Thái Ngọc Duy wrote: > refs is learning to avoid path rewriting that is done by > strbuf_git_path_submodule(). Factor out this code so it could be reused > by refs* Is the "*" on the previous line is a typo, or did you want to add a footnote, or ...? > Signed-off-by

Re: [PATCH v6 17/27] refs: move submodule code out of files-backend.c

2017-03-19 Thread Michael Haggerty
On 03/18/2017 03:03 AM, Nguyễn Thái Ngọc Duy wrote: > files-backend is now initialized with a $GIT_DIR. Converting a submodule > path to where real submodule gitdir is located is done in get_ref_store(). > > This gives a slight performance improvement for submodules since we > don't convert submod

Re: [PATCH v6 18/27] files-backend: replace submodule_allowed check in files_downcast()

2017-03-19 Thread Michael Haggerty
On 03/18/2017 03:03 AM, Nguyễn Thái Ngọc Duy wrote: > files-backend.c is unlearning submodules. Instead of having a specific > check for submodules to see what operation is allowed, files backend > now takes a set of flags at init. Each operation will check if the > required flags is present before

Re: [PATCH v6 26/27] t1406: new tests for submodule ref store

2017-03-19 Thread Michael Haggerty
On 03/18/2017 03:03 AM, Nguyễn Thái Ngọc Duy wrote: > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > t/t1406-submodule-ref-store.sh (new +x) | 95 > + > 1 file changed, 95 insertions(+) > create mode 100755 t/t1406-submodule-ref-store.sh > > diff --git a/t/t1406-su

Re: [PATCH v6 00/27] Remove submodule from files-backend.c

2017-03-19 Thread Michael Haggerty
few optional comments, but nothing serious. With or without the suggested changes, I think it's ready to go. Thanks for working on this! Reviewed-by: Michael Haggerty Michael

Re: [PATCH v3 2/4] refs: introduce get_worktree_ref_store()

2017-03-20 Thread Michael Haggerty
On 03/18/2017 11:02 AM, Nguyễn Thái Ngọc Duy wrote: > files-backend at this point is still aware of the per-repo/worktree > separation in refs, so it can handle a linked worktree. > > Some refs operations are known not working when current files-backend is > used in a linked worktree (e.g. reflog)

Re: [PATCH v3 2/4] refs: introduce get_worktree_ref_store()

2017-03-20 Thread Michael Haggerty
On 03/20/2017 01:01 PM, Duy Nguyen wrote: > On Mon, Mar 20, 2017 at 1:59 PM, Michael Haggerty > wrote: >> I guess I can hold my nose and accept storing worktree and submodule >> `ref_store`s together in a single hashmap > > Release your nose, I'll add a new hashma

Re: [PATCH v6 17/27] refs: move submodule code out of files-backend.c

2017-03-20 Thread Michael Haggerty
On 03/20/2017 01:09 PM, Duy Nguyen wrote: > On Mon, Mar 20, 2017 at 4:05 AM, Michael Haggerty > wrote: >>> [...] >>> diff --git a/refs/refs-internal.h b/refs/refs-internal.h >>> index f732473e1d..dfa1817929 100644 >>> --- a/refs/refs-internal.h >

[PATCH 00/20] Separate `ref_cache` into a separate module

2017-03-20 Thread Michael Haggerty
2] http://public-inbox.org/git/20170318020337.22767-1-pclo...@gmail.com/ Michael Haggerty (20): get_ref_dir(): don't call read_loose_refs() for "refs/bisect" refs_read_raw_ref(): new function refs_ref_iterator_begin(): new function refs_verify_refname

[PATCH 10/20] ref-cache: introduce a new type, ref_cache

2017-03-20 Thread Michael Haggerty
For now, it just wraps a `ref_entry *` that points at the root of the tree. Soon it will hold more information. Add two new functions, `create_ref_cache()` and `free_ref_cache()`. Make `free_ref_entry()` private. Change files-backend to use this type to hold its caches. Signed-off-by: Michael

[PATCH 01/20] get_ref_dir(): don't call read_loose_refs() for "refs/bisect"

2017-03-20 Thread Michael Haggerty
lazy mechanism, and this time the read was done correctly. This code has been broken since it was first introduced. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index 4242486118..e7a

[PATCH 13/20] refs: handle "refs/bisect/" in `loose_fill_ref_dir()`

2017-03-20 Thread Michael Haggerty
That "refs/bisect/" has to be handled specially when filling the ref_cache for loose references is a peculiarity of the files backend, and the ref-cache code shouldn't need to know about it. So move this code to the callback function, `loose_fill_ref_dir()`. Signed-off-by: M

[PATCH 16/20] get_loose_ref_cache(): new function

2017-03-20 Thread Michael Haggerty
Extract a new function, `get_loose_ref_cache()`, from get_loose_ref_dir(). The function returns the `ref_cache` for the loose refs of a `files_ref_store`. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/refs

[PATCH 20/20] do_for_each_entry_in_dir(): delete function

2017-03-20 Thread Michael Haggerty
Its only remaining caller was itself. Signed-off-by: Michael Haggerty --- refs/ref-cache.c | 21 - refs/ref-cache.h | 11 --- 2 files changed, 32 deletions(-) diff --git a/refs/ref-cache.c b/refs/ref-cache.c index b3a30350d7..6059362f1d 100644 --- a/refs/ref-cache.c

[PATCH 11/20] refs: record the ref_store in ref_cache, not ref_dir

2017-03-20 Thread Michael Haggerty
the size of the individual entries. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 6 +++--- refs/ref-cache.c | 12 +++- refs/ref-cache.h | 9 ++--- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index

[PATCH 18/20] commit_packed_refs(): use reference iteration

2017-03-20 Thread Michael Haggerty
Use reference iteration rather than do_for_each_entry_in_dir() in the definition of commit_packed_refs(). Signed-off-by: Michael Haggerty --- refs/files-backend.c | 38 +- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/refs/files-backend.c b

[PATCH 08/20] Rename `remove_entry()` to `remove_entry_from_dir()`

2017-03-20 Thread Michael Haggerty
This function's visibility is about to be increased, so give it a more distinctive name. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index 6768c8c86b..b4c11

[PATCH 15/20] get_loose_ref_dir(): function renamed from get_loose_refs()

2017-03-20 Thread Michael Haggerty
The new name is more analogous to `get_packed_ref_dir()`. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index 0ff5df6b46..0a16f6196c 100644 --- a/refs/files-backend.c

[PATCH 19/20] files_pack_refs(): use reference iteration

2017-03-20 Thread Michael Haggerty
Use reference iteration rather than do_for_each_entry_in_dir() in the definition of files_pack_refs(). Signed-off-by: Michael Haggerty --- refs/files-backend.c | 143 +-- 1 file changed, 60 insertions(+), 83 deletions(-) diff --git a/refs/files

[PATCH 14/20] do_for_each_entry_in_dir(): eliminate `offset` argument

2017-03-20 Thread Michael Haggerty
It was never used. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 4 ++-- refs/ref-cache.c | 6 +++--- refs/ref-cache.h | 11 +-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index 7b5f5c1240

[PATCH 17/20] cache_ref_iterator_begin(): make function smarter

2017-03-20 Thread Michael Haggerty
ator_begin()` to be made more ignorant of the internals of `ref_cache`, and `find_containing_dir()` and `prime_ref_dir()` to be made private. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 44 +--- refs/ref-cache.

[PATCH 09/20] refs: split `ref_cache` code into separate files

2017-03-20 Thread Michael Haggerty
, adds declarations, and changes the visibility of some functions, but doesn't change any code. The modules are still too tightly coupled, but the situation will be improved in subsequent commits. Signed-off-by: Michael Haggerty --- Makefile | 1 + refs/files-backend.c

[PATCH 12/20] ref-cache: use a callback function to fill the cache

2017-03-20 Thread Michael Haggerty
supply a pointer to function `read_loose_refs` (renamed to `loose_fill_ref_dir`) when creating the ref cache for its loose refs. This means that we can generify the type of the back-pointer in `struct ref_cache` from `files_ref_store` to `ref_store`. Signed-off-by: Michael Haggerty --- refs/files

[PATCH 02/20] refs_read_raw_ref(): new function

2017-03-20 Thread Michael Haggerty
Extract a new function from `refs_resolve_ref_unsafe()`. It will be useful elsewhere. Signed-off-by: Michael Haggerty --- refs.c | 11 +-- refs/refs-internal.h | 4 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/refs.c b/refs.c index 77a39f8b17

[PATCH 04/20] refs_verify_refname_available(): implement once for all backends

2017-03-20 Thread Michael Haggerty
It turns out that we can now implement `refs_verify_refname_available()` based on the other virtual functions, so there is no need for it to be defined at the backend level. Instead, define it once in `refs.c` and remove the `files_backend` definition. Signed-off-by: Michael Haggerty --- refs.c

[PATCH 07/20] Rename `find_ref()` to `find_ref_entry()`

2017-03-20 Thread Michael Haggerty
This function's visibility is about to be increased, so give it a more distinctive name. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index 4d579cbdac..6768c

[PATCH 05/20] refs_verify_refname_available(): use function in more places

2017-03-20 Thread Michael Haggerty
(and will be regained later). These were the last callers of `verify_refname_available_dir()`, so also delete that (very complicated) function. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 171 --- 1 file changed, 11 insertions(+)

[PATCH 06/20] Rename `add_ref()` to `add_ref_entry()`

2017-03-20 Thread Michael Haggerty
This function's visibility is about to be increased, so give it a more distinctive name. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index cad56efb04..4d579

[PATCH 03/20] refs_ref_iterator_begin(): new function

2017-03-20 Thread Michael Haggerty
Extract a new function from `do_for_each_ref()`. It will be useful elsewhere. Signed-off-by: Michael Haggerty --- refs.c | 15 +-- refs/refs-internal.h | 11 +++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/refs.c b/refs.c index 0ed6c3c7a4

Re: [PATCH 04/20] refs_verify_refname_available(): implement once for all backends

2017-03-20 Thread Michael Haggerty
On 03/20/2017 06:42 PM, Jeff King wrote: > On Mon, Mar 20, 2017 at 05:33:09PM +0100, Michael Haggerty wrote: > >> It turns out that we can now implement >> `refs_verify_refname_available()` based on the other virtual >> functions, so there is no need for it to be defined

Re: [PATCH 11/20] refs: record the ref_store in ref_cache, not ref_dir

2017-03-20 Thread Michael Haggerty
On 03/20/2017 06:51 PM, Jeff King wrote: > On Mon, Mar 20, 2017 at 05:33:16PM +0100, Michael Haggerty wrote: > >> Instead of keeping a pointer to the ref_store in every ref_dir entry, >> store it once in `struct ref_cache`, and change `struct ref_dir` to >> include a p

Re: [PATCH 00/20] Separate `ref_cache` into a separate module

2017-03-20 Thread Michael Haggerty
On 03/20/2017 11:32 PM, Junio C Hamano wrote: > Michael Haggerty writes: > >> Michael Haggerty (20): >> get_ref_dir(): don't call read_loose_refs() for "refs/bisect" >> refs_read_raw_ref(): new function >> refs_ref_iterator_begin(): ne

Re: [PATCH 18/20] commit_packed_refs(): use reference iteration

2017-03-22 Thread Michael Haggerty
On 03/20/2017 07:05 PM, Jeff King wrote: > On Mon, Mar 20, 2017 at 05:33:23PM +0100, Michael Haggerty wrote: > >> -/* >> - * An each_ref_entry_fn that writes the entry to a packed-refs file. >> - */ >> -static int write_packed_entry_fn(struct ref_entry *entry, voi

Re: [PATCH v3 1/2] [GSoC] dir_iterator: iterate over dir after its contents

2017-03-26 Thread Michael Haggerty
On 03/25/2017 07:12 PM, Daniel Ferreira wrote: > Create an option for the dir_iterator API to iterate over a directory > path only after having iterated through its contents. This feature was > predicted, although not implemented by 0fe5043 ("dir_iterator: new API > for iterating over a directory t

Re: [PATCH v3 1/2] [GSoC] dir_iterator: iterate over dir after its contents

2017-03-26 Thread Michael Haggerty
On 03/25/2017 07:12 PM, Daniel Ferreira wrote: > Create an option for the dir_iterator API to iterate over a directory > path only after having iterated through its contents. This feature was > predicted, although not implemented by 0fe5043 ("dir_iterator: new API > for iterating over a directory t

Re: [PATCH v4 1/5] dir_iterator: add helpers to dir_iterator_advance

2017-03-28 Thread Michael Haggerty
On 03/29/2017 02:32 AM, Daniel Ferreira wrote: > Create inline helpers to dir_iterator_advance(). Make > dir_iterator_advance()'s code more legible and allow some behavior to > be reusable. Thanks for breaking up the patches. That makes them a lot easier to review. > Signed-off-by: Daniel Ferreir

Re: [PATCH v4 2/5] dir_iterator: iterate over dir after its contents

2017-03-29 Thread Michael Haggerty
On 03/29/2017 02:32 AM, Daniel Ferreira wrote: > Create an option for the dir_iterator API to iterate over subdirectories > only after having iterated through their contents. This feature was > predicted, although not implemented by 0fe5043 ("dir_iterator: new API > for iterating over a directory t

Re: [PATCH v4 3/5] remove_subtree(): reimplement using iterators

2017-03-29 Thread Michael Haggerty
On 03/29/2017 02:32 AM, Daniel Ferreira wrote: > Use dir_iterator to traverse through remove_subtree()'s directory tree, > avoiding the need for recursive calls to readdir(). Simplify > remove_subtree()'s code. > > A conversion similar in purpose was previously done at 46d092a > ("for_each_reflog(

Re: [PATCH v4 5/5] files_reflog_iterator: amend use of dir_iterator

2017-03-29 Thread Michael Haggerty
On 03/29/2017 02:32 AM, Daniel Ferreira wrote: > Amend a call to dir_iterator_begin() to pass the flags parameter > introduced in 3efb5c0 ("dir_iterator: iterate over dir after its > contents", 2017-28-03). > > Signed-off-by: Daniel Ferreira > --- > refs/files-backend.c | 2 +- > 1 file changed,

Re: [PATCH v6 18/27] files-backend: replace submodule_allowed check in files_downcast()

2017-03-29 Thread Michael Haggerty
On 03/26/2017 04:16 AM, Duy Nguyen wrote: > On Mon, Mar 20, 2017 at 4:18 AM, Michael Haggerty > wrote: >>> +/* ref_store_init flags */ >>> +#define REF_STORE_READ (1 << 0) >> >> I asked [1] in reply to v5 whether `REF_STORE_READ` is really

Re: [PATCH v4 2/5] dir_iterator: iterate over dir after its contents

2017-03-29 Thread Michael Haggerty
On 03/29/2017 11:56 AM, Michael Haggerty wrote: > On 03/29/2017 02:32 AM, Daniel Ferreira wrote: >> [...] > [...] > The disagreement is not a surprise, because there isn't a corresponding > coding error in the code below that returns the directory itself in a > post-order

Re: [PATCH v4 2/5] dir_iterator: iterate over dir after its contents

2017-03-29 Thread Michael Haggerty
On 03/29/2017 06:46 PM, Junio C Hamano wrote: > Michael Haggerty writes: > >> I also realize that I made a goof in my comments about v3 of this patch >> series. Your new option is not choosing between "depth-first" and >> "breadth-first". Both type

Re: [PATCH v4 2/5] dir_iterator: iterate over dir after its contents

2017-03-29 Thread Michael Haggerty
On 03/30/2017 08:08 AM, Junio C Hamano wrote: > Michael Haggerty writes: > >> I think IN_ORDER really only applies to *binary* trees, not arbitrary >> trees like a filesystem. > > How true. Even if we were giving a sorted output (and dir-iterator > doesn't and

Re: [PATCH v5 4/6] dir_iterator: add tests for dir_iterator API

2017-03-30 Thread Michael Haggerty
On 03/30/2017 05:32 AM, Daniel Ferreira wrote: > Create t/helper/test-dir-iterator.c, which prints relevant information > about a directory tree iterated over with dir_iterator. > > Create t/t0065-dir-iterator.sh, which tests that dir_iterator does > iterate through a whole directory tree and that

Re: [PATCH v5 4/6] dir_iterator: add tests for dir_iterator API

2017-03-30 Thread Michael Haggerty
On 03/30/2017 05:32 AM, Daniel Ferreira wrote: > Create t/helper/test-dir-iterator.c, which prints relevant information > about a directory tree iterated over with dir_iterator. > > Create t/t0065-dir-iterator.sh, which tests that dir_iterator does > iterate through a whole directory tree and that

Re: [PATCH v5 4/6] dir_iterator: add tests for dir_iterator API

2017-03-30 Thread Michael Haggerty
On 03/30/2017 05:32 AM, Daniel Ferreira wrote: > Create t/helper/test-dir-iterator.c, which prints relevant information > about a directory tree iterated over with dir_iterator. > > Create t/t0065-dir-iterator.sh, which tests that dir_iterator does > iterate through a whole directory tree and that

Re: [PATCH v5 2/6] dir_iterator: refactor state machine model

2017-03-30 Thread Michael Haggerty
On 03/30/2017 05:32 AM, Daniel Ferreira wrote: > Remove the "initialized" member of dir_iterator_level. Replace its > functionality with a DIR_STATE_PUSH state in the > dir_iterator_level.dir_state enum. > > This serves to remove a redundant property in the dir_iterator_level > struct and ease com

Re: [PATCH v5 3/6] dir_iterator: iterate over dir after its contents

2017-03-30 Thread Michael Haggerty
On 03/30/2017 05:32 AM, Daniel Ferreira wrote: > Create an option for the dir_iterator API to iterate over subdirectories > only after having iterated through their contents. This feature was > predicted, although not implemented by 0fe5043 ("dir_iterator: new API > for iterating over a directory t

Re: [PATCH v5 6/6] remove_subtree(): test removing nested directories

2017-03-30 Thread Michael Haggerty
On 03/30/2017 05:32 AM, Daniel Ferreira wrote: > Test removing a nested directory when an attempt is made to restore the > index to a state where it does not exist. A similar test could be found > previously in t/t2000-checkout-cache-clash.sh, but it did not check for > nested directories, which co

Re: [PATCH v5 0/6] [GSoC] remove_subtree(): reimplement using iterators

2017-03-30 Thread Michael Haggerty
On 03/30/2017 05:32 AM, Daniel Ferreira wrote: > This is the fifth version of a patch series that implements the GSoC > microproject of converting a recursive call to readdir() to use dir_iterator. > > v1: > https://public-inbox.org/git/CAGZ79kZwT-9mHTiOJ5CEjk2wDFkn6+NcogjX0=vjhsah16a...@mail.gma

<    7   8   9   10   11   12   13   14   15   16   >