<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/ident.c, 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>2025-08-21T20:46:57Z</updated>
<entry>
<title>Merge branch 'ps/reflog-migrate-fixes'</title>
<updated>2025-08-21T20:46:57Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2025-08-21T20:46:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c3c8b6910a7cd3d5a25522d3fd6925083048be24'/>
<id>urn:sha1:c3c8b6910a7cd3d5a25522d3fd6925083048be24</id>
<content type='text'>
"git refs migrate" to migrate the reflog entries from a refs
backend to another had a handful of bugs squashed.

* ps/reflog-migrate-fixes:
  refs: fix invalid old object IDs when migrating reflogs
  refs: stop unsetting REF_HAVE_OLD for log-only updates
  refs/files: detect race when generating reflog entry for HEAD
  refs: fix identity for migrated reflogs
  ident: fix type of string length parameter
  builtin/reflog: implement subcommand to write new entries
  refs: export `ref_transaction_update_reflog()`
  builtin/reflog: improve grouping of subcommands
  Documentation/git-reflog: convert to use synopsis type
</content>
</entry>
<entry>
<title>ident: fix type of string length parameter</title>
<updated>2025-08-06T14:36:30Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2025-08-06T05:54:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9fdbba862dfa53cf347fd9f05e99bd1f13c5eb0c'/>
<id>urn:sha1:9fdbba862dfa53cf347fd9f05e99bd1f13c5eb0c</id>
<content type='text'>
The last parameter in `split_ident_line()` is the length of the line
passed in by the caller. As such, most callers pass in either the result
of `strlen()`, `struct strbuf::len` or a pointer diff, all of which
are expected to be positive numbers. Regardless of that, the function
accepts a signed integer, which is somewhat confusing.

Fix the function signature to instead accept a `size_t`.

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>Merge branch 'sa/multi-mailmap-fix'</title>
<updated>2025-06-24T16:48:51Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2025-06-24T16:48:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1e60e1d6d8e769c71547569d127f8149bffcd9ff'/>
<id>urn:sha1:1e60e1d6d8e769c71547569d127f8149bffcd9ff</id>
<content type='text'>
When asking to apply mailmap to both author and committer field
while showing a commit object, the field that appears later was not
correctly parsed and replaced, which has been corrected.

* sa/multi-mailmap-fix:
  cat-file: fix mailmap application for different author and committer
</content>
</entry>
<entry>
<title>cat-file: fix mailmap application for different author and committer</title>
<updated>2025-06-13T15:54:51Z</updated>
<author>
<name>Siddharth Asthana</name>
<email>siddharthasthana31@gmail.com</email>
</author>
<published>2025-06-13T11:57:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=abf94a283fd85e680f8d720241e6059dbb5f23f5'/>
<id>urn:sha1:abf94a283fd85e680f8d720241e6059dbb5f23f5</id>
<content type='text'>
The git cat-file command with --mailmap option fails to apply mailmap
transformations to the committer field when the author and committer
identities are different. This occurs due to a missing newline handling
in apply_mailmap_to_header() after processing each identity line.

When rewrite_ident_line() processes an identity, it stops at the end
of the identity data (e.g., "Author Name &lt;email&gt; timestamp"), but
doesn't account for the trailing newline. The current code adds the
identity length to buf_offset but fails to advance past the newline
character. This causes the next iteration to start parsing from the
newline instead of the beginning of the next header line, making it
impossible to match subsequent headers like "committer".

Additionally, rewrite_ident_line() may reallocate the buffer during
its operation. Any code using pointers into the old buffer would be
using invalid memory after such a reallocation.

This bug was introduced in e9c1b0e3 (revision: improve
commit_rewrite_person(), 2022-07-19) when the much simpler version of
commit_rewrite_person() that worked on one "person header" at a time
was rewritten to use the current apply_mailmap_to_header() function.
The original implementation processed author and committer separately,
but the rewrite introduced this loop-based approach that failed to
properly handle the transition between identity lines.

Let's fix this by addressing both issues:
1. After processing an identity line, we now check if we're at a
   newline and advance past it, ensuring the next header line is
   parsed correctly.
2. We recompute the buffer position after rewrite_ident_line() to
   handle potential buffer reallocation.

This ensures that all identity headers in commit and tag objects are
consistently processed regardless of whether the author and committer
are the same person.

