Re: [PATCH v2 1/8] fast-import: tighten path unquoting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



(Sorry for re-sending)

On Apr 9, 2024, at 23:27, Patrick Steinhardt <ps@xxxxxx> wrote:
> On Mon, Apr 01, 2024 at 09:02:47AM +0000, Thalia Archibald wrote:
>> 
>> - if (!*endp)
>> + if (!p)
>> die("Missing dest: %s", command_buf.buf);
> 
> So this statement right now doesn't make a whole lot of sense because
> `p` cannot ever be `NULL` -- we'd segfault before that. Once we update
> `parse_path()` to handle this correctly it will work as expected though.
> 
> I was briefly wondering though whether we really want `parse_path()` to
> set `p` to be a NULL pointer. If we didn't, we could retain the previous
> behaviour here and instead check for `!*p`.

Good catch. There should be a deref there.

This mistake was because I originally planned to not allow unquoted empty
strings and had factored that condition into parse_path. After your round 1
feedback, I changed my mind after reanalysis. The condition you see here is
supposed to match the behavior for before and is removed in patch 3/8. There was
no test before my series exercising this branch and my test for it is added in
3/8, so it wasn't caught in this intermediate version.

>> + ( printf "100644 blob $blob2\t'"$unquoted_path"'\n" &&
>> +   printf "100644 blob $blob1\thello.c\n" ) | sort >tree_m.exp &&
> 
> Also, there is no need to do `'"$unuoted_path"'` here. You should be
> able to refer to `$unquoted_path` just fine even without unquoting again
> because we use eval to execute the code block. In fact, it can even be
> harmful as it is known to break shells under some circumstances. See
> also 7c4449eb31 (t/README: document how to loop around test cases,
> 2024-03-22), which I think should apply in your case, too.

I agree it makes it less finicky. The one upside to string splicing is that when
a test fails, the substitutions are visible in the dump of the shell script. I
found that useful while debugging. The titles can uniquely identify the
$prefix/$path/$suffix values when looking in the source, since they're all
1-to-1. Considering the downsides, I've switched to plain substitutions. 

Thalia





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux