{"thread":{"id":"23174","subject":"git blame -M problem","startedAt":"2010-03-25T14:07:52Z","lastAt":"2010-03-25T14:07:52Z","messageCount":1,"participants":["Bo Yang"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"137796","messageId":"41f08ee11003250707ta80f691mbd66a7d88a99e589@mail.gmail.com","threadId":"23174","inReplyTo":null,"subject":"git blame -M problem","fromName":"Bo Yang","fromEmail":"struggleyb.nku@gmail.com","sentAt":"2010-03-25T14:07:52Z","receivedAt":"2010-03-25T14:07:52Z","isPatch":false,"sender":{"key":"struggleyb.nku@gmail.com","avatar":"https://avatars.githubusercontent.com/u/233030?v=4"},"body":"Hi,\n    I am now digging into blame/log code recent days. And I find that\n'git blame -M' act not as what express in the document. In the docs:\n\n-M|<num>|\nDetect moving lines in the file as well. When a commit moves a block\nof lines in a file (e.g. the original file has A and then B, and the\ncommit changes it to B and then A), the traditional blame algorithm\ntypically blames the lines that were moved up (i.e. B) to the parent\nand assigns blame to the lines that were moved down (i.e. A) to the\nchild commit. With this option, both groups of lines are blamed on the\nparent.\n\n<num> is optional but it is the lower bound on the number of\nalphanumeric characters that git must detect as moving within a file\nfor it to associate those lines with the parent commit.\n\nIt said, -M will blame the moved code to its author before movement.\nBut from the code, I find, the function 'find_move_in_parent' is\nreally try to find some same code with the current suspected lines in\nthe current blamed file instead of searching code movement. So, if you\nhave a file like:\n-------------------\nbyang@byang-laptop:~/git/test$ cat n\none\ntwo\nthree\none\ntwo\nthree\n--------------------\nNote that, the last three lines is copied from the first three ones.\n\nbyang@byang-laptop:~/git/test$ git blame n\n41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 1) one\n41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 2) two\n41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 3) three\nb2b6ac51 (Bo Yang 2010-03-25 22:01:38 +0800 4) one\nb2b6ac51 (Bo Yang 2010-03-25 22:01:38 +0800 5) two\nb2b6ac51 (Bo Yang 2010-03-25 22:01:38 +0800 6) three\n\nbyang@byang-laptop:~/git/test$ git blame -M1 n\n41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 1) one\n41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 2) two\n41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 3) three\n41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 4) one\n41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 5) two\n41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 6) three\n\nAnd blame -C\n\nbyang@byang-laptop:~/git/test$ git blame -C1 n\n41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 1) one\n41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 2) two\n41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 3) three\nb2b6ac51 (Bo Yang 2010-03-25 22:01:38 +0800 4) one\nb2b6ac51 (Bo Yang 2010-03-25 22:01:38 +0800 5) two\nb2b6ac51 (Bo Yang 2010-03-25 22:01:38 +0800 6) three\n\nbyang@byang-laptop:~/git/test$ git blame -C1 -C1 n\n41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 1) one\n41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 2) two\n41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 3) three\nb2b6ac51 (Bo Yang 2010-03-25 22:01:38 +0800 4) one\nb2b6ac51 (Bo Yang 2010-03-25 22:01:38 +0800 5) two\nb2b6ac51 (Bo Yang 2010-03-25 22:01:38 +0800 6) three\n\nbyang@byang-laptop:~/git/test$ git blame -C1 -C1 -C1 n\n41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 1) one\n41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 2) two\n41f445bd (Bo Yang 2010-03-25 22:01:26 +0800 3) three\nb2b6ac51 (Bo Yang 2010-03-25 22:01:38 +0800 4) one\nb2b6ac51 (Bo Yang 2010-03-25 22:01:38 +0800 5) two\nb2b6ac51 (Bo Yang 2010-03-25 22:01:38 +0800 6) three\n\nSo, I think indeed, -M deals with the code move/copy inside same file\nand -C deal with code copy between files. I am wondering is this\nbehavior desired? If so, should the documents to be changed to make it\nmore clear?\n\nThanks!\n\nRegards!\nBo\n-- \nMy blog: http://blog.morebits.org\n"}]}