libgit2 / libgit2/pygit2

Repository.create_reference only accepts str and not bytes

Open
#966 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.7k
Forks
408
Avg merge
2d 57m
Merged PRs (30d)
7

Description

Repository.create_reference only accepts str and not bytes. This is because Repository_create_reference_direct in repository.c uses the s specifier for parsing that argument, which only accepts str and implicitly encodes it using UTF-8. I would expect it to accept str or bytes, and if you pass bytes, it uses exactly what you pass in with no encoding/decoding.

This is a similar problem to #932.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in repository.c at Repository_create_reference_direct and inspect how the reference argument is parsed. Check the existing Repository.create_reference behavior and related issue #932 for expected handling, then verify that str remains UTF-8 encoded while bytes are passed through unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, git, python
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
Half a day
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.