git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Trailers Containing Underscore or Dot Characters

From
ふふじを <ffjlabo@gmail.com>
Date
Nov 13, 2024, 07:40 UTC
Message-ID
<CABpqQ_u4GG28L9KGX+HXiOv2AVAL7sckRBN4a99pCyeaQS+n_w@mail.gmail.com>

Hi everyone, First of all, thank you for making such a tool. I am grateful to use this tool every day.

I encountered the issue with trailers containing Underscore or Dot characters. I don't know if this behavior is OK as a specification, or not. So I created the post.

What did you do before the bug happened? (Steps to reproduce your issue)
I added coommit with trailers which have "_" or "." in each key.
```
git commit -m "Test" --trailer "test_hoge: fuga" --trailer "test.hoge:
fuga" --trailer "test-hoge: fuga"
```
What did you expect to happen? (Expected behavior)
I expcted that they are shown like this.
```
# git show
    Test
    test_hoge: fuga
    test.hoge: fuga
    test-hoge: fuga
```
What happened instead? (Actual behavior)
Actually, some of them are unexpected value.
```
# git show
commit 70afae811def2345bead6660e0f3183662c9f4df (HEAD -> master)
Author: Your Name <you@example.com>
Date:   Wed Nov 13 08:28:19 2024 +0300
    Test
    test_hoge: fuga:
    test.hoge: fuga:
    test-hoge: fuga
```
What's different between what you expected and what actually happened?

The one for `--trailer "test-hoge: fuga"` is finished with nothing. But The others for ones which have "_" or "." are finished with ":".

Anything else you want to add:

I want to use such characters to add some key-value received other service (e.g. GitHub Actions) as is. Is there any chance that characters like _ and . will be allowed in the trailer's key?

By the way, I tried the investigation for the current specification. I hope this is helpful in some way.

[1] This behavior occured when executing `git interpret-trailers`. ``` # echo msg > msg # git interpret-trailers --trailer "test_hoge: test" --trailer "test.hoge: test" --trailer "test-hoge: test" --in-place msg ``` ``` # cat msg msg test_hoge: test: test.hoge: test: test-hoge: test ``` [2] There might be the cause in the process of the persing trailers. if they have such characters, the whole of the trailer option values are interpreted as one token even though they have ":" if they have such characters.

I checked the source code at
- parse_trailers_from_command_line_args
https://github.com/git/git/blob/564d0252ca632e0264ed670534a51d18a689ef5d/trailer.c#L748C1-L764C4
- -> find_separator
https://github.com/git/git/blob/564d0252ca632e0264ed670534a51d18a689ef5d/trailer.c#L614C1-L642C1

[System Info] git version: git version 2.43.0 cpu: aarch64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh uname: Linux 6.10.11-orbstack-00280-g1304bd068592 #21 SMP Sat Sep 21 10:45:28 UTC 2024 aarch64 compiler info: gnuc: 13.2 libc info: glibc: 2.39 $SHELL (typically, interactive shell): <unset> [Enabled Hooks]

Next: Christian Couder
Message 1 of 8 in “Trailers Containing Underscore or Dot Characters”
  1. ふじをNov 13, 2024
  2. Christian CouderNov 13, 2024
  3. Junio C HamanoNov 13, 2024
  4. Patrick SteinhardtNov 15, 2024
  5. Junio C HamanoNov 18, 2024
  6. Documentation/glossary: describe "trailer"kristofferhaugsbakk@fastmail.com, Nov 17, 2024
  7. Junio C HamanoNov 18, 2024
  8. Christian CouderNov 18, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.