Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git blame throws a bad revision error with the -L <n,m> option

One of the git blame options processes a line range. The manual says:

-L Process only line range n,m, counting from 1

Now, I have a file that has over 100 lines. When I run git blame -L 5,15 myFile.txt, git complains:

fatal: bad revision '15'

Interestingly, git does not complain when I run git blame -L 5 myFile.txt.

What's going on?

like image 304
Shaun Luttin Avatar asked Dec 09 '14 17:12

Shaun Luttin


2 Answers

if you quote the lines it will work

git blame -L '10,200' composer.json
like image 198
shaneknysh Avatar answered Oct 04 '22 14:10

shaneknysh


Your command looks correct in that case.

I have checked that problem with my composer.json file, and it's working well. When I try to access more lines than are inside the file, I get an error "file composer.json has only 87 lines".

You get this error only if you have a space before the second value.

git blame -L 10, 200 composer.json 

fatal: bad revision '200'

So I think that's the problem.

Note that PowerShell and/or Posh-Git might inject a space after the comma. Try using the command prompt.

like image 44
René Höhle Avatar answered Oct 04 '22 14:10

René Höhle