Skip to content

Make Git::Base#ls_tree handle commit objects #643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2023
Merged

Conversation

jcouball
Copy link
Member

@jcouball jcouball commented Mar 4, 2023

Your checklist for this pull request

🚨Please review the guidelines for contributing to this repository.

  • Ensure all commits include DCO sign-off.
  • Ensure that your contributions pass unit testing.
  • Ensure that your contributions contain documentation if applicable.

Description

Fixes #475

git-ls-tree returns three types of objects: commits, blobs and trees. git ls-tree returns a commit in place of a submodule tree to indicate the commit SHA in the submodule's repository that is linked into the containing repository.

The implementation of Git::Lib#ls_tree raised an error when git ls-tree returns a commit. This PR changes the implementation so that the commit is returned in the Hash returned (from the test case):

{
  "blob" => {
    ".gitmodules" =>{ mode: "100644", sha: "caff6b7d44973f53e3e0cf31d0d695188b19aec6" },
    "README.md" => { mode: "100644", sha: "ab1bc6e140b700e97253b02e4ca117abe068a73f" }
    },
  "tree" => { },
  "commit" => {
    "submodule" => { mode: "160000", sha: "31b05441cda227c0531d659a13b7e10ce3ba8754" }
  }
}

Signed-off-by: James Couball <jcouball@yahoo.com>
@jcouball jcouball merged commit a79935e into master Mar 4, 2023
@jcouball jcouball deleted the fix_ls_tree branch March 4, 2023 22:09
@jcouball jcouball mentioned this pull request Mar 6, 2023
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.

Git::Object::Tree#check_tree throws exception on a submodule, type 'commit'
1 participant