Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 24, 2025

Fixes #2190

Problem

gix credential fill incorrectly required the url field to be present, even when both protocol and host fields were provided. This differs from Git's behavior and breaks compatibility with credential helpers that only provide individual fields.

According to the git-credential documentation:

When this special attribute is read by git credential, the value is parsed as a URL and treated as if its constituent parts were read (e.g., url=https://example.com would behave as if protocol=https and host=example.com had been provided).

This implies that url should be optional when the constituent parts (protocol and host) are available.

Before

$ echo -e "protocol=https\nhost=github.com" | gix credential fill
Error: The url wasn't provided in input - the git credentials protocol mandates this

After

$ echo -e "protocol=https\nhost=github.com" | gix credential fill
Username for https://github.com: 

Changes

  • Modified validation logic in gix-credentials/src/program/main.rs to accept either url OR both protocol and host
  • Enhanced destructure_url_in_place method to construct URLs from individual components when url field is missing
  • Updated gitoxide-core credential handling to work with constructed URLs
  • Improved error messages to accurately describe the new validation requirements
  • Added comprehensive tests covering all scenarios including edge cases

Compatibility

  • Backward compatible: Existing url-based workflows continue to work unchanged
  • Git compatible: Now matches git credential fill behavior exactly
  • Extended support: Works with any combination of protocol, host, path, and username

All existing tests continue to pass, and 7 new test cases ensure the new functionality works correctly.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI assigned Copilot and Byron Sep 24, 2025
@Copilot Copilot AI changed the title [WIP] @GitoxideLabs/gitoxide/issues/2190 Fix gix credential fill to accept protocol+host without URL field Sep 24, 2025
@Copilot Copilot AI requested a review from Byron September 24, 2025 04:13
Copilot finished work on behalf of Byron September 24, 2025 04:13
@Byron Byron force-pushed the copilot/fix-b53588ea-1fea-485f-82a8-505a9101514e branch from 53ce8c4 to db8a26e Compare September 24, 2025 07:12
@Byron Byron marked this pull request as ready for review September 24, 2025 07:12
@Byron Byron force-pushed the copilot/fix-b53588ea-1fea-485f-82a8-505a9101514e branch from db8a26e to 2cc63ca Compare September 24, 2025 07:13
@Byron Byron enabled auto-merge September 24, 2025 07:14
@Byron Byron merged commit 033ce8e into main Sep 24, 2025
29 checks passed
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.

credential fill subcommand incorrectly assumes required field(s)

2 participants