2
0

README 1.6 KB

123456789101112131415161718192021222324252627282930313233
  1. This is the dulwich project.
  2. It aims to give an interface to git repos that doesn't call out to git
  3. directly but instead uses pure Python.
  4. Currently can read blobs, trees and commits from the files. It reads both
  5. legacy and new headers. It can write out new indexes as well.
  6. Can also understand a little about the repository format.
  7. Open up a repo by passing it the path to the .git dir. You can then ask for
  8. HEAD with repo.head() or a ref with repo.ref(name). Both return the SHA id
  9. they currently point to. You can then grab this object with
  10. repo.get_object(sha).
  11. For the actual objects the ShaFile.from_file(filename) will return the object
  12. stored in the file whatever it is. To ensure you get the correct type then
  13. call {Blob,Tree,Commit}.from_file(filename). I will add repo methods to do
  14. this for you with file lookup soon.
  15. There is also support for creating blobs. Blob.from_string(string) will create
  16. a blob object from the string. You can then call blob.sha() to get the sha
  17. object for this blob, and hexdigest() on that will get its ID. There is
  18. currently no method that allows you to write it out though.
  19. Everything is currently done with assertions, where much of it should probably
  20. be exceptions. This was merely done for expediency. If you hit an assertion,
  21. it either means you have done something wrong, there is corruption, or
  22. you are trying an unsupported operation.
  23. The project is named after the part of London that Mr. and Mrs. Git live in
  24. in the particular Monty Python sketch. It is based on the Python-Git module
  25. that James Westby <jw+debian@jameswestby.net> released in 2007.