Skip to content

Commit

Permalink
Resolving issue chshersh#18 - status can't print diff when different …
Browse files Browse the repository at this point in the history
…path than root
  • Loading branch information
tekknoid committed Jun 10, 2023
1 parent b9be80f commit 969f00d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/status.ml
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,15 @@ let parse_diff_details (stat_line : string) : diff_details option =
1 file changed, 5 insertions(+), 6 deletions(-)
```
*)

let get_git_base_dir =
Process.proc_stdout "git rev-parse --show-toplevel"
|> String.rstrip ~drop:(fun c -> Char.( = ) c '\n')

let get_file_diff_stat ~(commit : string) ~(file : string) : diff_details =
let diff_stat =
Process.proc_stdout
@@ Printf.sprintf "git diff %s --stat --color=never -- %s" commit file
@@ Printf.sprintf "git diff %s --stat --color=never -- %s" commit (get_git_base_dir ^ "/" ^ file)
in
match String.split_lines diff_stat with
| stat_line :: _ ->
Expand Down

0 comments on commit 969f00d

Please sign in to comment.