Display correct `HEAD detached` text in `git status`

Open Beginner friendly
#198 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp, git
Domain
cli

Research direction

Start from the status subcommand's branch-name output, where it prints On branch HEAD for a detached HEAD. Check whether libgit2 reports the detached state at that point, then print HEAD detached at <short sha> in red, matching the git status output quoted in the issue. Done when git2cpp status after git checkout HEAD~1 shows that line and the clean-tree message is unchanged.

Written by the indexing model from the issue text.

Description

bug

If we have a detached HEAD situation, such as after a git checkout HEAD~1, the git2cpp status result is:

$ git2cpp status
On branch HEAD
Nothing to commit, working tree clean

Using git the output is more explicit:

$ git status
HEAD detached at 79e894b
Nothing to commit, working tree clean

and the HEAD detached at is red.

Dominant language
C++
Stars
7
Forks
5
Avg merge
2d 12h
Merged PRs (30d)
10

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from QuantStack/git2cpp

All issues in QuantStack/git2cpp

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.