Skip to content

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

@nosman

Description

@nosman

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions