Thread (94 messages) 94 messages, 6 authors, 2018-05-08

Re: [PATCH 1/9] git_config_set: fix off-by-two

From: Jeff King <hidden>
Date: 2018-03-29 19:42:06

On Thu, Mar 29, 2018 at 11:15:33AM -0700, Stefan Beller wrote:
quoted
When calling `git config --unset abc.a` on this file, it leaves this
(invalid) config behind:

        [
        [xyz]
                key = value

The reason is that we try to search for the beginning of the line (or
for the end of the preceding section header on the same line) that
defines abc.a, but as an optimization, we subtract 2 from the offset
pointing just after the definition before we call
find_beginning_of_line(). That function, however, *also* performs that
optimization and promptly fails to find the section header correctly.
This commit message would be more convincing if we had it in test form.
I agree a test might be nice. But I don't find the commit message
unconvincing at all. It explains pretty clearly why the bug occurs, and
you can verify it by looking at find_beginning_of_line.
    [abc]a

is not written by Git, but would be written from an outside tool or person
and we barely cope with it?
Yes, I don't think git would ever write onto the same line. But clearly
we should handle anything that's syntactically valid.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help