<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/attr.h, branch v2.13.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.13.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.13.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2017-03-13T22:28:54Z</updated>
<entry>
<title>pathspec: allow querying for attributes</title>
<updated>2017-03-13T22:28:54Z</updated>
<author>
<name>Brandon Williams</name>
<email>bmwill@google.com</email>
</author>
<published>2017-03-13T18:23:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b0db70465246bb8309d3d12c9bc34ac3f0c1e203'/>
<id>urn:sha1:b0db70465246bb8309d3d12c9bc34ac3f0c1e203</id>
<content type='text'>
The pathspec mechanism is extended via the new
":(attr:eol=input)pattern/to/match" syntax to filter paths so that it
requires paths to not just match the given pattern but also have the
specified attrs attached for them to be chosen.

Based on a patch by Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Brandon Williams &lt;bmwill@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>attr: reformat git_attr_set_direction() function</title>
<updated>2017-02-01T21:46:53Z</updated>
<author>
<name>Brandon Williams</name>
<email>bmwill@google.com</email>
</author>
<published>2017-01-28T02:02:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f0dd042148233ad4681b29f35f3bc3ba3b962474'/>
<id>urn:sha1:f0dd042148233ad4681b29f35f3bc3ba3b962474</id>
<content type='text'>
Move the 'git_attr_set_direction()' up to be closer to the variables
that it modifies as well as a small formatting by renaming the variable
'new' to 'new_direction' so that it is more descriptive.

Update the comment about how 'direction' is used to read the state of
the world.  It should be noted that callers of
'git_attr_set_direction()' should ensure that other threads are not
making calls into the attribute system until after the call to
'git_attr_set_direction()' completes.  This function essentially acts as
reset button for the attribute system and should be handled with care.

Signed-off-by: Brandon Williams &lt;bmwill@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>attr: store attribute stack in attr_check structure</title>
<updated>2017-02-01T21:46:53Z</updated>
<author>
<name>Brandon Williams</name>
<email>bmwill@google.com</email>
</author>
<published>2017-01-28T02:02:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=dc81cf377cd25193a9cf044767917e4f5553c285'/>
<id>urn:sha1:dc81cf377cd25193a9cf044767917e4f5553c285</id>
<content type='text'>
The last big hurdle towards a thread-safe API for the attribute system
is the reliance on a global attribute stack that is modified during each
call into the attribute system.

This patch removes this global stack and instead a stack is stored
locally in each attr_check instance.  This opens up the opportunity for
future optimizations to customize the attribute stack for the attributes
that a particular attr_check struct is interested in.

One caveat with pushing the attribute stack into the attr_check
structure is that the attribute system now needs to keep track of all
active attr_check instances.  Due to the direction mechanism the stack
needs to be dropped when the direction is switched.  In order to ensure
correctness when the direction is changed the attribute system needs to
iterate through all active attr_check instances and drop each of their
stacks.

Signed-off-by: Brandon Williams &lt;bmwill@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>attr: tighten const correctness with git_attr and match_attr</title>
<updated>2017-02-01T21:46:53Z</updated>
<author>
<name>Brandon Williams</name>
<email>bmwill@google.com</email>
</author>
<published>2017-01-28T02:02:04Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e810e0635767afbc9b304d5256fbdb26b59644fa'/>
<id>urn:sha1:e810e0635767afbc9b304d5256fbdb26b59644fa</id>
<content type='text'>
Signed-off-by: Brandon Williams &lt;bmwill@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>attr: eliminate global check_all_attr array</title>
<updated>2017-02-01T21:46:53Z</updated>
<author>
<name>Brandon Williams</name>
<email>bmwill@google.com</email>
</author>
<published>2017-01-28T02:02:02Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=685b2925757e98624e37abe09d49c205a7db5943'/>
<id>urn:sha1:685b2925757e98624e37abe09d49c205a7db5943</id>
<content type='text'>
Currently there is a reliance on 'check_all_attr' which is a global
array of 'attr_check_item' items which is used to store the value of
each attribute during the collection process.

This patch eliminates this global and instead creates an array per
'attr_check' instance which is then used in the attribute collection
process.  This brings the attribute system one step closer to being
thread-safe.

Signed-off-by: Brandon Williams &lt;bmwill@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>attr: use hashmap for attribute dictionary</title>
<updated>2017-02-01T21:46:53Z</updated>
<author>
<name>Brandon Williams</name>
<email>bmwill@google.com</email>
</author>
<published>2017-01-28T02:02:01Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1a600b7555205f80b276659db4fd521658642505'/>
<id>urn:sha1:1a600b7555205f80b276659db4fd521658642505</id>
<content type='text'>
The current implementation of the attribute dictionary uses a custom
hashtable.  This modernizes the dictionary by converting it to the builtin
'hashmap' structure.

