git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Jakub Narębski" <jnareb@gmail.com>
To: Stefan Beller <sbeller@google.com>
Cc: Stefan Beller <stefanbeller@gmail.com>,
	"git@vger.kernel.org" <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>,
	Jacob Keller <jacob.keller@gmail.com>
Subject: Re: [PATCHv4] diff.c: emit moved lines with a different color
Date: Tue, 6 Sep 2016 19:51:26 +0200	[thread overview]
Message-ID: <82367750-adea-6dee-198a-e39ac7a84b31@gmail.com> (raw)
In-Reply-To: <CAGZ79kZPzEYV=gdhzXQetXoe4+1zdh67eyL-gGh9EOCSbRwzWw@mail.gmail.com>

W dniu 06.09.2016 o 19:03, Stefan Beller pisze:
> On Tue, Sep 6, 2016 at 7:05 AM, Jakub Narębski <jnareb@gmail.com> wrote:

>> 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...
> 
> Can you please elaborate on how you'd use that as a user?
> 
> The -M and -C options only operate on the file level, e.g.
> these options are very good at things introduced via:
> 
>     git mv A B
>     $EDIT B # only a little.
> 
> So these options make no sense when operating only on one
> file or on many files that stay the same and only change very little.
> 
> The goal of my patch here is to improve cases like 11979b98
> (2005-11-18, http.c: reorder to avoid compilation failure.)
>
> In that case we just move code around, not necessarily across file
> boundaries.
>
> So that seems orthogonal to the -M/-C option as it operates on another
> level. (file vs line)

The idea for an alternative way of turning on color marking of moved
lines was to follow an example of "git blame", where _doubling_
of a command means more extensive move / copy detection (accompanied
by new values for `diff.renames`).

From git-blame(1) manpage:

-C|<num>|
     In addition to -M, detect lines moved or copied from other files
     that were modified in the same commit. [...]. When this option
     is given twice, the command additionally looks for copies from
     other files in the commit that creates the file. When this option
     is given three times, the command additionally looks for copies
     from other files in any commit.

Color marking of moved lines may be considered enhancing of exiting
whole-file movement and whole-file copy detection.


But it is not a good UI if the feature is to be turned on by default.
Your proposal of adding `--color-moved` and `color.moved` is better.
 
> In another email you asked whether this new approach works in the
> word-by-word diff, which it unfortunately doesn't yet, but I would think
> that it is the same problem (line vs word granularity).

I don't know how it is done internally, but I think word diff is done
by using words (as defined by `diff.<driver>.wordRegex`) in place
of lines...

Best,
-- 
Jakub Narębski


      reply	other threads:[~2016-09-06 17:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-06  7:01 [PATCHv4] diff.c: emit moved lines with a different color Stefan Beller
2016-09-06 13:37 ` Ramsay Jones
2016-09-07 18:52   ` Junio C Hamano
2016-09-06 14:05 ` Jakub Narębski
2016-09-06 17:03   ` Stefan Beller
2016-09-06 17:51     ` Jakub Narębski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=82367750-adea-6dee-198a-e39ac7a84b31@gmail.com \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jacob.keller@gmail.com \
    --cc=sbeller@google.com \
    --cc=stefanbeller@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).