Skip to content

Commit

Permalink
fix: The line range (-L) doesn't work with the follow option
Browse files Browse the repository at this point in the history
As introduce in git/git@39664cb
the `-L` and `--follow` options don't work together. This commit
addresses this by only use one or the other based on the presence of the
start/end line options being passed in.

This fixes up the `fatal: -L<range>:<file> cannot be used with pathspec`
error, as well as broken specs.
  • Loading branch information
kevinjalbert committed Oct 24, 2021
1 parent 2930076 commit 4f066d7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/git_evolution/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ def line_commits(start_line, end_line, file, since = nil)

def raw_line_history(start_line, end_line, file, since = nil)
since_option = "--since '#{since}'"
range_option = "-L#{start_line},#{end_line}:#{file}"
follow_option = "--follow '#{file}'"

Dir.chdir(dir) do
return `git --no-pager log -p -z\
#{since_option if since}\
#{"-L#{start_line},#{end_line}:#{file}" if start_line && end_line}\
--follow #{file}`
#{since_option if since}\
#{start_line && end_line ? range_option : follow_option}`
end
end
end
Expand Down

0 comments on commit 4f066d7

Please sign in to comment.