Reported-by: Vasilii Iakliushin &lt;viakliushin@gitlab.com&gt;
Reviewed-by: Christian Couder &lt;christian.couder@gmail.com&gt;
Signed-off-by: Siddharth Asthana &lt;siddharthasthana31@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>ident: stop assuming that `gw_gecos` is writable</title>
<updated>2025-03-06T16:35:07Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2025-03-06T10:26:18Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=4478ad37a7d233b8db4d46dd563ece0bc8b00af4'/>
<id>urn:sha1:4478ad37a7d233b8db4d46dd563ece0bc8b00af4</id>
<content type='text'>
In 590e081dea7c (ident: add NO_GECOS_IN_PWENT for systems without
pw_gecos in struct passwd, 2011-05-19), code was introduced to iterate
over the `gw_gecos` field; The loop variable is of type `char *`, which
assumes that `gw_gecos` is writable.

However, it is not necessarily writable (and it is a bad idea to have it
writable in the first place), so let's switch the loop variable type to
`const char *`.

This is not a new problem, but what is new is the Meson build. While it
does not trigger in CI builds, imitating the commands of
`ci/run-build-and-tests.sh` in a regular Git for Windows SDK (`meson
setup build . --fatal-meson-warnings --warnlevel 2 --werror --wrap-mode
nofallback -Dfuzzers=true` followed by `meson compile -C build --`
results in this beautiful error:

  "cc" [...] -o libgit.a.p/ident.c.obj "-c" ../ident.c
  ../ident.c: In function 'copy_gecos':
  ../ident.c:68:18: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
     68 |         for (src = get_gecos(w); *src &amp;&amp; *src != ','; src++) {
        |                  ^
  cc1.exe: all warnings being treated as errors

Now, why does this not trigger in CI? The answer is as simple as it is
puzzling: The `win+Meson` job completely side-steps Git for Windows'
development environment, opting instead to use the GCC that is on the
`PATH` in GitHub-hosted `windows-latest` runners. That GCC is pinned to
v12.2.0 and targets the UCRT (unlikely to change any time soon, see
https://github.com/actions/runner-images/blob/win25/20250303.1/images/windows/toolsets/toolset-2022.json#L132-L141).
That is in stark contrast to Git for Windows, which uses GCC v14.2.0 and
targets MSVCRT. Git for Windows' `Makefile`-based build also obviously
uses different compiler flags, otherwise this compile error would have
had plenty of opportunity in almost 14 years to surface.

In other words, contrary to my expectations, the `win+Meson` job is
ill-equipped to replace the `win build` job because it exercises a
completely different tool version/compiler flags vector than what Git
for Windows needs.

Nevertheless, there is currently this huge push, including breaking
changes after -rc1 and all, for switching to Meson. Therefore, we need
to make it work, somehow, even in Git for Windows' SDK, hence this
patch, at this point in time.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>ident: add casts for fallback name and GECOS</title>
<updated>2024-06-07T17:30:51Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2024-06-07T06:38:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=32f9929109e2858b81403f2cbb2a80774f822859'/>
<id>urn:sha1:32f9929109e2858b81403f2cbb2a80774f822859</id>
<content type='text'>
In `xgetpwuid_self()`, we return a fallback identity when it was not
possible to look up the current identity. This fallback identity needs
to be internal and must never be written to by the calles as specified
by getpwuid(3P). As both the `pw_name` and `pw_gecos` fields are marked
as non-constant though, it will cause a warning to assign constant
strings to them once compiling with `-Wwrite-strings`.

Add explicit casts to avoid the warning.

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>Merge branch 'bc/ident-dot-is-no-longer-crud-letter'</title>
<updated>2023-08-09T23:18:15Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2023-08-09T23:18:15Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=cf07e53bae8492fc6ee8a8d394e2fba858daa0a4'/>
<id>urn:sha1:cf07e53bae8492fc6ee8a8d394e2fba858daa0a4</id>
<content type='text'>
Exclude "." from the set of characters to be removed from the
beginning and the end of the human-readable name.

* bc/ident-dot-is-no-longer-crud-letter:
  ident: don't consider '.' a crud
</content>
</entry>
<entry>
<title>ident: don't consider '.' a crud</title>
<updated>2023-08-02T16:50:52Z</updated>
<author>
<name>brian m. carlson</name>
<email>sandals@crustytoothpaste.net</email>
</author>
<published>2023-08-02T16:49:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1c04cb0744d2acdcaebc77b0e78c47efbba67fd5'/>
<id>urn:sha1:1c04cb0744d2acdcaebc77b0e78c47efbba67fd5</id>
<content type='text'>
When we process a user's name (as in user.name), we strip all
leading and trailing crud from it.  Right now, we consider a dot
a crud character, and strip it off.

However, this is unsuitable for many personal names because humans
frequently have abbreviated suffixes, such as "Jr." or "Sr." at the end
of their names, and this corrupts them.  Some other users may wish to
use an abbreviated name or initial, which will pose a problem especially
in cultures that write the family name first, followed by the personal
name.

Since the current approach causes lots of practical problems, let's
avoid it by no longer considering a dot to be crud.

Note that "." in the name forces the entire name to be quoted to
please mailers, but stripping "." only at the beginning and the end
does not help a name with "." in the middle (like "brian m. carlson")
so this change will not make it much worse.  A name like "Given
Family, Jr." that did not have to be quoted now would need to be, in
order to be placed on the e-mail headers, though.

This is based on a weather-balloon patch by Jeff King sent in Aug 2021
https://lore.kernel.org/git/YSKm8Q8nyTavQaox@coredump.intra.peff.net/

Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>config: add ctx arg to config_fn_t</title>
<updated>2023-06-28T21:06:39Z</updated>
<author>
<name>Glen Choo</name>
<email>chooglen@google.com</email>
</author>
<published>2023-06-28T19:26:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a4e7e317f8f27f861321e6eb08b9c8c0f3ab570c'/>
<id>urn:sha1:a4e7e317f8f27f861321e6eb08b9c8c0f3ab570c</id>
<content type='text'>
Add a new "const struct config_context *ctx" arg to config_fn_t to hold
additional information about the config iteration operation.
config_context has a "struct key_value_info kvi" member that holds
metadata about the config source being read (e.g. what kind of config
source it is, the filename, etc). In this series, we're only interested
in .kvi, so we could have just used "struct key_value_info" as an arg,
but config_context makes it possible to add/adjust members in the future
without changing the config_fn_t signature. We could also consider other
ways of organizing the args (e.g. moving the config name and value into
config_context or key_value_info), but in my experiments, the
incremental benefit doesn't justify the added complexity (e.g. a
config_fn_t will sometimes invoke another config_fn_t but with a
different config value).

In subsequent commits, the .kvi member will replace the global "struct
config_reader" in config.c, making config iteration a global-free
operation. It requires much more work for the machinery to provide
meaningful values of .kvi, so for now, merely change the signature and
call sites, pass NULL as a placeholder value, and don't rely on the arg
in any meaningful way.

Most of the changes are performed by
contrib/coccinelle/config_fn_ctx.pending.cocci, which, for every
config_fn_t:

- Modifies the signature to accept "const struct config_context *ctx"
- Passes "ctx" to any inner config_fn_t, if needed
- Adds UNUSED attributes to "ctx", if needed

Most config_fn_t instances are easily identified by seeing if they are
called by the various config functions. Most of the remaining ones are
manually named in the .cocci patch. Manual cleanups are still needed,
but the majority of it is trivial; it's either adjusting config_fn_t
that the .cocci patch didn't catch, or adding forward declarations of
"struct config_context ctx" to make the signatures make sense.

The non-trivial changes are in cases where we are invoking a config_fn_t
outside of config machinery, and we now need to decide what value of
"ctx" to pass. These cases are:

- trace2/tr2_cfg.c:tr2_cfg_set_fl()

  This is indirectly called by git_config_set() so that the trace2
  machinery can notice the new config values and update its settings
  using the tr2 config parsing function, i.e. tr2_cfg_cb().

- builtin/checkout.c:checkout_main()

  This calls git_xmerge_config() as a shorthand for parsing a CLI arg.
  This might be worth refactoring away in the future, since
  git_xmerge_config() can call git_default_config(), which can do much
  more than just parsing.

Handle them by creating a KVI_INIT macro that initializes "struct
key_value_info" to a reasonable default, and use that to construct the
"ctx" arg.

Signed-off-by: Glen Choo &lt;chooglen@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>ident.h: move ident-related declarations out of cache.h</title>
<updated>2023-02-24T01:25:29Z</updated>
<author>
<name>Elijah Newren</name>
<email>newren@gmail.com</email>
</author>
<published>2023-02-24T00:09:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b5fa608180d4270b3495258ab098426551a18372'/>
<id>urn:sha1:b5fa608180d4270b3495258ab098426551a18372</id>
<content type='text'>
These functions were all defined in a separate ident.c already, so
create ident.h and move the declarations into that file.

Signed-off-by: Elijah Newren &lt;newren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
