]> git.99rst.org Git - git.git/commit
t1300: demonstrate failure when renaming sections with long lines
authorTaylor Blau <redacted>
Thu, 6 Apr 2023 15:42:03 +0000 (11:42 -0400)
committerJohannes Schindelin <redacted>
Mon, 17 Apr 2023 19:15:39 +0000 (21:15 +0200)
commit29198213c9163c1d552ee2bdbf78d2b09ccc98b8
treef1034e921aedb3faed6d3ac3250de764fb535530
parent2f3b28f27234a0130583131a6785c44e3dd1cac4
t1300: demonstrate failure when renaming sections with long lines

When renaming a configuration section which has an entry whose length
exceeds the size of our buffer in config.c's implementation of
`git_config_copy_or_rename_section_in_file()`, Git will incorrectly
form a new configuration section with part of the data in the section
being removed.

In this instance, our first configuration file looks something like:

    [b]
      c = d <spaces> [a] e = f
    [a]
      g = h

Here, we have two configuration values, "b.c", and "a.g". The value "[a]
e = f" belongs to the configuration value "b.c", and does not form its
own section.

However, when renaming the section 'a' to 'xyz', Git will write back
"[xyz]\ne = f", but "[xyz]" is still attached to the value of "b.c",
which is why "e = f" on its own line becomes a new entry called "b.e".

A slightly different example embeds the section being renamed within
another section.

Demonstrate this failure in a test in t1300, which we will fix in the
following commit.

Co-authored-by: Johannes Schindelin <redacted>
Helped-by: Jeff King <redacted>
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Taylor Blau <redacted>
t/t1300-config.sh
git clone https://git.99rst.org/PROJECT