You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In pygit2, none of the create_reference_... methods support the message parameter, so currently the only way to set a reference with a message is via the Reference.set_target() method. However, set_target will not update the reflog if the ref is already pointing to the specified target. This means that there is no way to create a new reference with a reflog message.
In a new git repo containing 2 commits (fab58a5, 48f4093):
$ pip freeze
cached-property==1.5.2
cffi==1.14.4
pycparser==2.20
pygit2==1.4.0
$ python
Python 3.8.2 (default, Nov 4 2020, 21:23:28)
[Clang 12.0.0 (clang-1200.0.32.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygit2
>>> repo = pygit2.repository(".")
>>> ref = repo.references.create("refs/foo/bar", "fab58a555d62a1fbbbd9c8be8159057ade88715d")
>>> [entry.message for entry in ref.log()]
[]
>>> ref.set_target("fab58a555d62a1fbbbd9c8be8159057ade88715d", message="cannot set message for unchanged ref")
>>> [entry.message for entry in ref.log()]
[]
>>> ref.set_target("48f4093a41f255ed8329eb05d7119902c842edea", message="can set message for changed ref")
>>> [entry.message for entry in ref.log()]
['can set message for changed ref']
To workaround this, if I want to create a ref with an initial reflog message, I would need to create the ref so that it points to any commit in my repo besides the intended ref target, and then call set_target() with a reflog message to point it to the correct target afterwards.
libgit2 does support specifying an initial reflog message on ref creation, so ideally pygit2's create_reference(), create_reference_direct(), and create_reference_symbolic() just need to be updated to accept a message parameter.
The text was updated successfully, but these errors were encountered:
In pygit2, none of the
create_reference_...
methods support themessage
parameter, so currently the only way to set a reference with a message is via theReference.set_target()
method. However,set_target
will not update the reflog if the ref is already pointing to the specified target. This means that there is no way to create a new reference with a reflog message.In a new git repo containing 2 commits (
fab58a5
,48f4093
):To workaround this, if I want to create a ref with an initial reflog message, I would need to create the ref so that it points to any commit in my repo besides the intended ref target, and then call
set_target()
with a reflog message to point it to the correct target afterwards.libgit2 does support specifying an initial reflog message on ref creation, so ideally pygit2's
create_reference()
,create_reference_direct()
, andcreate_reference_symbolic()
just need to be updated to accept a message parameter.The text was updated successfully, but these errors were encountered: