Skip to content
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

feat: allow signing rebased commits #3243

Conversation

Pranav2612000
Copy link
Contributor

Not sure if this is the best way to do it. Especially, setting rebase_options.inmemory(false); to false.
If not, I'll try to make it work by adding git_commit_create_cb support to git2

Fixes #3147

cc: @schacon @krlvi

@schacon
Copy link
Member

schacon commented Mar 20, 2024

I don't believe that this will work. If rebase is not in in_memory mode, it will try messing with the HEAD and working directory, which is going to put the project in a weird state most likely.

I think what's probably much simpler would be to do exactly what we're doing, but at the end, if the rebase is successful, simply rewrite all the rebased commits, reuse the trees and manually write the commits with the signature.

So, basically, here:

branch.head = last_rebase_head;

If there is a signing key, instead of just saving the rebased head here, we should calculate the list of commits from the base (merge_base) to that head (last_rebase_head), then walk through them starting from the first child of the base and for each one, rerun project_repository.commit() with the user, message and tree from that commit, and the parent that was written last. (does that make sense?)

@Byron Byron added the feedback requested Feedback was requested to help resolve the issue label Apr 25, 2024
@Byron
Copy link
Collaborator

Byron commented Apr 25, 2024

Thanks for contributing!

Since the PR was created, a lot has changed which puts it into a conflicting stage unfortunately. Also I hope you will find time to try out the suggestions.

If that's not the case, please feel free to close it and resubmit when that changes.

Thank you.

@schacon
Copy link
Member

schacon commented May 15, 2024

Hey @Pranav2612000, I just refactored how commits are done in general in a way that should sign everything properly now. The change is in #3721. I'll close this, since it's out of date and based on code that has been pretty massively changed and now should address this.

@schacon schacon closed this May 15, 2024
@Byron Byron removed the feedback requested Feedback was requested to help resolve the issue label May 16, 2024
@Pranav2612000
Copy link
Contributor Author

Sure. Thank you @schacon
Sorry for not replying earlier.

I think the cleanest way to do this would be to use the git_commit_create_cb method of libgit2. Since git2rs does not yet have support for it, I've opened up a PR [ https://github.com/rust-lang/git2-rs/pull/1047 ] to add this support and was waiting for this to be merged.

I'll open up this conversation again once the method is available in libgit2 and we can then decided if we want to use it or not. Does that work?

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.

rebased commits are not re-signed
3 participants