Also, in order to enable a threaded API in the future add an
accompanying mutex which must be acquired prior to accessing the
dictionary of interned attributes.

Signed-off-by: Brandon Williams &lt;bmwill@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>attr: retire git_check_attrs() API</title>
<updated>2017-02-01T21:46:52Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-01-28T02:01:58Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1295c2152457c2267d605d353332ae4b3e5e5d5c'/>
<id>urn:sha1:1295c2152457c2267d605d353332ae4b3e5e5d5c</id>
<content type='text'>
Since nobody uses the old API, make it file-scope static, and update
the documentation to describe the new API.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
Signed-off-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Brandon Williams &lt;bmwill@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>attr: convert git_all_attrs() to use "struct attr_check"</title>
<updated>2017-02-01T21:46:52Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-01-30T18:06:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7f8641112de8724a565a47b0f0b2a9b826b6baa9'/>
<id>urn:sha1:7f8641112de8724a565a47b0f0b2a9b826b6baa9</id>
<content type='text'>
This updates the other two ways the attribute check is done via an
array of "struct attr_check_item" elements.  These two niches
appear only in "git check-attr".

 * The caller does not know offhand what attributes it wants to ask
   about and cannot use attr_check_initl() to prepare the
   attr_check structure.

 * The caller may not know what attributes it wants to ask at all,
   and instead wants to learn everything that the given path has.

Such a caller can call attr_check_alloc() to allocate an empty
attr_check, and then call attr_check_append() to add attribute names
one by one.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
Signed-off-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Brandon Williams &lt;bmwill@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>attr: (re)introduce git_check_attr() and struct attr_check</title>
<updated>2017-02-01T21:46:52Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-01-30T18:05:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=37293768d0482f41c5aa7d34cf91b03fdfee9d4e'/>
<id>urn:sha1:37293768d0482f41c5aa7d34cf91b03fdfee9d4e</id>
<content type='text'>
A common pattern to check N attributes for many paths is to

 (1) prepare an array A of N attr_check_item items;
 (2) call git_attr() to intern the N attribute names and fill A;
 (3) repeatedly call git_check_attrs() for path with N and A;

A look-up for these N attributes for a single path P scans the
entire attr_stack, starting from the .git/info/attributes file and
then .gitattributes file in the directory the path P is in, going
upwards to find .gitattributes file found in parent directories.

An earlier commit 06a604e6 (attr: avoid heavy work when we know the
specified attr is not defined, 2014-12-28) tried to optimize out
this scanning for one trivial special case: when the attribute being
sought is known not to exist, we do not have to scan for it.  While
this may be a cheap and effective heuristic, it would not work well
when N is (much) more than 1.

What we would want is a more customized way to skip irrelevant
entries in the attribute stack, and the definition of irrelevance
is tied to the set of attributes passed to git_check_attrs() call,
i.e. the set of attributes being sought.  The data necessary for
this optimization needs to live alongside the set of attributes, but
a simple array of git_attr_check_elem simply does not have any place
for that.

Introduce "struct attr_check" that contains N, the number of
attributes being sought, and A, the array that holds N
attr_check_item items, and a function git_check_attr() that
takes a path P and this structure as its parameters.  This structure
can later be extended to hold extra data necessary for optimization.

Also, to make it easier to write the first two steps in common
cases, introduce git_attr_check_initl() helper function, which takes
a NULL-terminated list of attribute names and initialize this
structure.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
Signed-off-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Brandon Williams &lt;bmwill@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>attr: rename function and struct related to checking attributes</title>
<updated>2017-02-01T21:46:52Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-01-28T02:01:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7bd18054d249d1f9aebad38d74ba6c53f8e6ecb3'/>
<id>urn:sha1:7bd18054d249d1f9aebad38d74ba6c53f8e6ecb3</id>
<content type='text'>
The traditional API to check attributes is to prepare an N-element
array of "struct git_attr_check" and pass N and the array to the
function "git_check_attr()" as arguments.

In preparation to revamp the API to pass a single structure, in
which these N elements are held, rename the type used for these
individual array elements to "struct attr_check_item" and rename
the function to "git_check_attrs()".

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
Signed-off-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Brandon Williams &lt;bmwill@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
