<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/templates, branch v2.31.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.31.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.31.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2020-10-16T15:47:02Z</updated>
<entry>
<title>hook: add sample template for push-to-checkout</title>
<updated>2020-10-16T15:47:02Z</updated>
<author>
<name>Adam Spiers</name>
<email>git@adamspiers.org</email>
</author>
<published>2020-10-15T22:54:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e632c464d5dbbda72ae370ff6e9cbe31c01b0bb0'/>
<id>urn:sha1:e632c464d5dbbda72ae370ff6e9cbe31c01b0bb0</id>
<content type='text'>
The template is a more-or-less exact translation to shell of the C
code for the default behaviour for git's push-to-checkout hook defined
in the push_to_deploy() function in builtin/receive-pack.c, to serve
as a convenient starting point for modification.

It also contains relevant text extracted from the git-config(1) and
githooks(5) man pages.

Signed-off-by: Adam Spiers &lt;git@adamspiers.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hooks--update.sample: use hash-agnostic zero OID</title>
<updated>2020-09-23T16:31:45Z</updated>
<author>
<name>Denton Liu</name>
<email>liu.denton@gmail.com</email>
</author>
<published>2020-09-23T09:38:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d8d3d632f4165955da49032d50279c20cfbde2e5'/>
<id>urn:sha1:d8d3d632f4165955da49032d50279c20cfbde2e5</id>
<content type='text'>
The update sample hook has the zero OID hardcoded as 40 zeros. However,
with the introduction of SHA-256 support, this assumption no longer
holds true. Replace the hardcoded $z40 with a call to

	git hash-object --stdin &lt;/dev/null | tr '[0-9a-f]' '0'

so the sample hook becomes hash-agnostic.

Signed-off-by: Denton Liu &lt;liu.denton@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hooks--pre-push.sample: use hash-agnostic zero OID</title>
<updated>2020-09-23T16:31:45Z</updated>
<author>
<name>Denton Liu</name>
<email>liu.denton@gmail.com</email>
</author>
<published>2020-09-23T09:38:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=8c7e5059506c6840bfbd4dd8d1730784a5689719'/>
<id>urn:sha1:8c7e5059506c6840bfbd4dd8d1730784a5689719</id>
<content type='text'>
The pre-push sample hook has the zero OID hardcoded as 40 zeros.
However, with the introduction of SHA-256 support, this assumption no
longer holds true. Replace the hardcoded $z40 with a call to

	git hash-object --stdin &lt;/dev/null | tr '[0-9a-f]' '0'

so the sample hook becomes hash-agnostic.

Signed-off-by: Denton Liu &lt;liu.denton@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hooks--pre-push.sample: modernize script</title>
<updated>2020-09-23T16:31:45Z</updated>
<author>
<name>Denton Liu</name>
<email>liu.denton@gmail.com</email>
</author>
<published>2020-09-23T09:38:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6a117da6e523a82115733682f4d3f59755897d5a'/>
<id>urn:sha1:6a117da6e523a82115733682f4d3f59755897d5a</id>
<content type='text'>
The preferred form for a command substitution is $() over ``. Use this
form for the command substitution in the sample hook.

The preferred form for conditional tests is to use `test` over [].
Replace [] with `test`.

Finally, replace all instances of "sha" with "oid".

Signed-off-by: Denton Liu &lt;liu.denton@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'kw/fsmonitor-watchman-racefix'</title>
<updated>2020-02-14T20:54:20Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-02-14T20:54:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c9a33e5e5d7e124feb86ccff08ea466faff53b26'/>
<id>urn:sha1:c9a33e5e5d7e124feb86ccff08ea466faff53b26</id>
<content type='text'>
A new version of fsmonitor-watchman hook has been introduced, to
avoid races.

* kw/fsmonitor-watchman-racefix:
  fsmonitor: update documentation for hook version and watchman hooks
  fsmonitor: add fsmonitor hook scripts for version 2
  fsmonitor: handle version 2 of the hooks that will use opaque token
  fsmonitor: change last update timestamp on the index_state to opaque token
</content>
</entry>
<entry>
<title>Merge branch 'lh/bool-to-type-bool'</title>
<updated>2020-01-30T22:17:11Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-01-30T22:17:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7050624abceb6f7b4ca0ca7ddfce5831f8a40b8f'/>
<id>urn:sha1:7050624abceb6f7b4ca0ca7ddfce5831f8a40b8f</id>
<content type='text'>
Replace "git config --bool" calls with "git config --type=bool" in
sample templates.

* lh/bool-to-type-bool:
  templates: fix deprecated type option `--bool`
</content>
</entry>
<entry>
<title>fsmonitor: add fsmonitor hook scripts for version 2</title>
<updated>2020-01-23T23:10:23Z</updated>
<author>
<name>Kevin Willford</name>
<email>Kevin.Willford@microsoft.com</email>
</author>
<published>2020-01-23T15:26:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e4e1e8342aa03c4e4585908736a103130cc8906d'/>
<id>urn:sha1:e4e1e8342aa03c4e4585908736a103130cc8906d</id>
<content type='text'>
Version 2 of the fsmonitor hooks is passed the version and an update
token and must pass back a last update token to use for subsequent calls
to the hook.

Signed-off-by: Kevin Willford &lt;Kevin.Willford@microsoft.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>templates: fix deprecated type option `--bool`</title>
<updated>2020-01-21T22:11:20Z</updated>
<author>
<name>Lucius Hu</name>
<email>orctarorga@gmail.com</email>
</author>
<published>2020-01-19T22:53:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=81e3db42f3212a8e441e4ecee9a2928921cb9045'/>
<id>urn:sha1:81e3db42f3212a8e441e4ecee9a2928921cb9045</id>
<content type='text'>
The `--bool` option to `git-config` is marked as historical, and users are
recommended to use `--type=bool` instead. This commit replaces all occurrences
of `--bool` in the templates.

Also note that, no other deprecated type options are found, including `--int`,
`--bool-or-int`, `--path`, or `--expiry-date`.

Signed-off-by: Lucius Hu &lt;orctarorga@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'kw/fsmonitor-watchman-fix'</title>
<updated>2019-12-01T17:04:33Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-12-01T17:04:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=fc7b26c907b7a07c143611c5acf31daa88a35eb3'/>
<id>urn:sha1:fc7b26c907b7a07c143611c5acf31daa88a35eb3</id>
<content type='text'>
The watchman integration for fsmonitor was racy, which has been
corrected to be more conservative.

* kw/fsmonitor-watchman-fix:
  fsmonitor: fix watchman integration
</content>
</entry>
<entry>
<title>fsmonitor: fix watchman integration</title>
<updated>2019-11-06T03:23:30Z</updated>
<author>
<name>Kevin Willford</name>
<email>kewillf@microsoft.com</email>
</author>
<published>2019-11-04T17:50:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=dd0b61f577f041f1119bb3288451f8f9b7f9e3f2'/>
<id>urn:sha1:dd0b61f577f041f1119bb3288451f8f9b7f9e3f2</id>
<content type='text'>
When running Git commands quickly -- such as in a shell script or the
test suite -- the Git commands frequently complete and start again
during the same second. The example fsmonitor hooks to integrate with
Watchman truncate the nanosecond times to seconds. In principle, this is
fine, as Watchman claims to use inclusive comparisons [1]. The result
should only be an over-representation of the changed paths since the
last Git command.

However, Watchman's own documentation claims "Using a timestamp is prone
to race conditions in understanding the complete state of the file tree"
[2]. All of their documented examples use a "clockspec" that looks like
'c:123:234'. Git should eventually learn how to store this type of
string to provide a stronger integration, but that will be a more
invasive change.

When using GIT_TEST_FSMONITOR="$(pwd)/t7519/fsmonitor-watchman", scripts
such as t7519-wtstatus.sh fail due to these race conditions. In fact,
running any test script with GIT_TEST_FSMONITOR pointing at
t/t7519/fsmonitor-wathcman will cause failures in the test_commit
function. The 'git add "$indir$file"' command fails due to not enough
time between the creation of '$file' and the 'git add' command.

For now, subtract one second from the timestamp we pass to Watchman.
This will make our window large enough to avoid these race conditions.
Increasing the window causes tests like t7519-wtstatus.sh to pass.

When the integration was introduced in def437671 (fsmonitor: add a
sample integration script for Watchman, 2018-09-22), the query included
an expression that would ignore files created and deleted in that
window. The performance reason for this change was to ignore temporary
files created by a build between Git commands. However, this causes
failures in script scenarios where Git is creating or deleting files
quickly.

When using GIT_TEST_FSMONITOR as before, t2203-add-intent.sh fails
due to this add-and-delete race condition.

By removing the "expression" from the Watchman query, we remove this
race condition. It will lead to some performance degradation in the case
of users creating and deleting temporary files inside their working
directory between Git commands. However, that is a cost we need to pay
to be correct.

[1] https://github.com/facebook/watchman/blob/master/query/since.cpp#L35-L39
[2] https://facebook.github.io/watchman/docs/clockspec.html

Helped-by: Derrick Stolee &lt;dstolee@microsoft.com&gt;
Signed-off-by: Kevin Willford &lt;Kevin.Willford@microsoft.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
