Skip to content

Renaming the current branch doesn't cause a message to be written to the HEAD reflog #4292

@jgrosso

Description

@jgrosso

In the case that the currently checked-out branch is renamed, Git core has logic to write to HEAD's reflog instead of only the ref-specific reflog (https://github.com/git/git/blob/e0aaa1b6532cfce93d87af9bc813fb2e7a7ce9d7/refs/files-backend.c#L2156-L2186). libgit2, however, only writes to the ref-specific reflog.

Reproduction steps

  1. Rename the currently checked-out branch via git_reference_rename (for example, check out development and rename it to develop).

Expected behavior

  • The reflog for the new name of the branch should be written to (for example, .git/logs/refs/heads/develop should contain branch: renamed...).
  • The reflog for HEAD should be written to (for example, .git/logs/HEAD should contain branch: renamed....

Actual behavior

  • The reflog for the new name of the branch is written to (for example, .git/logs/refs/heads/develop should contain branch: renamed...).
  • The reflog for HEAD is not written to (for example, .git/logs/HEAD should contain branch: renamed....

Version of libgit2 (release number or SHA1)

v0.25.1

Operating system(s) tested

macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions