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

Fix garbled mirror configuration in recipe for git clone --mirror #1072

Merged
merged 1 commit into from
Apr 14, 2021

Conversation

cjolowicz
Copy link
Contributor

The documentation contains a recipe for how to emulate git clone --mirror. In
the example code, the init_remote callback constructs the mirror configuration
passing name to str.format. However, the callback receives the name (and
url) as bytes, so str.format would return something like this:

"remote.b'origin'.mirror"

This commit fixes the code example by decoding name when used with str.format.

The invocation of repo.remotes.create in the same example works fine as is,
because that function invokes to_bytes on its arguments, and to_bytes is a
noop when passed bytes.

The documentation contains a recipe for how to emulate `git clone --mirror`. In
the example code, the init_remote callback constructs the mirror configuration
passing `name` to str.format. However, the callback receives the `name` (and
`url`) as bytes, so str.format would return something like this:

    "remote.b'origin'.mirror"

This commit fixes the code example by decoding `name` when used with str.format.

The invocation of `repo.remotes.create` in the same example works fine as is,
because that function invokes `to_bytes` on its arguments, and `to_bytes` is a
noop when passed bytes.
@jdavid jdavid merged commit 7cdd043 into libgit2:master Apr 14, 2021
@cjolowicz cjolowicz deleted the docs-fix-mirror-recipe branch April 14, 2021 09:47
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.

None yet

2 participants