fix(cli): judge --output by the caller-named output rule, not os.Create

main
No checks reported

Commit

Suhaan Thayyil3d ago

index --report already answers this question, in 70KB of code with its own test file: a destination inside a checkout the invocation implicates was chosen by the repository rather than by the caller, so a committed symlink on that path is refused instead of followed, while a path outside every such checkout stays caller-owned and is written as before.

--output is the second caller-named destination, and it had none of that. The spelling the documentation shows is the in-repo one -- --output graph.compact.ndjson -- so a hostile clone that commits that name as a symlink had the snapshot truncate and replace whatever it pointed at. Opening it with os.Create now turns the committed-symlink test red while the caller-owned half stays green.

The rule is not reimplemented. writeOutputFile is now openOutputFile followed by a write, so the streaming sink a snapshot needs and the buffered one the report needs cannot drift apart: a second answer to this question would be the one that gets it wrong.