Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

"object not found" error in object.Change#Files() when To is a submodule #317

Closed
lupine opened this issue Mar 28, 2017 · 1 comment
Closed
Assignees
Labels

Comments

@lupine
Copy link

lupine commented Mar 28, 2017

Discovered after updating to the latest version of gopkg.in/src-d/go-git.v4

I use object#DiffTree() and step through the changes, unconditionally calling change.Files() for each. When I come across the addition of a submodule, I get the aforementioned error, when before I would not.

Does it make more sense for File() to return nil instead for these cases? Presumably there's a similar issue with the From side as well.

@alcortesm
Copy link
Contributor

Thanks for reporting this issue.

I have been able to reproduce the problem and I can confirm it also happens in the From side as well.

The cause of the problem is that change.Files() assumes that change.To and change.From are files, but as you pointed out, this is not true in some cases; they can also refer to:

  • A FileMode.Submodule.
  • A FileMode.Symlink.
  • In theory, to a FileMode.Directory, but our difftree algorithm does not issue changes for directories.

This means not all the hashes in the change.To and change.From will reference blobs (or even file contents) in the storage. For symlinks we should return the content of the symlink, not the file it is linking to.

Does it make more sense for File() to return nil instead for these cases?

Yes, It totally makes sense. The current behaviour (returning a "not found error") is wrong.

We are going to fix this, but I don't know when. In any case, in the meanwhile, we will happily accept PRs.

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants