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

Re: [PATCH] svn: use correct variable name for short OID

From
Jeff King <peff@peff.net>
Date
Oct 22, 2020, 03:00 UTC
Message-ID
<20201022030051.GB1480820@coredump.intra.peff.net>
In-Reply-To
<20201022011811.853465-1-sandals@crustytoothpaste.net>
On Thu, Oct 22, 2020 at 01:18:11AM +0000, brian m. carlson wrote:
Show 16 quoted lines
> The commit 9ab33150a0 ("perl: create and switch variables for hash
> constants", 2020-06-22) converted each instance of the variable
> $sha1_short into $oid_short in the Subversion code, since git-svn now
> understands SHA-256.  However, one conversion was missed.
> 
> As a result, Perl complains about the use of this variable:
> 
>   Use of uninitialized value $sha1_short in regexp compilation at
>   /usr/lib64/perl5/vendor_perl/5.30.3/Git/SVN/Log.pm line 301, <$fh>
>   line 6.
> 
> Because we're parsing raw diff output here, the likelihood is very low
> that we'll actually misparse the data, since the only lines we're going
> to get starting with colons are the ones we're expecting.  Even if we
> had a newline in a path, we'd end up with a quoted path.  Our regex is
> just less strict than we'd like it to be.

I agree this is unlikely to matter much in the happy path, but I wondered how confused things could get. I'd never looked at this code before, but it looks like we take git-log @args from the user. So:

  git svn log --format=":123456 123456 foo"

gets mis-parsed. But not only is that exceedingly unlikely in the first place, AFAICT the command was never meant to allow arbitrary formats anyway. It's expecting its own "--pretty=raw" to be respected, so the command above is broken even with your fix.

None of that changes the fix, which is obviously correct, but I wondered if we ought to have better test coverage here. And I've convinced myself the answer is "no"; there's no reasonable-to-test functional impact of this bug or its fix (aside from generating the warning, but it would be silly to write a test for this one warning; if we do anything it should be to complain about any warnings during the test run).

-Peff
Previous: brian m. carlsonNext: Jeff King
Message 9 of 11 in “git svn log: Use of uninitialized value $sha1_short”
  1. Nikos ChantziarasOct 21, 2020
  2. Jeff KingOct 21, 2020
  3. Junio C HamanoOct 21, 2020
  4. Jeff KingOct 21, 2020
  5. brian m. carlsonOct 21, 2020
  6. Jeff KingOct 22, 2020
  7. brian m. carlsonOct 21, 2020
  8. svn: use correct variable name for short OIDbrian m. carlson, Oct 22, 2020
  9. Jeff KingOct 22, 2020
  10. Jeff KingOct 22, 2020
  11. Junio C HamanoOct 22, 2020

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.