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

preserve commit signatures #958

Merged
merged 4 commits into from
Oct 3, 2022
Merged

Conversation

RalfJung
Copy link
Contributor

@RalfJung RalfJung commented Oct 1, 2022

Note that I don't really know what I am doing here. ;) This seems like a massive breaking change to me -- if someone's git history contains these signatures, now the commits exposed via josh will be all different. Is that a problem? What is the usual way to deal with such a problem? Should there be a flag? Were signatures actually dropped deliberately? So many questions.^^

The first commit is just me learning to write these tests, but I couldn't find an existing test specifically for the prefix filter so I figured I might submit it as well. If you prefer I can remove it.

Fixes #957

mostly for me to learn how to write these tests
@RalfJung
Copy link
Contributor Author

RalfJung commented Oct 2, 2022

For instance, the docs for importing say

4. Any external users can now use the `:/tools/project-b` josh filter
   to retrieve changes made in the new project location - without the
   git hashes of their existing commits changing (that is to say,
   without conflicting).

but currently this is only true if the original project did not contain any signed commits.

@@ -196,6 +196,18 @@ pub fn rewrite_commit(
parents,
)?;

if let Ok((sig, _)) = repo.extract_signature(&base.id(), None) {
// Re-create the object with the original signature (which of course does not match any
// more, but this is needed to guarantee perfect round-trips).
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FWIW there is a comment a few lines up that needs updating now -- or we could entirely remove that equality check.

Copy link
Member

Choose a reason for hiding this comment

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

I think that equality check can be removed. It's value as an optimization is super low as it is an quite rare case.

@@ -196,6 +196,18 @@ pub fn rewrite_commit(
parents,
)?;

if let Ok((sig, _)) = repo.extract_signature(&base.id(), None) {
Copy link
Contributor Author

@RalfJung RalfJung Oct 2, 2022

Choose a reason for hiding this comment

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

None here and in the commit_signed below refers to the name of the signature field. Looks like that can be customized. Roundtrips will still not work if there are commits that use a non-standard name for that field. I don't know how to get git to tell us tabout non-standard fields... really ideally we'd have an API to list all header fields, and preserve them all while only adjusting the tree, but I am not sure if that is possible.

Copy link
Member

Choose a reason for hiding this comment

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

That's quite interesting: We could maybe at some point even use that for out own metadata. Good to know.

About getting all extra header fields: Worst case we have to parse the commit buffer ourselves. But I think this is good enough for now.

One little thing: The constant CACHE_VERSION in src/cache.rs should be incremented whenever we make a change that can affect the output sha's of any filter. This is to avoid strange effects that could happen when somebody uses a cache that was computed using the old version and things could get mixed up.

@christian-schilling christian-schilling enabled auto-merge (squash) October 3, 2022 13:27
@RalfJung
Copy link
Contributor Author

RalfJung commented Oct 3, 2022

Oh, that makes a ton of tests fail that have the version number somewhere in their output...

auto-merge was automatically disabled October 3, 2022 13:40

Head branch was pushed to by a user without write access

@christian-schilling christian-schilling enabled auto-merge (squash) October 3, 2022 14:59
@christian-schilling christian-schilling merged commit 1936ec8 into josh-project:master Oct 3, 2022
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.

Imperfect round-trip of Miri repo due to gpgsig
2 participants