Skip to content

Commit

Permalink
Make filter_commit work with tag objects (#1394)
Browse files Browse the repository at this point in the history
Change: tags-objects-fix
  • Loading branch information
LMG authored Sep 26, 2024
1 parent f95c264 commit 61643c0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
5 changes: 4 additions & 1 deletion josh-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,10 @@ pub fn filter_commit(
oid: git2::Oid,
permissions: filter::Filter,
) -> JoshResult<git2::Oid> {
let original_commit = transaction.repo().find_commit(oid)?;
let original_commit = {
let obj = transaction.repo().find_object(oid, None)?;
obj.peel_to_commit()?
};

let perms_commit = if let Some(s) = transaction.get_ref(permissions, oid) {
s
Expand Down
13 changes: 9 additions & 4 deletions tests/proxy/clone_subtree_tags.t
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
1 file changed, 1 insertion(+)
create mode 100644 sub1/file12

$ git tag -m "a tag object" a_tag_object

$ mkdir sub2
$ echo contents1 > sub2/file2
Expand All @@ -40,7 +41,7 @@
create mode 100644 sub2/file2

$ git describe --tags
a_tag-2-gbbc3f80
a_tag_object-1-gbbc3f80

$ tree
.
Expand All @@ -65,6 +66,7 @@
$ git push --tags
To http://localhost:8001/real_repo.git
* [new tag] a_tag -> a_tag
* [new tag] a_tag_object -> a_tag_object

$ cd ${TESTTMP}

Expand All @@ -84,7 +86,7 @@
* add file1

$ git describe --tags
a_tag-1-g6e99e1e
a_tag_object

$ cat file1
contents1
Expand Down Expand Up @@ -142,6 +144,8 @@
| | | |-- 282e9cdc1b972fffd08fd21eead43bc0c83cb8
| | | |-- c3f8026800792a43ffbc932153f4864509378e
| | | `-- f54cff926d013ce65a3b1cf4e8d239c43beb4b
| | |-- c1
| | | `-- 90f9e0d45065e20a13996f541c3571ed317c45
| | |-- c8
| | | `-- 2fc150c43f13cc56c0e9caeba01b58ec612022
| | |-- fa
Expand All @@ -158,7 +162,8 @@
| | |-- heads
| | | `-- master
| | `-- tags
| | `-- a_tag
| | |-- a_tag
| | `-- a_tag_object
| `-- tags
`-- overlay
|-- HEAD
Expand All @@ -178,5 +183,5 @@
|-- namespaces
`-- tags

38 directories, 26 files
39 directories, 28 files
$ cat ${TESTTMP}/josh-proxy.out | grep TAGS

0 comments on commit 61643c0

Please sign in to comment.