[PATCH v3 06/20] ref-cache: rename `add_ref()` to `add_ref_entry()`

2017-04-15 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 cf1c18cffb..05029

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

2017-04-15 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 v3 14/20] do_for_each_entry_in_dir(): eliminate `offset` argument

2017-04-15 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 079ba941ef

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

2017-04-15 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 v3 16/20] get_loose_ref_cache(): new function

2017-04-15 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 v3 02/20] refs_read_raw_ref(): new function

2017-04-15 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 bad05ba861

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

2017-04-15 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 v3 07/20] ref-cache: rename `find_ref()` to `find_ref_entry()`

2017-04-15 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 05029d43b8..6e08b

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

2017-04-15 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 v3 04/20] refs_verify_refname_available(): implement once for all backends

2017-04-15 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 v3 03/20] refs_ref_iterator_begin(): new function

2017-04-15 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 aa461156c4

Re: [PATCH v8 0/5] [GSoC] remove_subtree(): reimplement using iterators

2017-04-16 Thread Michael Haggerty
y credit you for it. It's a small enough bit of code that you don't have to credit me. However, technically you should add a Signed-off-by: Michael Haggerty line to your patch that includes my code, which you are allowed to do because I included that line in the email where I sugge

Re: [PATCH v8 4/5] dir_iterator: refactor state machine model

2017-04-16 Thread Michael Haggerty
On 04/06/2017 03:39 AM, Daniel Ferreira wrote: > Perform major refactor of dir_iterator_advance(). dir_iterator has > ceased to rely on a convoluted state machine mechanism of two loops and > two state variables (level.initialized and level.dir_state). This serves > to ease comprehension of the ite

Re: [PATCH] files_for_each_reflog_ent_reverse(): close stream and free strbuf on error

2017-04-17 Thread Michael Haggerty
log for %s: > %s", > - cnt, refname, strerror(errno)); > + if (nread != 1) { > + ret = error("cannot read %d bytes from reflog for %s: > %s", > + cnt, refname, strerror(errno)); > + break; > + } > pos -= cnt; > > scanp = endp = buf + cnt; > Reviewed-by: Michael Haggerty Michael

Re: [PATCH v10 4/5] dir_iterator: rewrite state machine model

2017-04-20 Thread Michael Haggerty
fs/files-backend.c to pass > the flags parameter introduced, as well as handle the case in which it > fails to open the directory. > > Improve t/t0065-dir-iterator.sh and t/helper/test-dir-iterator.c to > test "post-order" and "iterate-over-root" modes. > &

Re: [PATCH] refs.h: rename submodule arguments to submodule_path

2017-04-20 Thread Michael Haggerty
On 04/21/2017 03:12 AM, Junio C Hamano wrote: > Stefan Beller writes: > >> + Junio > > Just like Michael, I do not have strong enough opinion for or > against this patch to comment on it. > > I do agree with you that it would be a good longer-term direction to > use "submodule" for a "struct su

Re: [PATCH] refs.h: rename submodule arguments to submodule_path

2017-04-20 Thread Michael Haggerty
On 04/21/2017 08:32 AM, Michael Haggerty wrote: > [...] > I've CCed Duy because I don't know whether he has more plans regarding > submodule references [...] get rid of the > `for_each_ref_submodule()` family of functions entirely. > > So perhaps the code that this p

Re: [PATCH v4 3/5] refs: introduce get_worktree_ref_store()

2017-04-21 Thread Michael Haggerty
On 04/04/2017 12:21 PM, 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 v4 0/5] Kill manual ref parsing code in worktree.c

2017-04-21 Thread Michael Haggerty
On 04/14/2017 03:40 AM, Junio C Hamano wrote: > Nguyễn Thái Ngọc Duy writes: > >> v4 adds a new patch, 2/5, which makes the hashmap related functions in >> refs.c generic, so I could add a new map for worktree ref stores and >> not abuse submodule hashmap. >> >> I mentioned about moving these ha

Re: [PATCH v3 04/12] refs.c: refactor get_submodule_ref_store(), share common free block

2017-04-21 Thread Michael Haggerty
On 04/19/2017 01:01 PM, Nguyễn Thái Ngọc Duy wrote: > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > refs.c | 12 +--- > 1 file changed, 5 insertions(+), 7 deletions(-) > > diff --git a/refs.c b/refs.c > index 5d31fb6bcf..5902a3d9e5 100644 > --- a/refs.c > +++ b/refs.c > @@ -1570,19 +1570,1

