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

Re: [PATCHv4] diff.c: emit moved lines with a different color

From
Jakub Narębski <jnareb@gmail.com>
Date
Sep 6, 2016, 14:05 UTC
Message-ID
<15618224-a9f3-bbe7-3556-8fd8aab2a2a4@gmail.com>
In-Reply-To
<20160906070151.15163-1-stefanbeller@gmail.com>
W dniu 06.09.2016 o 09:01, Stefan Beller pisze:
Show 6 quoted lines
> ---
> 
>  * moved new data structures into struct diff_options
>  * color.moved=bool as well as --[no-]color-moved to {dis,en}able the new feature
>  * color.diff.movedfrom and color.diff.movedto to control the colors
>  * added a test
[...]
Show 14 quoted lines
> diff --git a/Documentation/config.txt b/Documentation/config.txt
> index 0bcb679..5daf77a 100644
> --- a/Documentation/config.txt
> +++ b/Documentation/config.txt
> @@ -974,14 +974,22 @@ This does not affect linkgit:git-format-patch[1] or the
>  'git-diff-{asterisk}' plumbing commands.  Can be overridden on the
>  command line with the `--color[=<when>]` option.
>  
> +color.moved::
> +	A boolean value, whether a diff should color moved lines
> +	differently. The moved lines are searched for in the diff only.
> +	Duplicated lines from somewhere in the project that are not
> +	part of the diff are not colored as moved.
> +	Defaults to true.
[...]
Show 14 quoted lines
> diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
> index 705a873..13b6a2a 100644
> --- a/Documentation/diff-options.txt
> +++ b/Documentation/diff-options.txt
> @@ -234,6 +234,13 @@ ifdef::git-diff[]
>  endif::git-diff[]
>  	It is the same as `--color=never`.
>  
> +--[no-]color-moved::
> +	Show moved blocks in a different color.
> +ifdef::git-diff[]
> +	It can be changed by the `diff.ui` and `color.diff`
> +	configuration settings.
> +endif::git-diff[]

If not for `color.moved`, I would have thought that instead of adding new command line option `--color-moved` (and the fact that it is on by default), we could simply reuse duplication of code movement detection as a signal of stronger detection, namely "-M -M" (and also "-C -C" to handle copy detection) that git-blame uses...

-- 
Jakub Narębski
Previous: Junio C HamanoNext: Stefan Beller
Message 4 of 6 in “[PATCHv4] diff.c: emit moved lines with a different color”
  1. Stefan BellerSep 6, 2016
  2. Ramsay JonesSep 6, 2016
  3. Junio C HamanoSep 7, 2016
  4. Jakub NarębskiSep 6, 2016
  5. Stefan BellerSep 6, 2016
  6. Jakub NarębskiSep 6, 2016

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.