From: Bo Yang <struggleyb.nku@gmail.com>
To: git@vger.kernel.org
Subject: git blame -M problem
Date: Thu, 25 Mar 2010 22:07:52 +0800 [thread overview]
Message-ID: <41f08ee11003250707ta80f691mbd66a7d88a99e589@mail.gmail.com> (raw)
Hi,
I am now digging into blame/log code recent days. And I find that
'git blame -M' act not as what express in the document. In the docs:
-M|<num>|
Detect moving lines in the file as well. When a commit moves a block
of lines in a file (e.g. the original file has A and then B, and the
commit changes it to B and then A), the traditional blame algorithm
typically blames the lines that were moved up (i.e. B) to the parent
and assigns blame to the lines that were moved down (i.e. A) to the
child commit. With this option, both groups of lines are blamed on the
parent.
<num> is optional but it is the lower bound on the number of
alphanumeric characters that git must detect as moving within a file
for it to associate those lines with the parent commit.
It said, -M will blame the moved code to its author before movement.
But from the code, I find, the function 'find_move_in_parent' is
really try to find some same code with the current suspected lines in
the current blamed file instead of searching code movement. So, if you
have a file like:
-------------------
byang@byang-laptop:~/git/test$ cat n
one
two
three
one
two
three
--------------------
Note that, the last three lines is copied from the first three ones.
byang@byang-laptop:~/git/test$ git blame n
41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 1) one
41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 2) two
41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 3) three
b2b6ac51 (Bo Yang 2010-03-25 22:01:38 +0800 4) one
b2b6ac51 (Bo Yang 2010-03-25 22:01:38 +0800 5) two
b2b6ac51 (Bo Yang 2010-03-25 22:01:38 +0800 6) three
byang@byang-laptop:~/git/test$ git blame -M1 n
41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 1) one
41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 2) two
41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 3) three
41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 4) one
41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 5) two
41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 6) three
And blame -C
byang@byang-laptop:~/git/test$ git blame -C1 n
41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 1) one
41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 2) two
41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 3) three
b2b6ac51 (Bo Yang 2010-03-25 22:01:38 +0800 4) one
b2b6ac51 (Bo Yang 2010-03-25 22:01:38 +0800 5) two
b2b6ac51 (Bo Yang 2010-03-25 22:01:38 +0800 6) three
byang@byang-laptop:~/git/test$ git blame -C1 -C1 n
41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 1) one
41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 2) two
41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 3) three
b2b6ac51 (Bo Yang 2010-03-25 22:01:38 +0800 4) one
b2b6ac51 (Bo Yang 2010-03-25 22:01:38 +0800 5) two
b2b6ac51 (Bo Yang 2010-03-25 22:01:38 +0800 6) three
byang@byang-laptop:~/git/test$ git blame -C1 -C1 -C1 n
41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 1) one
41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 2) two
41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 3) three
b2b6ac51 (Bo Yang 2010-03-25 22:01:38 +0800 4) one
b2b6ac51 (Bo Yang 2010-03-25 22:01:38 +0800 5) two
b2b6ac51 (Bo Yang 2010-03-25 22:01:38 +0800 6) three
So, I think indeed, -M deals with the code move/copy inside same file
and -C deal with code copy between files. I am wondering is this
behavior desired? If so, should the documents to be changed to make it
more clear?
Thanks!
Regards!
Bo
--
My blog: http://blog.morebits.org
reply other threads:[~2010-03-25 14:08 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=41f08ee11003250707ta80f691mbd66a7d88a99e589@mail.gmail.com \
--to=struggleyb.nku@gmail.com \
--cc=git@vger.kernel.org \
/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.
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 NNTP newsgroup(s).