Re: [PATCH v3 05/12] refs: move submodule slash stripping code to get_submodule_ref_store

2017-04-21 Thread Michael Haggerty
On 04/19/2017 01:01 PM, Nguyễn Thái Ngọc Duy wrote: > This is a better place that will benefit all submodule callers instead > of just resolve_gitlink_ref() > > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > refs.c | 33 + > 1 file changed, 17 insertions(+), 16 delet

Re: [PATCH v3 08/12] refs: remove dead for_each_*_submodule()

2017-04-21 Thread Michael Haggerty
On 04/19/2017 01:01 PM, Nguyễn Thái Ngọc Duy wrote: > These are used in revision.c. After the last patch they are replaced > with the refs_ version. Delete them (except for_each_remote_ref_submodule > which is still used by submodule.c) ❤❤ I love the way this is going. Michael

Re: [PATCH v3 09/12] revision.c: --all adds HEAD from all worktrees

2017-04-21 Thread Michael Haggerty
On 04/19/2017 01:01 PM, Nguyễn Thái Ngọc Duy wrote: > Unless single_worktree is set, --all now adds HEAD from all worktrees. > > Since reachable.c code does not use setup_revisions(), we need to call > other_head_refs_submodule() explicitly there to have the same effect on > "git prune", so that w

Re: [PATCH v3 06/12] refs: add refs_head_ref()

2017-04-21 Thread Michael Haggerty
On 04/19/2017 01:01 PM, Nguyễn Thái Ngọc Duy wrote: > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > refs.c | 19 +-- > refs.h | 2 ++ > 2 files changed, 11 insertions(+), 10 deletions(-) > > diff --git a/refs.c b/refs.c > index 26474cb62a..a252ae43ee 100644 > --- a/refs.c > +++ b/

Re: [PATCH v3 10/12] files-backend: make reflog iterator go through per-worktree reflog

2017-04-22 Thread Michael Haggerty
On 04/19/2017 01:01 PM, Nguyễn Thái Ngọc Duy wrote: > refs/bisect is unfortunately per-worktree, so we need to look in > per-worktree logs/refs/bisect in addition to per-repo logs/refs. The > current iterator only goes through per-repo logs/refs. > > Ideally we should have something like merge_ref

Re: [PATCH v3 00/12] Fix git-gc losing objects in multi worktree

2017-04-22 Thread Michael Haggerty
On 04/19/2017 01:01 PM, Nguyễn Thái Ngọc Duy wrote: > Changes since v2 [1] is relatively small. It still needs > nd/worktree-kill-parse-ref of course. I read the whole series. Aside from the comments I made, it looks good to me. This will be able to be cleaned up once we have a cleaner distinctio

Re: [PATCH 38/53] refs: convert struct ref_update to use struct object_id

2017-04-26 Thread Michael Haggerty
On 04/23/2017 11:34 PM, brian m. carlson wrote: > Convert struct ref_array_item to use struct object_id by changing the > definition and applying the following semantic patch, plus the standard > object_id transforms: > [...] This commit LGTM. Michael

Re: [PATCH 39/53] refs/files-backend: convert many internals to struct object_id

2017-04-26 Thread Michael Haggerty
On 04/23/2017 11:34 PM, brian m. carlson wrote: > Convert many of the internals of the files backend to use struct > object_id. Avoid converting public APIs to limit the scope of the > changes. > > Convert one use of get_sha1_hex to parse_oid_hex, and rely on the fact > that a strbuf will be NUL-

Re: [PATCHv2 0/3] Make diff plumbing commands respect the indentHeuristic.

2017-04-29 Thread Michael Haggerty
On 04/29/2017 02:40 PM, Jeff King wrote: > On Fri, Apr 28, 2017 at 06:33:12PM -0400, Marc Branchaud wrote: > >> v2: Fixed up the commit messages and added tests. >> >> Marc Branchaud (2): >> diff: make the indent heuristic part of diff's basic configuration >> diff: have the diff-* builtins co

Performance regression in `git branch` due to ref-filter usage

2017-05-17 Thread Michael Haggerty
While working on reference code, I was running `git branch` under `strace`, when I noticed that `$GIT_DIR/HEAD` was being `lstat()`ed and `read()` 121 times. This is in a repository with 114 branches, so probably it is being run once per branch. The extra work makes a measurable difference to the (

[PATCH 00/23] Prepare to separate out a packed_ref_store

2017-05-17 Thread Michael Haggerty
lum.mit.edu/ http://public-inbox.org/git/cover.1492323985.git.mhag...@alum.mit.edu/ [2] https://github.com/mhagger/git Jeff King (1): ref-filter: limit traversal to prefix Michael Haggerty (22): t3600: clean up permissions test properly refs.h: clarify docstring for the ref_transaction_u

[PATCH 01/23] t3600: clean up permissions test properly

2017-05-17 Thread Michael Haggerty
`test_must_fail` block so that it can't be skipped. Signed-off-by: Michael Haggerty --- t/t3600-rm.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index 5f9913ba33..4a35c378c8 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -98,8

[PATCH 04/23] prefix_ref_iterator: don't trim too much

2017-05-17 Thread Michael Haggerty
7;s be cautious here. Skip over any references whose names are not longer than `trim`. Signed-off-by: Michael Haggerty --- refs/iterator.c | 14 +- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/refs/iterator.c b/refs/iterator.c index bce1f192f7..f33d1b3a39 100644 --- a/

[PATCH 03/23] ref_iterator_begin_fn(): fix docstring

2017-05-17 Thread Michael Haggerty
, `cache_ref_iterator_begin()` (from which the files reference iterator gets its values) automatically wraps its output using `prefix_ref_iterator_begin()` when necessary, so it has the stricter behavior. Signed-off-by: Michael Haggerty --- refs/refs-internal.h | 4 ++-- 1 file changed, 2 insertions

[PATCH 02/23] refs.h: clarify docstring for the ref_transaction_update()-related fns

2017-05-17 Thread Michael Haggerty
In particular, make it clear that they make copies of the sha1 arguments. Signed-off-by: Michael Haggerty --- refs.h | 13 + 1 file changed, 13 insertions(+) diff --git a/refs.h b/refs.h index d18ef47128..a7d7b1afdf 100644 --- a/refs.h +++ b/refs.h @@ -427,6 +427,19 @@ struct

[PATCH 07/23] ref_store: take `logmsg` parameter when deleting references

2017-05-17 Thread Michael Haggerty
Just because the files backend can't retain reflogs for deleted references is no reason that they shouldn't be supported by the virtual method interface. Let's add them now before the interface becomes truly polymorphic and increases the work. Signed-off-by: Michael Haggerty ---

[PATCH 16/23] should_pack_ref(): new function, extracted from `files_pack_refs()`

2017-05-17 Thread Michael Haggerty
Extract a function for deciding whether a reference should be packed. It is a self-contained bit of logic, so splitting it out improves readability. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 42 -- 1 file changed, 28 insertions(+), 14

[PATCH 09/23] files-backend: move `lock` member to `files_ref_store`

2017-05-17 Thread Michael Haggerty
Move the `lock` member from `packed_ref_cache` to `files_ref_store`, since at most one cache can have a locked "packed-refs" file associated with it. Rename it to `packlock` to make its purpose clearer in its new home. More changes are coming here shortly. Signed-off-by: Michae

[PATCH 12/23] ref_transaction_commit(): break into multiple functions

2017-05-17 Thread Michael Haggerty
sub-transactions. Only if all of the "prepare" steps succeed would we "finish" each of them. Signed-off-by: Michael Haggerty --- refs.c | 34 ++--- refs.h | 37 ++- refs/files-backend.c | 71 +

[PATCH 05/23] refs_ref_iterator_begin(): don't check prefixes redundantly

2017-05-17 Thread Michael Haggerty
The backend already takes care of the prefix. By passing the prefix again to `prefix_ref_iterator`, we were forcing that iterator to do redundant prefix comparisons. So set it to the empty string. Signed-off-by: Michael Haggerty --- refs.c | 8 +++- 1 file changed, 7 insertions(+), 1

[PATCH 17/23] get_packed_ref_cache(): assume "packed-refs" won't change while locked

2017-05-17 Thread Michael Haggerty
If we've got the "packed-refs" file locked, then it can't change; there's no need to keep calling `stat_validity_check()` on it. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 16 +++- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git

[PATCH 10/23] files_ref_store: put the packed files lock directly in this struct

2017-05-17 Thread Michael Haggerty
p track of whether it is locked. This keeps related data together and makes the main reference store less of a special case. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 29 +++-- 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/refs/files-backen

[PATCH 19/23] read_packed_refs(): report unexpected fopen() failures

2017-05-17 Thread Michael Haggerty
re such problems. So report any failures that are not due to ENOENT. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 15 +-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index 6a037e1d61..eb74d1119a 100644 --- a/

[PATCH 18/23] read_packed_refs(): do more of the work of reading packed refs

2017-05-17 Thread Michael Haggerty
Teach `read_packed_refs()` to also * Allocate and initialize the new `packed_ref_cache` * Open and close the `packed-refs` file * Update the `validity` field of the new object This decreases the coupling between `packed_refs_cache` and `files_ref_store` by a little bit. Signed-off-by: Michael

[PATCH 06/23] refs: use `size_t` indexes when iterating over ref transaction updates

2017-05-17 Thread Michael Haggerty
Signed-off-by: Michael Haggerty --- refs.c | 2 +- refs/files-backend.c | 6 -- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/refs.c b/refs.c index f4a485cd8a..ea8233c67d 100644 --- a/refs.c +++ b/refs.c @@ -848,7 +848,7 @@ struct ref_transaction

[PATCH 23/23] cache_ref_iterator_begin(): avoid priming unneeded directories

2017-05-17 Thread Michael Haggerty
e latter yet, because it might be useful for another patch series that I'm working on. Signed-off-by: Michael Haggerty --- refs/ref-cache.c | 93 ++-- 1 file changed, 83 insertions(+), 10 deletions(-) diff --git a/refs/ref-cache.c b/refs/ref

[PATCH 14/23] ref_update_reject_duplicates(): use `size_t` rather than `int`

2017-05-17 Thread Michael Haggerty
Signed-off-by: Michael Haggerty --- refs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/refs.c b/refs.c index 43d65bc9c6..ffc9bd0be5 100644 --- a/refs.c +++ b/refs.c @@ -1692,7 +1692,7 @@ int create_symref(const char *ref_target, const char *refs_heads_master, int

[PATCH 21/23] create_ref_entry(): remove `check_name` option

2017-05-17 Thread Michael Haggerty
Only one caller was using it, so move the check to that caller. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 12 refs/ref-cache.c | 6 +- refs/ref-cache.h | 3 +-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/refs/files-backend.c b

[PATCH 08/23] lockfile: add a new method, is_lock_file_locked()

2017-05-17 Thread Michael Haggerty
It will soon prove useful. Signed-off-by: Michael Haggerty --- lockfile.h | 8 1 file changed, 8 insertions(+) diff --git a/lockfile.h b/lockfile.h index 7b715f9e77..572064939c 100644 --- a/lockfile.h +++ b/lockfile.h @@ -175,6 +175,14 @@ static inline int hold_lock_file_for_update

[PATCH 15/23] ref_update_reject_duplicates(): add a sanity check

2017-05-17 Thread Michael Haggerty
It's pretty cheap to make sure that the caller didn't pass us an unsorted list by accident, so do so. Signed-off-by: Michael Haggerty --- refs.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/refs.c b/refs.c index ffc9bd0be5..68a0872562 100644 --- a/re

[PATCH 11/23] files_transaction_cleanup(): new helper function

2017-05-17 Thread Michael Haggerty
Extract function from `files_transaction_commit()`. It will soon have another caller. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 33 - 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index

[PATCH 20/23] refs_ref_iterator_begin(): handle `GIT_REF_PARANOIA`

2017-05-17 Thread Michael Haggerty
Instead of handling `GIT_REF_PARANOIA` in `files_ref_iterator_begin()`, handle it in `refs_ref_iterator_begin()`, where it will cover all reference stores. Signed-off-by: Michael Haggerty --- refs.c | 5 + refs/files-backend.c | 11 --- 2 files changed, 9 insertions

[PATCH 22/23] ref-filter: limit traversal to prefix

2017-05-17 Thread Michael Haggerty
t probably doesn't come up that often, and (b) it is more awkward to deal with multiple patterns (e.g., the patterns might not be disjoint). So, since this is just an optimization, punt on the case of multiple patterns. Signed-off-by: Jeff King Signed-off-by: Michael Haggerty --- re

[PATCH 13/23] ref_update_reject_duplicates(): expose function to whole refs module

2017-05-17 Thread Michael Haggerty
It will soon have some other users. Signed-off-by: Michael Haggerty --- refs.c | 17 + refs/files-backend.c | 17 - refs/refs-internal.h | 8 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/refs.c b/refs.c index 689362db1e

Re: [PATCH v3 10/12] files-backend: make reflog iterator go through per-worktree reflog

2017-05-17 Thread Michael Haggerty
Hi, I put off reviewing this patch, thinking that it would appear in a re-roll, then never came back to it. :-( On 04/23/2017 06:44 AM, Duy Nguyen wrote: > On Sat, Apr 22, 2017 at 10:05:02AM +0200, Michael Haggerty wrote: >> I find this implementation confusing: >>

Re: [PATCH 01/23] t3600: clean up permissions test properly

2017-05-17 Thread Michael Haggerty
On 05/17/2017 02:42 PM, Jeff King wrote: > On Wed, May 17, 2017 at 02:05:24PM +0200, Michael Haggerty wrote: > >> The test of failing `git rm -f` removes the write permissions on the >> test directory, but fails to restore them if the test fails. This >> means that the

Re: [PATCH 04/23] prefix_ref_iterator: don't trim too much

2017-05-17 Thread Michael Haggerty
On 05/17/2017 02:55 PM, Jeff King wrote: > On Wed, May 17, 2017 at 02:05:27PM +0200, Michael Haggerty wrote: > >> diff --git a/refs/iterator.c b/refs/iterator.c >> index bce1f192f7..f33d1b3a39 100644 >> --- a/refs/iterator.c >> +++ b/refs/iterator.c >

Re: [PATCH 05/23] refs_ref_iterator_begin(): don't check prefixes redundantly

2017-05-17 Thread Michael Haggerty
On 05/17/2017 02:59 PM, Jeff King wrote: > On Wed, May 17, 2017 at 02:05:28PM +0200, Michael Haggerty wrote: > >> The backend already takes care of the prefix. By passing the prefix >> again to `prefix_ref_iterator`, we were forcing that iterator to do >> redundant prefi

Re: [PATCH 07/23] ref_store: take `logmsg` parameter when deleting references

2017-05-17 Thread Michael Haggerty
On 05/17/2017 03:12 PM, Jeff King wrote: > On Wed, May 17, 2017 at 02:05:30PM +0200, Michael Haggerty wrote: > >> Just because the files backend can't retain reflogs for deleted >> references is no reason that they shouldn't be supported by the >> virtual me

Re: [PATCH 10/23] files_ref_store: put the packed files lock directly in this struct

2017-05-17 Thread Michael Haggerty
On 05/17/2017 03:17 PM, Jeff King wrote: > On Wed, May 17, 2017 at 02:05:33PM +0200, Michael Haggerty wrote: > >> Instead of using a global `lock_file` instance for the main >> "packed-refs" file and using a pointer in `files_ref_store` to keep >> track

Re: [PATCH 19/23] read_packed_refs(): report unexpected fopen() failures

2017-05-17 Thread Michael Haggerty
On 05/17/2017 03:28 PM, Jeff King wrote: > On Wed, May 17, 2017 at 02:05:42PM +0200, Michael Haggerty wrote: > >> The old code ignored any errors encountered when trying to fopen the >> "packed-refs" file, treating all such failures as if the file didn't >&g

Re: [PATCH 09/23] files-backend: move `lock` member to `files_ref_store`

2017-05-17 Thread Michael Haggerty
On 05/17/2017 03:15 PM, Jeff King wrote: > On Wed, May 17, 2017 at 02:05:32PM +0200, Michael Haggerty wrote: > >> @@ -70,6 +61,13 @@ struct files_ref_store { >> >> struct ref_cache *loose; >> struct packed_ref_cache *packed; >> + >> +

Re: [PATCH 04/23] prefix_ref_iterator: don't trim too much

2017-05-17 Thread Michael Haggerty
On 05/18/2017 06:19 AM, Junio C Hamano wrote: > Michael Haggerty writes: > >> The `trim` parameter can be set independently of `prefix`. So if some >> caller were to set `trim` to be greater than `strlen(prefix)`, we >> could end up pointing the `refname` field of the ite

Re: [PATCH 06/23] refs: use `size_t` indexes when iterating over ref transaction updates

2017-05-17 Thread Michael Haggerty
On 05/17/2017 06:59 PM, Stefan Beller wrote: > On Wed, May 17, 2017 at 5:05 AM, Michael Haggerty > wrote: > > Now this would want to have some selling words for it? > I do not see an advantage of this patch as-is. > > I mean technically we don't need a sign, so we

Re: [PATCH 01/23] t3600: clean up permissions test properly

2017-05-18 Thread Michael Haggerty
On 05/18/2017 06:10 AM, Junio C Hamano wrote: > Michael Haggerty writes: > >> The test of failing `git rm -f` removes the write permissions on the >> test directory, but fails to restore them if the test fails. This >> means that the test temporary directory cannot be cl

Re: [PATCH 10/23] files_ref_store: put the packed files lock directly in this struct

2017-05-18 Thread Michael Haggerty
On 05/17/2017 07:18 PM, Stefan Beller wrote: > On Wed, May 17, 2017 at 6:17 AM, Jeff King wrote: >> On Wed, May 17, 2017 at 02:05:33PM +0200, Michael Haggerty wrote: >> >>> Instead of using a global `lock_file` instance for the main >>> "packed-refs" f

Re: [PATCH 11/23] files_transaction_cleanup(): new helper function

2017-05-18 Thread Michael Haggerty
On 05/17/2017 07:26 PM, Stefan Beller wrote: > On Wed, May 17, 2017 at 5:05 AM, Michael Haggerty > wrote: >> Extract function from `files_transaction_commit()`. It will soon have >> another caller. > > This sounds odd to me. Maybe it is missing words? > of s/fu

Re: [PATCH 11/23] files_transaction_cleanup(): new helper function

2017-05-18 Thread Michael Haggerty
On 05/17/2017 03:19 PM, Jeff King wrote: > On Wed, May 17, 2017 at 02:05:34PM +0200, Michael Haggerty wrote: > >> Extract function from `files_transaction_commit()`. It will soon have >> another caller. >> [...] >> @@ -2868,10 +2889,8 @@ static int files_trans

Re: [PATCH 12/23] ref_transaction_commit(): break into multiple functions

2017-05-19 Thread Michael Haggerty
On 05/17/2017 07:44 PM, Stefan Beller wrote: > On Wed, May 17, 2017 at 5:05 AM, Michael Haggerty > wrote: >> Break the function `ref_transaction_commit()` into two functions, >> `ref_transaction_prepare()` and `ref_transaction_finish()`, with a >> third function, `ref_tr

Re: [PATCH 22/23] ref-filter: limit traversal to prefix

2017-05-19 Thread Michael Haggerty
On 05/17/2017 03:38 PM, Jeff King wrote: > On Wed, May 17, 2017 at 02:05:45PM +0200, Michael Haggerty wrote: > >> From: Jeff King > > This patch did originate with me, but I know you had to fix several > things to integrate it in your series. So I'll review it anyway,

[PATCH v2 09/25] lockfile: add a new method, is_lock_file_locked()

2017-05-22 Thread Michael Haggerty
It will soon prove useful. Signed-off-by: Michael Haggerty --- lockfile.h | 8 1 file changed, 8 insertions(+) diff --git a/lockfile.h b/lockfile.h index 7b715f9e77..572064939c 100644 --- a/lockfile.h +++ b/lockfile.h @@ -175,6 +175,14 @@ static inline int hold_lock_file_for_update

[PATCH v2 16/25] ref_update_reject_duplicates(): use `size_t` rather than `int`

2017-05-22 Thread Michael Haggerty
Eliminate a theoretical risk of integer overflow if the two types have different sizes. Signed-off-by: Michael Haggerty --- refs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/refs.c b/refs.c index beb49fb297..143936a9c3 100644 --- a/refs.c +++ b/refs.c @@ -1705,7 +1705,7

[PATCH v2 07/25] refs: use `size_t` indexes when iterating over ref transaction updates

2017-05-22 Thread Michael Haggerty
Eliminate any chance of integer overflow on platforms where the two types have different sizes. Signed-off-by: Michael Haggerty --- refs.c | 2 +- refs/files-backend.c | 6 -- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/refs.c b/refs.c index 8494b1f20d

[PATCH v2 06/25] refs_ref_iterator_begin(): don't check prefixes redundantly

2017-05-22 Thread Michael Haggerty
The backend already correctly restricts its output to references whose names start with the prefix. By passing the prefix again to `prefix_ref_iterator`, we were forcing that iterator to do redundant prefix comparisons. So set it to the empty string. Signed-off-by: Michael Haggerty --- refs.c

[PATCH v2 02/25] refs.h: clarify docstring for the ref_transaction_update()-related fns

2017-05-22 Thread Michael Haggerty
In particular, make it clear that they make copies of the sha1 arguments. Signed-off-by: Michael Haggerty --- refs.h | 13 + 1 file changed, 13 insertions(+) diff --git a/refs.h b/refs.h index 685a979a0e..ec8c6bfbbb 100644 --- a/refs.h +++ b/refs.h @@ -427,6 +427,19 @@ struct

[PATCH v2 03/25] ref_iterator_begin_fn(): fix docstring

2017-05-22 Thread Michael Haggerty
, `cache_ref_iterator_begin()` (from which the files reference iterator gets its values) automatically wraps its output using `prefix_ref_iterator_begin()` when necessary, so it has the stricter behavior. Signed-off-by: Michael Haggerty --- refs/refs-internal.h | 7 --- 1 file changed, 4 insertions

[PATCH v2 01/25] t3600: clean up permissions test properly

2017-05-22 Thread Michael Haggerty
`test_when_finished` block so that it can't be skipped. Signed-off-by: Michael Haggerty --- t/t3600-rm.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index 5f9913ba33..f8568f8841 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@

[PATCH v2 12/25] files_transaction_cleanup(): new helper function

2017-05-22 Thread Michael Haggerty
Extract the cleanup functionality from `files_transaction_commit()` into a new function. It will soon have another caller. Use the common cleanup code even on early exit if the transaction is empty, to reduce code duplication. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 33

[PATCH v2 00/25] Prepare to separate out a packed_ref_store

2017-05-22 Thread Michael Haggerty
f the changes (which works but is not yet polished), checkout the `mmap-packed-refs` branch from the same place. Michael [1] http://public-inbox.org/git/cover.1495014840.git.mhag...@alum.mit.edu/ [2] https://github.com/mhagger/git Jeff King (1): ref-filter: limit traversal to prefix Michael Hag

[PATCH v2 11/25] files_ref_store: put the packed files lock directly in this struct

2017-05-22 Thread Michael Haggerty
p track of whether it is locked. This keeps related data together and makes the main reference store less of a special case. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 29 +++-- 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/refs/files-backen

[PATCH v2 10/25] files-backend: move `lock` member to `files_ref_store`

2017-05-22 Thread Michael Haggerty
Move the `lock` member from `packed_ref_cache` to `files_ref_store`, since at most one cache can have a locked "packed-refs" file associated with it. Rename it to `packed_refs_lock` to make its purpose clearer in its new home. More changes are coming here shortly. Signed-off-by: Michae

[PATCH v2 14/25] ref_transaction_prepare(): new optional step for reference updates

2017-05-22 Thread Michael Haggerty
_abort`. A `ref_transaction_commit()` now basically calls methods `transaction_prepare` then `transaction_finish`. Signed-off-by: Michael Haggerty --- refs.c | 74 -- refs.h | 124 --- refs/files-backe

[PATCH v2 08/25] ref_store: take a `msg` parameter when deleting references

2017-05-22 Thread Michael Haggerty
efs_delete_refs()`. Signed-off-by: Michael Haggerty --- builtin/fetch.c| 2 +- builtin/remote.c | 4 ++-- refs.c | 11 ++- refs.h | 12 +++- refs/files-backend.c | 4 ++-- refs/refs-internal.h

[PATCH v2 05/25] prefix_ref_iterator: don't trim too much

2017-05-22 Thread Michael Haggerty
7;s be cautious here. Report a bug if ever asked to trim a reference whose name is not longer than `trim`. Signed-off-by: Michael Haggerty --- refs/iterator.c | 18 +- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/refs/iterator.c b/refs/iterator.c index bce1f19

[PATCH v2 04/25] files-backend: use `die("BUG: ...")`, not `die("internal error: ...")`

2017-05-22 Thread Michael Haggerty
The former is by far more common in our codebase. 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 cb1f528cbe..fa5d2b6f08 100644 --- a/refs/files-backend.c +++ b

[PATCH v2 20/25] read_packed_refs(): do more of the work of reading packed refs

2017-05-22 Thread Michael Haggerty
Teach `read_packed_refs()` to also * Allocate and initialize the new `packed_ref_cache` * Open and close the `packed-refs` file * Update the `validity` field of the new object This decreases the coupling between `packed_refs_cache` and `files_ref_store` by a little bit. Signed-off-by: Michael

[PATCH v2 19/25] get_packed_ref_cache(): assume "packed-refs" won't change while locked

2017-05-22 Thread Michael Haggerty
If we've got the "packed-refs" file locked, then it can't change; there's no need to keep calling `stat_validity_check()` on it. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 16 +++- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git

[PATCH v2 15/25] ref_update_reject_duplicates(): expose function to whole refs module

2017-05-22 Thread Michael Haggerty
It will soon have some other users. Signed-off-by: Michael Haggerty --- refs.c | 17 + refs/files-backend.c | 17 - refs/refs-internal.h | 8 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/refs.c b/refs.c index b3860a9e33

[PATCH v2 22/25] refs_ref_iterator_begin(): handle `GIT_REF_PARANOIA`

2017-05-22 Thread Michael Haggerty
Instead of handling `GIT_REF_PARANOIA` in `files_ref_iterator_begin()`, handle it in `refs_ref_iterator_begin()`, where it will cover all reference stores. Signed-off-by: Michael Haggerty --- refs.c | 5 + refs/files-backend.c | 11 --- 2 files changed, 9 insertions

[PATCH v2 17/25] ref_update_reject_duplicates(): add a sanity check

2017-05-22 Thread Michael Haggerty
It's pretty cheap to make sure that the caller didn't pass us an unsorted list by accident, so do so. Signed-off-by: Michael Haggerty --- refs.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/refs.c b/refs.c index 143936a9c3..d1c781d94e 100644 --- a/re

[PATCH v2 25/25] cache_ref_iterator_begin(): avoid priming unneeded directories

2017-05-22 Thread Michael Haggerty
e latter yet, because it might be useful for another patch series that I'm working on. Signed-off-by: Michael Haggerty --- refs/ref-cache.c | 94 ++-- 1 file changed, 84 insertions(+), 10 deletions(-) diff --git a/refs/ref-cache.c b/refs/ref

[PATCH v2 21/25] read_packed_refs(): report unexpected fopen() failures

2017-05-22 Thread Michael Haggerty
re such problems. So report any failures that are not due to ENOENT. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index b4fa745cd7..dbfd03f989 100644 --- a/refs/f

[PATCH v2 23/25] create_ref_entry(): remove `check_name` option

2017-05-22 Thread Michael Haggerty
Only one caller was using it, so move the check to that caller. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 12 refs/ref-cache.c | 6 +- refs/ref-cache.h | 3 +-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/refs/files-backend.c b

[PATCH v2 24/25] ref-filter: limit traversal to prefix

2017-05-22 Thread Michael Haggerty
). So, since this is just an optimization, punt on the case of multiple patterns. Signed-off-by: Jeff King Signed-off-by: Michael Haggerty --- ref-filter.c | 64 +++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/ref-filte

[PATCH v2 13/25] ref_transaction_commit(): check for valid `transaction->state`

2017-05-22 Thread Michael Haggerty
Move the check that `transaction->state` is valid from `files_transaction_commit()` to `ref_transaction_commit()`, where other future reference backends can benefit from it as well. Signed-off-by: Michael Haggerty --- refs.c | 12 refs/files-backend.c | 3 ---

[PATCH v2 18/25] should_pack_ref(): new function, extracted from `files_pack_refs()`

2017-05-22 Thread Michael Haggerty
Extract a function for deciding whether a reference should be packed. It is a self-contained bit of logic, so splitting it out improves readability. Signed-off-by: Michael Haggerty --- refs/files-backend.c | 42 -- 1 file changed, 28 insertions(+), 14

Re: [PATCH] refs: handle null-oid for pseudorefs

2018-05-07 Thread Michael Haggerty
On 05/06/2018 03:35 PM, Martin Ågren wrote: > According to the documentation on `git update-ref`, it is possible to > "specify 40 '0' or an empty string as to make sure that the > ref you are creating does not exist." But in the code for pseudorefs, we > do not implement this. If we fail to read t

Re: Implementing reftable in Git

2018-05-11 Thread Michael Haggerty
On Wed, May 9, 2018 at 4:33 PM, Christian Couder wrote: > I might start working on implementing reftable in Git soon. > [...] Nice. It'll be great to have a reftable implementation in git core (and ideally libgit2, as well). It seems to me that it could someday become the new default reference st

Re: commit-graph: change in "best" merge-base when ambiguous

2018-05-21 Thread Michael Haggerty
On 05/21/2018 08:10 PM, Derrick Stolee wrote: > [...] > In the Discussion section of the `git merge-base` docs [1], we have the > following: > >     When the history involves criss-cross merges, there can be more than > one best common ancestor for two commits. For example, with this topology: >

Re: commit-graph: change in "best" merge-base when ambiguous

2018-05-24 Thread Michael Haggerty
On 05/25/2018 12:08 AM, Jakub Narebski wrote: > Derrick Stolee writes: >> On 5/22/2018 1:39 AM, Michael Haggerty wrote: >>> On 05/21/2018 08:10 PM, Derrick Stolee wrote: >>>> [...] >>> This may be beyond the scope of what you are working on, but there are &g

<    5   6   7   8   9   10   11   12   13   14   >