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

Re: phpdoc diff in git -L is not the correct one

From
MÅMartin Ågren <martin.agren@gmail.com>
Date
Nov 14, 2020, 15:32 UTC
Message-ID
<CAN0heSrU5zzgR_FDZcEopPP2EmSQnraZXO4v8Smx8=fWcXa0uQ@mail.gmail.com>
In-Reply-To
<348a2a4a-dfdb-190b-edac-01e9ad4c2d4d@greg0ire.fr>
Hi greg0ire,
On Sat, 14 Nov 2020 at 14:28, Grégoire PARIS <postmaster@greg0ire.fr> wrote:
Show 9 quoted lines
> I have recently found out about git -L , which is great! I think I have
> found a
> bug in it though: the diff is correct on the method itself, but changes
> in the
> phpdoc of the method do not seem to be taken into account, while changes
> in the
> phpdoc of the method that follows the one I care about show up in the
> diff. I
> have attached a bug report generated with git bugreport.
This seems to be behaving like documented. Quoting the man-page:
  If :<funcname> is given in place of <start> and <end>, it is a regular
  expression that denotes the range from the first funcname line that
  matches <funcname>, up to the next funcname line.
That range is exactly what you're seeing.

Now, I can certainly understand your wish of peeking backwards to include the phpdoc for that function. You can do that using something like

  git log -L46,76:src/Doctrine/Instantiator/Instantiator.php

but it's obviously a bit more involved to figure out which (approximate) numbers to give.

One way of *only* looking backwards might be to use a regex for the <start>, then a negative offset for <end>:

  git log -L/instantiate\(/,-14:src/Doctrine/Instantiator/Instantiator.php

Alas, this also requires coming up with a decent guess for how far back to look. I can't seem to find a way of using a regex for <end> and searching backwards -- I imagine it could be something like "-/regex/". Anyway, that would just solve half your problem: You'd see the documentation evolve but not the implementation.

In the end I think your best option right now is to give explicit line numbers for <end> and <start>.

Martin
Previous: Grégoire PARISNext: Grégoire PARIS
Message 2 of 7 in “phpdoc diff in git -L is not the correct one”
  1. Grégoire PARISNov 14, 2020
  2. Martin ÅgrenNov 14, 2020
  3. Grégoire PARISNov 14, 2020
  4. Martin ÅgrenNov 14, 2020
  5. René ScharfeNov 14, 2020
  6. Grégoire PARISNov 18, 2020
  7. Martin ÅgrenNov 18, 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.