Skip to content

Conversation

djc
Copy link

@djc djc commented Oct 15, 2025

Trying to make a little progress on #2152 (and this copied crate stuff seems extremely ugly anyway).

Why does cargo check pass while cargo check -p gix break? Something to do with feature unification? This means I'm not getting feedback from VS Code on errors, which makes it much harder to get stuff done.

@djc djc force-pushed the dedup-packetline branch from 480fa19 to ea41222 Compare October 15, 2025 10:52
@Byron Byron marked this pull request as draft October 15, 2025 12:09
@Byron
Copy link
Member

Byron commented Oct 15, 2025

Thanks for giving it a shot, it's much appreciated!

Feature-unification is the reason for requiring a differently named copy. It's very ugly, but there was no other way.
It all goes down to wanting to be able to 'switch' async on or off with minimal code duplication and shared tests. This is how one atrocity led to another.
Like mentioned before, I'd live better without async entirely (in this codebase).

@djc
Copy link
Author

djc commented Oct 15, 2025

Feature-unification is the reason for requiring a differently named copy. It's very ugly, but there was no other way.
It all goes down to wanting to be able to 'switch' async on or off with minimal code duplication and shared tests. This is how one atrocity led to another.

Do you have reason to think the approach in this PR would not work? It seems like an existence proof contradicting that "there was no other way" (and I don't think it introduces substantial code duplication, although the tests might be a bit harder).

@Byron
Copy link
Member

Byron commented Oct 15, 2025

Apologies, I didn't even look at the code yet and wanted to wait until you think it's ready for review.
My statement was about how this came to be, it's not the wish to torture users, but to solve a specific problem that led down this path.
Sometimes other solutions aren't seen in time leading to suboptimal results, and I genuinely hope that this PR can show the way.

@djc
Copy link
Author

djc commented Oct 15, 2025

Apologies, I didn't even look at the code yet and wanted to wait until you think it's ready for review.

It obviously doesn't pass CI yet, but I'd like some early feedback before I try to tackle the remaining issues. I think the idea is conceptually simple: the gix-packetline crate offers both async and sync APIs, separately (both are toggled by a Cargo feature flag), and consumers explicitly use the API for the mode they want to use. I don't think there's substantially more library-level code duplication. For now, this leaves mutually exclusive features in higher-level crates alone, at some point the I/O mode will bubble up to the top-level API and then we have to decide how to best present that.

Copy link
Member

@Byron Byron left a comment

Choose a reason for hiding this comment

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

I think I understand now what this PR is going for and have a feeling that it could work. Maybe gix-packetline never needed have offer one unified codepath that can be 'toggled' async due to its primitive nature.

Now that I think about it, maybe the tests for gix-packetline then will be more duplicated, but that should be alright as they are stable.

And yes, I agree that from here more opportunities for similar updates may show up.

@djc djc force-pushed the dedup-packetline branch 3 times, most recently from c791c05 to 9c3977c Compare October 18, 2025 21:12
@djc djc marked this pull request as ready for review October 18, 2025 21:14
@djc djc force-pushed the dedup-packetline branch from 9c3977c to 6cfaf8d Compare October 18, 2025 21:17
@djc
Copy link
Author

djc commented Oct 18, 2025

This feels like it's pretty close. Somehow some builds in the full tests end up enabling both async-client and blocking-client on gix-transport which are supposed to be mutually exclusive on this branch as before -- I'm not sure what's triggering that? It doesn't feel like any of the changes I made should be capable of that, they're all supposed to be upstream of gix-transport.

djc-2021 dedup-packetline gitoxide $ cargo check --features lean-async
    Checking gix-packetline v0.19.1 (/Users/djc/src/gitoxide/gix-packetline)
    Checking gix-filter v0.20.0 (/Users/djc/src/gitoxide/gix-filter)
    Checking gix-transport v0.48.0 (/Users/djc/src/gitoxide/gix-transport)
error: Cannot set both 'blocking-client' and 'async-client' features as they are mutually exclusive
  --> gix-transport/src/lib.rs:92:1
   |
92 | compile_error!("Cannot set both 'blocking-client' and 'async-client' features as they are mutually exclusive");
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@djc djc force-pushed the dedup-packetline branch 4 times, most recently from f9607bf to 4ea089f Compare October 19, 2025 07:42
@djc
Copy link
Author

djc commented Oct 19, 2025

This feels like it's pretty close. Somehow some builds in the full tests end up enabling both async-client and blocking-client on gix-transport which are supposed to be mutually exclusive on this branch as before -- I'm not sure what's triggering that? It doesn't feel like any of the changes I made should be capable of that, they're all supposed to be upstream of gix-transport.

djc-2021 dedup-packetline gitoxide $ cargo check --features lean-async
    Checking gix-packetline v0.19.1 (/Users/djc/src/gitoxide/gix-packetline)
    Checking gix-filter v0.20.0 (/Users/djc/src/gitoxide/gix-filter)
    Checking gix-transport v0.48.0 (/Users/djc/src/gitoxide/gix-transport)
error: Cannot set both 'blocking-client' and 'async-client' features as they are mutually exclusive
  --> gix-transport/src/lib.rs:92:1
   |
92 | compile_error!("Cannot set both 'blocking-client' and 'async-client' features as they are mutually exclusive");
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Ahh, I think I just didn't understand the justfile ! prefix syntax. I think this next run might pass CI. Honestly not sure why it's useful to have CI check that certain configurations don't compile.

@djc
Copy link
Author

djc commented Oct 19, 2025

I've tacked on a second commit (which can be reviewed independently) to clean up the gix-packetline API in a way that seems quite a bit nicer to me.

Copy link
Member

@Byron Byron left a comment

Choose a reason for hiding this comment

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

Great news! I see that this PR can be merged, I just need some more time with it, and didn't yet have time for my refactoring round.

Generally, I'd wish API improvements would be in a separate commit.
TCC

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 this should be read/mod.rs.

Copy link
Author

Choose a reason for hiding this comment

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

Why? There are no nested modules, right? Putting it in a directory without a need for further nesting seems pretty unidiomatic.

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 true. To me it looked like there is read on the top-level, or does it not?

Screenshot 2025-10-22 at 08 39 04

Choose a reason for hiding this comment

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

Image

The view is a bit confusing, it shows a read directory because it was there previously and has now been deleted.

Copy link
Member

Choose a reason for hiding this comment

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

This can be write.rs.

Copy link
Author

Choose a reason for hiding this comment

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

It's not clear what this is referring to.

Comment on lines +27 to +28
#[cfg(feature = "blocking-io")]
pub mod blocking_io {
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 cool, I don't think I have ever seen this kind of style before. I will take some time to wrap my head around it :).

@djc
Copy link
Author

djc commented Oct 22, 2025

and didn't yet have time for my refactoring round.

What do you mean by this?

@Byron
Copy link
Member

Byron commented Oct 22, 2025

This means I have only done a partial armchair review without actually opening the code in an editor. When I do, I usually just make the changes I need and merge. That saves a lot of time as I don't have to go back and forth.

@djc djc force-pushed the dedup-packetline branch from d66725c to ad90ced Compare October 22, 2025 12:00
@djc
Copy link
Author

djc commented Oct 22, 2025

Rebased onto current main.

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.

4 participants