diff --git a/docs/diff.rst b/docs/diff.rst index 09fc9da..dc7bf4d 100644 --- a/docs/diff.rst +++ b/docs/diff.rst @@ -50,8 +50,8 @@ Attributes: .. autoattribute:: pygit2.Patch.old_file_path .. autoattribute:: pygit2.Patch.new_file_path -.. autoattribute:: pygit2.Patch.old_oid -.. autoattribute:: pygit2.Patch.new_oid +.. autoattribute:: pygit2.Patch.old_id +.. autoattribute:: pygit2.Patch.new_id .. autoattribute:: pygit2.Patch.status .. autoattribute:: pygit2.Patch.similarity .. autoattribute:: pygit2.Patch.hunks diff --git a/docs/merge.rst b/docs/merge.rst index 4d98590..47984a8 100644 --- a/docs/merge.rst +++ b/docs/merge.rst @@ -22,8 +22,8 @@ merge with the default ones defined in GIT_MERGE_OPTS_INIT libgit2 constant. Example:: >>> branch_head_hex = '5ebeeebb320790caf276b9fc8b24546d63316533' - >>> branch_oid = self.repo.get(branch_head_hex).id - >>> merge_result = self.repo.merge(branch_oid) + >>> branch_id = self.repo.get(branch_head_hex).id + >>> merge_result = self.repo.merge(branch_id) The MergeResult object ====================== @@ -33,5 +33,5 @@ Represents the result of a merge and contains these fields: - is_uptodate: bool, if there wasn't any merge because the repo was already up to date - is_fastforward: bool, whether the merge was fastforward or not -- fastforward_oid: Oid, in the case it was a fastforward, this is the - forwarded Oid. +- fastforward_id: Oid, in the case it was a fastforward, this is the + forwarded id. diff --git a/docs/objects.rst b/docs/objects.rst index 3583c17..b9d038b 100644 --- a/docs/objects.rst +++ b/docs/objects.rst @@ -14,14 +14,14 @@ type. Object lookup ================= -In the previous chapter we learnt about Object IDs. With an oid we can ask the +In the previous chapter we learnt about Object IDs. With an Oid we can ask the repository to get the associated object. To do that the ``Repository`` class implementes a subset of the mapping interface. .. automethod:: pygit2.Repository.get - Return the Git object for the given *oid*, returns the *default* value if - there's no object in the repository with that oid. The oid can be an Oid + Return the Git object for the given *id*, returns the *default* value if + there's no object in the repository with that id. The id can be an Oid object, or an hexadecimal string. Example:: @@ -32,16 +32,16 @@ implementes a subset of the mapping interface. >>> obj <_pygit2.Commit object at 0x7ff27a6b60f0> -.. method:: Repository.__getitem__(oid) +.. method:: Repository.__getitem__(id) - Return the Git object for the given oid, raise ``KeyError`` if there's no - object in the repository with that oid. The oid can be an Oid object, or + Return the Git object for the given id, raise ``KeyError`` if there's no + object in the repository with that id. The id can be an Oid object, or an hexadecimal string. -.. method:: Repository.__contains__(oid) +.. method:: Repository.__contains__(id) - Returns True if there is an object in the Repository with that oid, False - if there is not. The oid can be an Oid object, or an hexadecimal string. + Returns True if there is an object in the Repository with that id, False + if there is not. The id can be an Oid object, or an hexadecimal string. The Object base type @@ -125,15 +125,15 @@ them to the Git object database: Example: - >>> oid = repo.create_blob('foo bar') # Creates blob from bytes string - >>> blob = repo[oid] + >>> id = repo.create_blob('foo bar') # Creates blob from bytes string + >>> blob = repo[id] >>> blob.data 'foo bar' .. automethod:: pygit2.Repository.create_blob_fromworkdir .. automethod:: pygit2.Repository.create_blob_fromdisk -There are also some functions to calculate the oid for a byte string without +There are also some functions to calculate the id for a byte string without creating the blob object: .. autofunction:: pygit2.hash diff --git a/docs/references.rst b/docs/references.rst index 363e3ee..049fa81 100644 --- a/docs/references.rst +++ b/docs/references.rst @@ -92,8 +92,8 @@ Example:: >>> for entry in head.log(): ... print(entry.message) -.. autoattribute:: pygit2.RefLogEntry.oid_new -.. autoattribute:: pygit2.RefLogEntry.oid_old +.. autoattribute:: pygit2.RefLogEntry.id_new +.. autoattribute:: pygit2.RefLogEntry.id_old .. autoattribute:: pygit2.RefLogEntry.message .. autoattribute:: pygit2.RefLogEntry.committer @@ -109,6 +109,6 @@ The Note type -------------------- .. autoattribute:: pygit2.Note.annotated_id -.. autoattribute:: pygit2.Note.oid +.. autoattribute:: pygit2.Note.id .. autoattribute:: pygit2.Note.message .. automethod:: pygit2.Note.remove diff --git a/docs/working-copy.rst b/docs/working-copy.rst index 76bcada..cc1853d 100644 --- a/docs/working-copy.rst +++ b/docs/working-copy.rst @@ -8,8 +8,8 @@ Index read:: >>> index = repo.index >>> index.read() - >>> oid = index['path/to/file'].id # from path to object id - >>> blob = repo[oid] # from object id to object + >>> id = index['path/to/file'].id # from path to object id + >>> blob = repo[id] # from object id to object Iterate over all entries of the index:: @@ -43,7 +43,7 @@ The Index type The IndexEntry type -------------------- -.. autoattribute:: pygit2.IndexEntry.oid +.. autoattribute:: pygit2.IndexEntry.id .. autoattribute:: pygit2.IndexEntry.hex .. autoattribute:: pygit2.IndexEntry.path .. autoattribute:: pygit2.IndexEntry.mode diff --git a/src/diff.c b/src/diff.c index da08874..3aeddeb 100644 --- a/src/diff.c +++ b/src/diff.c @@ -80,8 +80,8 @@ wrap_patch(git_patch *patch) py_patch->status = git_diff_status_char(delta->status); py_patch->similarity = delta->similarity; py_patch->flags = delta->flags; - py_patch->old_oid = git_oid_allocfmt(&delta->old_file.oid); - py_patch->new_oid = git_oid_allocfmt(&delta->new_file.oid); + py_patch->old_id = git_oid_allocfmt(&delta->old_file.id); + py_patch->new_id = git_oid_allocfmt(&delta->new_file.id); git_patch_line_stats(NULL, &additions, &deletions, patch); py_patch->additions = additions; @@ -149,8 +149,8 @@ static void Patch_dealloc(Patch *self) { Py_CLEAR(self->hunks); - free(self->old_oid); - free(self->new_oid); + free(self->old_id); + free(self->new_id); /* We do not have to free old_file_path and new_file_path, they will * be freed by git_diff_list_free in Diff_dealloc */ PyObject_Del(self); @@ -159,8 +159,8 @@ Patch_dealloc(Patch *self) PyMemberDef Patch_members[] = { MEMBER(Patch, old_file_path, T_STRING, "old file path"), MEMBER(Patch, new_file_path, T_STRING, "new file path"), - MEMBER(Patch, old_oid, T_STRING, "old oid"), - MEMBER(Patch, new_oid, T_STRING, "new oid"), + MEMBER(Patch, old_id, T_STRING, "old oid"), + MEMBER(Patch, new_id, T_STRING, "new oid"), MEMBER(Patch, status, T_CHAR, "status"), MEMBER(Patch, similarity, T_INT, "similarity"), MEMBER(Patch, hunks, T_OBJECT, "hunks"), diff --git a/src/index.c b/src/index.c index 7269749..1ae3a1b 100644 --- a/src/index.c +++ b/src/index.c @@ -628,7 +628,7 @@ IndexEntry_init(IndexEntry *self, PyObject *args, PyObject *kwds) return -1; if (id) - git_oid_cpy(&self->entry.oid, &id->oid); + git_oid_cpy(&self->entry.id, &id->oid); if (mode) self->entry.mode = mode; @@ -689,18 +689,18 @@ IndexEntry_path__set__(IndexEntry *self, PyObject *py_path) return 0; } -PyDoc_STRVAR(IndexEntry_oid__doc__, "Object id."); +PyDoc_STRVAR(IndexEntry_id__doc__, "Object id."); PyObject * -IndexEntry_oid__get__(IndexEntry *self) +IndexEntry_id__get__(IndexEntry *self) { - return git_oid_to_python(&self->entry.oid); + return git_oid_to_python(&self->entry.id); } int -IndexEntry_oid__set__(IndexEntry *self, PyObject *py_id) +IndexEntry_id__set__(IndexEntry *self, PyObject *py_id) { - if (!py_oid_to_git_oid(py_id, &self->entry.oid)) + if (!py_oid_to_git_oid(py_id, &self->entry.id)) return -1; return 0; @@ -711,13 +711,13 @@ PyDoc_STRVAR(IndexEntry_hex__doc__, "Hex id."); PyObject * IndexEntry_hex__get__(IndexEntry *self) { - return git_oid_to_py_str(&self->entry.oid); + return git_oid_to_py_str(&self->entry.id); } PyGetSetDef IndexEntry_getseters[] = { GETSET(IndexEntry, mode), GETSET(IndexEntry, path), - GETSET(IndexEntry, oid), + GETSET(IndexEntry, id), GETTER(IndexEntry, hex), {NULL}, }; diff --git a/src/mergeresult.c b/src/mergeresult.c index 345e56e..4579e4b 100644 --- a/src/mergeresult.c +++ b/src/mergeresult.c @@ -80,15 +80,15 @@ MergeResult_is_fastforward__get__(MergeResult *self) Py_RETURN_FALSE; } -PyDoc_STRVAR(MergeResult_fastforward_oid__doc__, "Fastforward Oid"); +PyDoc_STRVAR(MergeResult_fastforward_id__doc__, "Fastforward Oid"); PyObject * -MergeResult_fastforward_oid__get__(MergeResult *self) +MergeResult_fastforward_id__get__(MergeResult *self) { if (git_merge_result_is_fastforward(self->result)) { - git_oid fastforward_oid; - git_merge_result_fastforward_oid(&fastforward_oid, self->result); - return git_oid_to_python((const git_oid *)&fastforward_oid); + git_oid fastforward_id; + git_merge_result_fastforward_id(&fastforward_id, self->result); + return git_oid_to_python((const git_oid *)&fastforward_id); } else Py_RETURN_NONE; } @@ -96,7 +96,7 @@ MergeResult_fastforward_oid__get__(MergeResult *self) PyGetSetDef MergeResult_getseters[] = { GETTER(MergeResult, is_uptodate), GETTER(MergeResult, is_fastforward), - GETTER(MergeResult, fastforward_oid), + GETTER(MergeResult, fastforward_id), {NULL}, }; diff --git a/src/note.c b/src/note.c index e14e308..9762ef6 100644 --- a/src/note.c +++ b/src/note.c @@ -66,13 +66,13 @@ Note_remove(Note *self, PyObject* args) } -PyDoc_STRVAR(Note_oid__doc__, +PyDoc_STRVAR(Note_id__doc__, "Gets the id of the blob containing the note message\n"); PyObject * -Note_oid__get__(Note *self) +Note_id__get__(Note *self) { - return git_oid_to_python(git_note_oid(self->note)); + return git_oid_to_python(git_note_id(self->note)); } @@ -108,7 +108,7 @@ PyMemberDef Note_members[] = { PyGetSetDef Note_getseters[] = { GETTER(Note, message), - GETTER(Note, oid), + GETTER(Note, id), {NULL} }; diff --git a/src/repository.c b/src/repository.c index 738627f..53f9649 100644 --- a/src/repository.c +++ b/src/repository.c @@ -588,9 +588,9 @@ Repository_merge_base(Repository *self, PyObject *args) } PyDoc_STRVAR(Repository_merge__doc__, - "merge(oid) -> MergeResult\n" + "merge(id) -> MergeResult\n" "\n" - "Merges the given oid and returns the MergeResult.\n" + "Merges the given id and returns the MergeResult.\n" "\n" "If the merge is fastforward the MergeResult will contain the new\n" "fastforward oid.\n" @@ -614,7 +614,7 @@ Repository_merge(Repository *self, PyObject *py_oid) if (len == 0) return NULL; - err = git_merge_head_from_oid(&oid_merge_head, self->repo, &oid); + err = git_merge_head_from_id(&oid_merge_head, self->repo, &oid); if (err < 0) return Error_set(err); diff --git a/src/types.h b/src/types.h index cfd0009..f127399 100644 --- a/src/types.h +++ b/src/types.h @@ -114,8 +114,8 @@ typedef struct { PyObject* hunks; const char * old_file_path; const char * new_file_path; - char* old_oid; - char* new_oid; + char* old_id; + char* new_id; char status; unsigned similarity; unsigned additions; diff --git a/test/test_diff.py b/test/test_diff.py index f982d01..2f4314d 100644 --- a/test/test_diff.py +++ b/test/test_diff.py @@ -257,13 +257,13 @@ class DiffTest(utils.BareRepoTestCase): self.assertEqual(diff.patch, PATCH) self.assertEqual(len(diff), len([patch for patch in diff])) - def test_diff_oids(self): + def test_diff_ids(self): commit_a = self.repo[COMMIT_SHA1_1] commit_b = self.repo[COMMIT_SHA1_2] patch = commit_a.tree.diff_to_tree(commit_b.tree)[0] - self.assertEqual(patch.old_oid, + self.assertEqual(patch.old_id, '7f129fd57e31e935c6d60a0c794efe4e6927664b') - self.assertEqual(patch.new_oid, + self.assertEqual(patch.new_id, 'af431f20fc541ed6d5afede3e2dc7160f6f01f16') def test_hunk_content(self): diff --git a/test/test_index.py b/test/test_index.py index 7bed86b..1426e7f 100644 --- a/test/test_index.py +++ b/test/test_index.py @@ -181,13 +181,13 @@ class IndexTest(utils.RepoTestCase): index = self.repo.index entry = index['hello.txt'] ign_entry = index['.gitignore'] - self.assertNotEqual(ign_entry.oid, entry.oid) + self.assertNotEqual(ign_entry.id, entry.id) self.assertNotEqual(entry.mode, pygit2.GIT_FILEMODE_BLOB_EXECUTABLE) entry.path = 'foo.txt' - entry.oid = ign_entry.oid + entry.id = ign_entry.id entry.mode = pygit2.GIT_FILEMODE_BLOB_EXECUTABLE self.assertEqual('foo.txt', entry.path) - self.assertEqual(ign_entry.oid, entry.oid) + self.assertEqual(ign_entry.id, entry.id) self.assertEqual(pygit2.GIT_FILEMODE_BLOB_EXECUTABLE, entry.mode) def test_write_tree_to(self): @@ -201,7 +201,7 @@ class IndexEntryTest(utils.RepoTestCase): def test_create_entry(self): index = self.repo.index hello_entry = index['hello.txt'] - entry = pygit2.IndexEntry('README.md', hello_entry.oid, hello_entry.mode) + entry = pygit2.IndexEntry('README.md', hello_entry.id, hello_entry.mode) index.add(entry) tree_id = index.write_tree() self.assertEqual('60e769e57ae1d6a2ab75d8d253139e6260e1f912', str(tree_id)) diff --git a/test/test_note.py b/test/test_note.py index 74f0894..4fcead5 100644 --- a/test/test_note.py +++ b/test/test_note.py @@ -58,7 +58,7 @@ class NotesTest(utils.BareRepoTestCase): def test_lookup_note(self): annotated_id = self.repo.head.target.hex note = self.repo.lookup_note(annotated_id) - self.assertEqual(NOTES[0][0], note.oid.hex) + self.assertEqual(NOTES[0][0], note.id.hex) self.assertEqual(NOTES[0][1], note.message) def test_remove_note(self): @@ -70,7 +70,7 @@ class NotesTest(utils.BareRepoTestCase): def test_iterate_notes(self): for i, note in enumerate(self.repo.notes()): - entry = (note.oid.hex, note.message, note.annotated_id) + entry = (note.id.hex, note.message, note.annotated_id) self.assertEqual(NOTES[i], entry) def test_iterate_non_existing_ref(self): diff --git a/test/test_repository.py b/test/test_repository.py index 71214cc..8da7311 100644 --- a/test/test_repository.py +++ b/test/test_repository.py @@ -314,7 +314,7 @@ class RepositoryTest_III(utils.RepoTestCaseForMerging): merge_result = self.repo.merge(branch_oid) self.assertTrue(merge_result.is_uptodate) self.assertFalse(merge_result.is_fastforward) - self.assertEqual(None, merge_result.fastforward_oid) + self.assertEqual(None, merge_result.fastforward_id) self.assertEqual({}, self.repo.status()) def test_merge_fastforward(self): @@ -324,8 +324,8 @@ class RepositoryTest_III(utils.RepoTestCaseForMerging): self.assertFalse(merge_result.is_uptodate) self.assertTrue(merge_result.is_fastforward) # Asking twice to assure the reference counting is correct - self.assertEqual(branch_head_hex, merge_result.fastforward_oid.hex) - self.assertEqual(branch_head_hex, merge_result.fastforward_oid.hex) + self.assertEqual(branch_head_hex, merge_result.fastforward_id.hex) + self.assertEqual(branch_head_hex, merge_result.fastforward_id.hex) self.assertEqual({}, self.repo.status()) def test_merge_no_fastforward_no_conflicts(self): @@ -335,8 +335,8 @@ class RepositoryTest_III(utils.RepoTestCaseForMerging): self.assertFalse(merge_result.is_uptodate) self.assertFalse(merge_result.is_fastforward) # Asking twice to assure the reference counting is correct - self.assertEqual(None, merge_result.fastforward_oid) - self.assertEqual(None, merge_result.fastforward_oid) + self.assertEqual(None, merge_result.fastforward_id) + self.assertEqual(None, merge_result.fastforward_id) self.assertEqual({'bye.txt': 1}, self.repo.status()) self.assertEqual({'bye.txt': 1}, self.repo.status()) # Checking the index works as expected @@ -351,8 +351,8 @@ class RepositoryTest_III(utils.RepoTestCaseForMerging): self.assertFalse(merge_result.is_uptodate) self.assertFalse(merge_result.is_fastforward) # Asking twice to assure the reference counting is correct - self.assertEqual(None, merge_result.fastforward_oid) - self.assertEqual(None, merge_result.fastforward_oid) + self.assertEqual(None, merge_result.fastforward_id) + self.assertEqual(None, merge_result.fastforward_id) self.assertEqual({'.gitignore': 132}, self.repo.status()) self.assertEqual({'.gitignore': 132}, self.repo.status()) # Checking the index works as expected