<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/notes.h, branch jch</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=jch</id>
<link rel='self' href='https://git.shady.money/git/atom?h=jch'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2024-09-12T17:15:44Z</updated>
<entry>
<title>environment: stop storing "core.notesRef" globally</title>
<updated>2024-09-12T17:15:44Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2024-09-12T11:30:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1e7e4a111f986088abc9194d55349419e5c110c3'/>
<id>urn:sha1:1e7e4a111f986088abc9194d55349419e5c110c3</id>
<content type='text'>
Stop storing the "core.notesRef" config value globally. Instead,
retrieve the value in `default_notes_ref()`. The code is never called in
a hot loop anyway, so doing this on every invocation should be perfectly
fine.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>revision: fix leaking display notes</title>
<updated>2024-06-11T20:15:05Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2024-06-11T09:19:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=97485374377fa62fdd36f4b707e2fcd8f1a7c6c3'/>
<id>urn:sha1:97485374377fa62fdd36f4b707e2fcd8f1a7c6c3</id>
<content type='text'>
We never free the display notes options embedded into `struct revision`.
Implement a new function `release_display_notes()` that we can call in
`release_revisions()` to fix this.

There is another gotcha here though: we play some games with the string
list used to track extra notes refs, where we sometimes set the bit that
indicates that strings should be strdup'd and sometimes unset it. This
dance is done to avoid a copy of an already-allocated string when we
call `enable_ref_display_notes()`. But this dance is rather pointless as
we can instead call `string_list_append_nodup()` to transfer ownership
of the allocated string to the list.

Refactor the code to do so and drop the `strdup_strings` dance.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>notes: move the documentation to the struct</title>
<updated>2023-06-06T00:35:05Z</updated>
<author>
<name>Kristoffer Haugsbakk</name>
<email>code@khaugsbakk.name</email>
</author>
<published>2023-06-05T10:05:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=aeee1408ce98f0527d9d22c3aee96360f341443b'/>
<id>urn:sha1:aeee1408ce98f0527d9d22c3aee96360f341443b</id>
<content type='text'>
Its better to document the struct members directly instead of on a
function that takes a pointer to the struct. This will also make it
easier to update the documentation in the future.

Make adjustments for this new context. Also drop “may contain” since we
don’t need to emphasize that a list could be empty.

Suggested-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Kristoffer Haugsbakk &lt;code@khaugsbakk.name&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>notes: update documentation for `use_default_notes`</title>
<updated>2023-06-06T00:35:03Z</updated>
<author>
<name>Kristoffer Haugsbakk</name>
<email>code@khaugsbakk.name</email>
</author>
<published>2023-06-05T10:05:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a2e9dbb8849a29d010dceea2d5d1cab62d4dee6d'/>
<id>urn:sha1:a2e9dbb8849a29d010dceea2d5d1cab62d4dee6d</id>
<content type='text'>
`suppress_default_notes` was renamed to `use_default_notes` in
3a03cf6b1d (notes: refactor display notes default handling,
2011-03-29).

The commit message says that “values less than one [indicates] “not
set” ”, but what was meant was probably “less than zero” (the author of
3a03cf6b1d agrees on this point).

Signed-off-by: Kristoffer Haugsbakk &lt;code@khaugsbakk.name&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'dl/format-patch-notes-config-fixup'</title>
<updated>2019-12-25T19:21:58Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-12-25T19:21:58Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=17066bea38d14a9f9a7a174f40cd9dc1fd720210'/>
<id>urn:sha1:17066bea38d14a9f9a7a174f40cd9dc1fd720210</id>
<content type='text'>
"git format-patch" can take a set of configured format.notes values
to specify which notes refs to use in the log message part of the
output.  The behaviour of this was not consistent with multiple
--notes command line options, which has been corrected.

* dl/format-patch-notes-config-fixup:
  notes.h: fix typos in comment
  notes: break set_display_notes() into smaller functions
  config/format.txt: clarify behavior of multiple format.notes
  format-patch: move git_config() before repo_init_revisions()
  format-patch: use --notes behavior for format.notes
  notes: extract logic into set_display_notes()
  notes: create init_display_notes() helper
  notes: rename to load_display_notes()
</content>
</entry>
<entry>
<title>notes.h: fix typos in comment</title>
<updated>2019-12-18T20:35:35Z</updated>
<author>
<name>Denton Liu</name>
<email>liu.denton@gmail.com</email>
</author>
<published>2019-12-18T18:17:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e0f9095aaa56f5c731faced2e61ca48df5caedfb'/>
<id>urn:sha1:e0f9095aaa56f5c731faced2e61ca48df5caedfb</id>
<content type='text'>
In 1d7297513d (notes: break set_display_notes() into smaller functions,
2019-12-11), we introduced a comment which had a couple of typos. In the
first typo, we referenced 'enable_default_display_notes' instead of
'enable_ref_display_notes'. In the second typo, we wrote "is a points to"
instead of "is a pointer to". Correct both of these typos.

Reported-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
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>notes: break set_display_notes() into smaller functions</title>
<updated>2019-12-13T19:07:15Z</updated>
<author>
<name>Denton Liu</name>
<email>liu.denton@gmail.com</email>
</author>
<published>2019-12-12T00:49:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1d7297513df66873e68af4b254804151b8ba5359'/>
<id>urn:sha1:1d7297513df66873e68af4b254804151b8ba5359</id>
<content type='text'>
In 8164c961e1 (format-patch: use --notes behavior for format.notes,
2019-12-09), we introduced set_display_notes() which was a monolithic
function with three mutually exclusive branches. Break the function up
into three small and simple functions that each are only responsible for
one task.

This family of functions accepts an `int *show_notes` instead of
returning a value suitable for assignment to `show_notes`. This is for
two reasons. First of all, this guarantees that the external
`show_notes` variable changes in lockstep with the
`struct display_notes_opt`. Second, this prompts future developers to be
careful about doing something meaningful with this value. In fact, a
NULL check is intentionally omitted because causing a segfault here
would tell the future developer that they are meant to use the value for
something meaningful.

One alternative was making the family of functions accept a
`struct rev_info *` instead of the `struct display_notes_opt *`, since
the former contains the `show_notes` field as well. This does not work
because we have to call git_config() before repo_init_revisions().
However, if we had a `struct rev_info`, we'd need to initialize it before
it gets assigned values from git_config(). As a result, we break the
circular dependency by having standalone `int show_notes` and
`struct display_notes_opt notes_opt` variables which temporarily hold
values from git_config() until the values are copied over to `rev`.

To implement this change, we need to get a pointer to
`rev_info::show_notes`. Unfortunately, this is not possible with
bitfields and only direct-assignment is possible. Change
`rev_info::show_notes` to a non-bitfield int so that we can get its
address.

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>notes: extract logic into set_display_notes()</title>
<updated>2019-12-09T21:36:45Z</updated>
<author>
<name>Denton Liu</name>
<email>liu.denton@gmail.com</email>
</author>
<published>2019-12-09T13:10:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=452538c3586a76939faf43019fb7c21b3147309b'/>
<id>urn:sha1:452538c3586a76939faf43019fb7c21b3147309b</id>
<content type='text'>
Instead of open coding the logic that tweaks the variables in
`struct display_notes_opt` within handle_revision_opt(), abstract away the
logic into set_display_notes() so that it can be reused.

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>notes: create init_display_notes() helper</title>
<updated>2019-12-09T21:36:44Z</updated>
<author>
<name>Denton Liu</name>
<email>liu.denton@gmail.com</email>
</author>
<published>2019-12-09T13:10:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e6e230eeae0f3cb46c4c356e6cd0a0f1119a2a83'/>
<id>urn:sha1:e6e230eeae0f3cb46c4c356e6cd0a0f1119a2a83</id>
<content type='text'>
We currently open code the initialization for revs-&gt;notes_opt. Abstract
this away into a helper function so that the logic can be reused in a
future commit.

This is slightly wasteful as we memset the struct twice but this is only
run once so it shouldn't have any major effect.

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>notes: rename to load_display_notes()</title>
<updated>2019-12-09T21:36:42Z</updated>
<author>
<name>Denton Liu</name>
<email>liu.denton@gmail.com</email>
</author>
<published>2019-12-09T13:10:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1e6ed5441a61b5085978e0429691e2e2425f6846'/>
<id>urn:sha1:1e6ed5441a61b5085978e0429691e2e2425f6846</id>
<content type='text'>
According to the function comment, init_display_notes() was supposed to
"Load the notes machinery for displaying several notes trees." Rename
this function to load_display_notes() so that its use is more accurately
represented.

This is done because, in a future commit, we will reuse the name
init_display_notes().

Signed-off-by: Denton Liu &lt;liu.denton@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
