Skip to content

Conversation

Byron
Copy link
Collaborator

@Byron Byron commented Nov 6, 2024

With the merge of #5416, which made it into the latest release somehow, there was also the introduction of a more convenient API for writing trees. This API, however, also added validation for everything that was about to be written to ensure the tree-entry names are valid and the objects they point to exist.

Unfortunately, a test for submodules was missing, whose objects never exist in the parent repository as they refer to the HEAD commit in the submodule.
This object-exists check would cause errors like The object d12a68fc4930062c0bed26447a6b5245697e77c1 (160000) at 'suite' could not be found.

As this runs as part of most merges now, this also means that no repository with submodules will work.

This PR updates gitoxide to the latest version which implements a test and fix.

It's definitely recommended to release an update soon after.

Fixes #5459 .

Tasks

  • update gitoxide to latest version on main

@vercel
Copy link

vercel bot commented Nov 6, 2024

@Byron is attempting to deploy a commit to the GitButler Team on Vercel.

A member of the Team first needs to authorize it.

This includes a fix for Tree-writing, where the validation
incorrectly tried to assure that commits/submodules existed
in the same repository.
@Byron Byron marked this pull request as ready for review November 6, 2024 08:46
Copy link
Member

@krlvi krlvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for the quick turnaround here!

@Byron
Copy link
Collaborator Author

Byron commented Nov 6, 2024

Of course, I am glad I caught it early as well.

For posterity, here is the fix:

commit 4079519e7e292ee193248e3acea6587788c6b884
Author: Sebastian Thiel <[email protected]>
Date:   Wed Nov 6 09:07:12 2024 +0100

    fix: assure submodules are skipped everywhere
    
    This also adds `Repository::head_tree()` for convenience.

diff --git a/gix/src/object/tree/editor.rs b/gix/src/object/tree/editor.rs
index d7a42fcd9..48fd57167 100644
--- a/gix/src/object/tree/editor.rs
+++ b/gix/src/object/tree/editor.rs
@@ -263,7 +263,7 @@ fn write_cursor<'repo>(cursor: &mut Cursor<'_, 'repo>) -> Result<Id<'repo>, writ
                     id: entry.oid,
                     source: err,
                 })?;
-                if !cursor.repo.has_object(entry.oid) {
+                if !entry.mode.is_commit() && !cursor.repo.has_object(entry.oid) {
                     return Err(write::Error::MissingObject {
                         filename: entry.filename.clone(),
                         kind: entry.mode.into(),

A small oversight with huge impact.

@Byron Byron merged commit ed6a6e9 into gitbutlerapp:master Nov 6, 2024
17 of 18 checks passed
@Byron Byron deleted the tree-merge branch November 6, 2024 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

applying a branch puts project into a bad state after updating to 0.13.10

2 participants