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 18, 2020, 19:18 UTC
Message-ID
<CAN0heSrqs9GLo6DA8aWGG8JON4NmGCEiw63pR0BJRZHRTZOaFA@mail.gmail.com>
In-Reply-To
<a205cb0c-95ec-7f9e-0dea-8fd5b4bc694f@greg0ire.fr>
On Wed, 18 Nov 2020 at 09:17, Grégoire PARIS <postmaster@greg0ire.fr> wrote:
> On 11/15/20 12:40 AM, René Scharfe wrote:
> >
> > The --function-context options of git diff and git grep try to show
> > comments by including non-empty lines before function lines.
Show 23 quoted lines
> >    This
> > heuristic might work for -L :funcname:file as well (patch below), but
> > breaks seven tests in each of t8001-annotate.sh, t8002-blame.sh and
> > t8012-blame-colors.sh.
>
> I haven't written C in 10 literal years but I think I managed to apply
> this patch, and something looks wrong: it's looking too "far" before:
> See for instance: --- commit 1a8a640f87cad94d36713f45e5e257de20930171
> Author: Michael Moravec <me@majkl.me> Date: Mon Mar 5 04:01:58 2018
> +0100 Upgrade to Doctrine CS 4.0 diff --git
> a/src/Doctrine/Instantiator/Instantiator.php
> b/src/Doctrine/Instantiator/Instantiator.php ---
> a/src/Doctrine/Instantiator/Instantiator.php +++
> b/src/Doctrine/Instantiator/Instantiator.php @@ -31,12 +33,14 @@ */
> private static $cachedInstantiators = []; /** - * @var object[] of
> objects that can directly be cloned, indexed by class name + * Array of
> objects that can directly be cloned, indexed by class name. + * + * @var
> object[] */ private static $cachedCloneables = []; /** * {@inheritDoc}
> */ public function instantiate($className) --- Here it's picking changes
> in the phpdoc of the property that precedes `instantiate`, (when using
> git log
> -L/instantiate\(/,-14:src/Doctrine/Instantiator/Instantiator.php) What's
> wrong? -- greg0ire
So to reproduce, it's first something like this?
  git clone https://github.com/doctrine/instantiator.git
  cd instantiator
  echo '*.php diff=php' >>.gitattributes
Then this?
  git log -L/instantiate\(/,-14:src/Doctrine/Instantiator/Instantiator.php
Or should that be the following?
  git log -L :instantiate:src/Doctrine/Instantiator/Instantiator.php

I played around a little, but couldn't seem to hit 1a8a640f87 as you mentioned.

Martin
Previous: Grégoire PARIS
Message 7 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.