0

Currently, based on this question I was able to come up with the following command:

git log -u -L 1626,1626:airflow/www/app.py 7399d6176181190a63b70eeec0f7012156c15332..HEAD

E.g. I'm looking for when line 1626 was modified (deleted) from airflow/www/app.py. The line number is valid in commit 7399d6, but not in HEAD, resulting in the following error:

fatal: file airflow/www/app.py has only 255 lines

(The file is much shorter since then.)

I think I wouldn't have this problem if the file was long enough. Can I maybe turn off this check somehow?

nemkin
  • 95
  • 2
  • 9
  • ```git rev-list 7399d6176181190a63b70eeec0f7012156c15332..HEAD | xargs -i sh -c 'git diff -r {}^..{} airflow/www/app.py | grep expose_config && echo {}'``` worked for me, where expose_config is part of the line I'm looking for. Not sure yet how to grep for any random string with taking care of escaping everything properly. – nemkin Dec 13 '19 at 15:08
  • You might try combining `git bisect` with `git grep` as a faster way to find out when the line vanished: `git bisect bad` a commit that doesn't have the line, `git bisect good` a commit that does, and then use a script to check for the existence of the line as your bisect script (`git bisect run`). – torek Dec 13 '19 at 23:02

3 Answers3

0

git blame path/to/file for each commit in your git log should do the trick.

Lots of modern IDEs also have an 'annotate' option if you right click to the left of the line number which will do the same thing graphically.

What does git blame do?

Chicxen
  • 63
  • 7
  • ```git rev-list 7399d6176181190a63b70eeec0f7012156c15332..HEAD | xargs -i git blame airflow/www/app.py -L 1626,1626 {} 2>/dev/null | uniq``` Seems to work, but extremely slowly since there are 6490 commits between 7399d6 and HEAD. And it doesn't notice that the line number of the commit has increased, but the line itself is still there. I guess I'm looking for something a little bit more clever. – nemkin Dec 13 '19 at 14:19
0

git blame --reverse might help you track down where this happened. You could try using a script that I developed for this task called difflame:

https://github.com/eantoranz/difflame

eftshift0
  • 26,375
  • 3
  • 36
  • 60
0

try this no commit ID

git log -L <fromLine,toLine>:<file>
JackChouMine
  • 947
  • 8
  • 22