Я просто прочитал страницу руководства вины мерзавца еще раз и заметил эту часть:
Особенно полезный путь состоит в том, чтобы видеть, создала ли добавленному файлу строки копия-и-вставка из существующих файлов. Иногда это указывает, что разработчик был неаккуратен и не осуществлял рефакторинг код правильно. Можно сначала найти фиксацию, которая представила файл с:
журнал мерзавца - diff-filter=A - pretty=short - нечто
и затем аннотируйте изменение между фиксацией и ее родителями, с помощью commit^! нотация:
вина мерзавца-C-C-f $commit^! - нечто
Это звучит довольно интересным, но я не делаю вполне grok, как это работает, и почему. Интересно, может ли это использоваться в рычаге мерзавца для обнаружения копии и вставляемого кода.
Некоторый эксперт мерзавца может, возможно, объяснить эффект использования вышеупомянутых команд мерзавца вместе, и возможно ли использовать что-то как этот для создания шоу мерзавца, существует ли дублирование кода (возможно, при помощи 'индекса подобия', которым мерзавец кажется вычисленному при переименовании файлов)?
You can break the commands down individually.
$ git log --diff-filter=A --pretty=short -- foo
displays the log for the file "foo". The --diff-filter
option only shows commits in which files were added ("A"), and shows it in a condensed format (the --pretty=short
option). (The --
is a standard for saying "nothing that follows is an option", and everything after that is a list of file names on which the log should be applied.)
Then:
$ git blame -C -C -f $commit^! -- foo
git blame
annotates each line of a file with information from the last commit. The double -C -C
option aggressively checks for lines that were copied from other files. The -f
option shows the filename of the original commit (which means if a line was copied from another file, you see the name of the file it was copied from). The $commit^!
is notation for a $commit; the ^!
suffix means to exclude all of $commit's parents.
So basically, the first command (git log
) helps you find commits that introduced copied lines; the second (git blame
) helps you find the source for any suspicious commits returned by git log
.