Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git_index.add supports absolute file paths, but Git_index.fold throws when it traverses them #576

Open
nosman opened this issue Jun 25, 2022 · 1 comment
Assignees

Comments

@nosman
Copy link

nosman commented Jun 25, 2022

Consider this example in the top-level:

let index = Git_index.load ~hash:Git_index.SHA1 (Fpath.v "/Users/stsoucas/shadowgraph/save/.git/index") |> Result.get_ok;;
val index : Store.hash Git_index.t = <abstr>
Git_index.add ~hash:Git_index.SHA1 (Fpath.v "/Users/stsoucas/shadowgraph/save/testfile.txt") index |> Result.get_ok;; unit = ()

At this point, I can verify that testfile.txt has been added to the index with git ls-files:

git ls-files
/Users/stsoucas/shadowgraph/save/testfile.txt
Now when I do Git_index.fold:

Git_index.fold ~f:(fun e lst acc -> Lwt_result.return ()) () index;;
Exception: Invalid_argument "\"\": invalid path". Raised at Stdlib.invalid_arg in file "stdlib.ml", line 30, characters 20-45 Called from Git_index.create_graph.insert.(fun) in file "src/git-index/git_index.ml", line 586, characters 41-54 Called from Stdlib__List.fold_left in file "list.ml", line 121, characters 24-34 Called from Git_index.create_graph.insert in file "src/git-index/git_index.ml", line 582, characters 10-398 Called from Stdlib__Array.iter in file "array.ml", line 95, characters 31-48 Called from Git_index.create_graph in file "src/git-index/git_index.ml", line 599, characters 2-29 Called from Git_index.fold in file "src/git-index/git_index.ml", line 669, characters 14-28 Called from unknown location Called from Stdlib__Fun.protect in file "fun.ml", line 33, characters 8-15 Re-raised at Stdlib__Fun.protect in file "fun.ml", line 38, characters 6-52 Called from Topeval.load_lambda in file "toplevel/byte/topeval.ml", line 89, characters 4-150

Valid input should be consistent across these two functions.

@dinosaure dinosaure self-assigned this Sep 30, 2022
@dinosaure
Copy link
Member

Hi, sorry for the large delay.

I just pushed a new PR which add a new test and reproduce your usage with a fix here: #596
This patch breaks the API when load/make requires a root argument which is the root of the Git repository. By this way, we are able to relativize internal paths with the given root value. Tell me if this proposal fix your issue, I will happy to cut a release then 👍.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants