{"thread":{"id":"49964","subject":"behaviour of git-blame -M -C (maybe a bug?)","startedAt":"2018-12-06T22:42:00Z","lastAt":"2018-12-06T22:42:00Z","messageCount":1,"participants":["dmg"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"364715","messageId":"87efau2s7h.fsf@mn.cs.uvic.ca","threadId":"49964","inReplyTo":null,"subject":"behaviour of git-blame -M -C (maybe a bug?)","fromName":"dmg","fromEmail":"dmg@turingmachine.org","sentAt":"2018-12-06T22:41:54Z","receivedAt":"2018-12-06T22:42:00Z","isPatch":false,"sender":{"key":"dmg@turingmachine.org","avatar":null},"body":"\n\nhi everybody,\n\nI am the maintainer of cregit. We are trying to improve blame \ntraceability at the token level (see \nhttps://github.com/dmgerman/papers/blob/master/editorials/cregit/cregit.org)\n\nWe use git-blame heavilty in cregit. One of the features that I \nwould like to add to cregit is the ability track movement of code.\n\nI have been testing git-blame -M -C and I found some behaviour \nthat  seems incorrect. I have created a very simple repository \nthat I think showcases this problem:\n\nhttps://github.com/dmgerman/testBlameMove\n\nthis repo have 4 commits (listed below in order of execution):\n\n1. A file is created tpm-dev.c (authored by D German),\n2. a refactoring (code is moved from tpm-dev.c to \ntpm-dev-common.c, a new file). Author is \"refactor\"\n3. a commit that adds some few contiguous lines (the existence of \nthis commit seems to matter). Author is \"none\"\n4. a commit that changes few lines and alters the result of blame \nfor lines not modified by this commit. Author is \"problem\"\n\nSee below. I am running blame at different commits, showing only \nthe lines attributed to author \"refactor\" (author of commit #2).\n\ndmg@iodine:/tmp/testRepo|master ⇒  git log --oneline\nded1aa1 (HEAD -> master, origin/master) problematic commit\n3720e68 simple commit\n391adba refactoring\n33165cb file before refactoring\n\nif we checkout 391adba and do blame -M -C we get this:\n\ndmg@iodine:/tmp/testRepo|3720e68 ⇒  git checkout 3720e68 && git \nblame -M -C tpm-dev-common.c | grep refactor | head\nHEAD is now at 3720e68 simple commit\n391adba4 tpm-dev-common.c (refactor 2018-12-06 12:41:10 -0800  24) \nbegin_include\n391adba4 tpm-dev-common.c (refactor 2018-12-06 12:41:10 -0800  25) \ninclude|#\n391adba4 tpm-dev-common.c (refactor 2018-12-06 12:41:10 -0800  26) \ndirective|include\n391adba4 tpm-dev-common.c (refactor 2018-12-06 12:41:10 -0800  27) \nfile|\"tpm-dev.h\"\n391adba4 tpm-dev-common.c (refactor 2018-12-06 12:41:10 -0800  28) \nend_include\n391adba4 tpm-dev-common.c (refactor 2018-12-06 12:41:10 -0800 147) \nDECL|function|tpm_common_open (struct file * file,struct tpm_chip \n* chip,struct file_priv * priv)\n391adba4 tpm-dev-common.c (refactor 2018-12-06 12:41:10 -0800 148) \nname|void\n391adba4 tpm-dev-common.c (refactor 2018-12-06 12:41:10 -0800 149) \nname|tpm_common_open\n391adba4 tpm-dev-common.c (refactor 2018-12-06 12:41:10 -0800 150) \nparameter_list|(\n391adba4 tpm-dev-common.c (refactor 2018-12-06 12:41:10 -0800 151) \nname|struct\n\nso far, so good. blame detects the movement. Note that the changes \nby refactor are adding 5 lines (24 to 28) and then adding some at \n147 and beyond.\n\nnow do it for the next commit: 3720e68\n\n\nthings continue to look good. The changes of this commit do not \naffect any of these lines.\n\nnow... the next commit, the problematic: ded1aa1 (author is not \nrefactor)\n\ndmg@iodine:/tmp/testRepo|3720e68 ⇒  git checkout ded1aa1 && git \nblame -M -C tpm-dev-common.c | grep refactor | head\nPrevious HEAD position was 3720e68 simple commit\nHEAD is now at ded1aa1 problematic commit\n391adba4 tpm-dev-common.c (refactor 2018-12-06 12:41:10 -0800  24) \nbegin_include\n391adba4 tpm-dev-common.c (refactor 2018-12-06 12:41:10 -0800  25) \ninclude|#\n391adba4 tpm-dev-common.c (refactor 2018-12-06 12:41:10 -0800  26) \ndirective|include\n391adba4 tpm-dev-common.c (refactor 2018-12-06 12:41:10 -0800  27) \nfile|\"tpm-dev.h\"\n391adba4 tpm-dev-common.c (refactor 2018-12-06 12:41:10 -0800  28) \nend_include\n391adba4 tpm-dev-common.c (refactor 2018-12-06 12:41:10 -0800  29)\n391adba4 tpm-dev-common.c (refactor 2018-12-06 12:41:10 -0800  30) \nbegin_function\n391adba4 tpm-dev-common.c (refactor 2018-12-06 12:41:10 -0800  53) \nname|user_read_timer\n391adba4 tpm-dev-common.c (refactor 2018-12-06 12:41:10 -0800  54) \nargument_list|)\n391adba4 tpm-dev-common.c (refactor 2018-12-06 12:41:10 -0800 150) \nDECL|function|tpm_common_open (struct file * file,struct tpm_chip \n* chip,struct file_priv * priv)\n\nnow blame assigns the lines 29, 30, 53 and 54 to commit 391adba4 \nrefactor!!! This is what I think is a bug.\n(by the way, the changes made in this last commit were between 28 \nand 150)\n\nthank you in advance for any clues on why git-blame is behaving \nlike this.\n\n--dmg\n\n---\nD M German\nhttp://turingmachine.org\n"}]}