Skip to content

No graph shown for small -n values #119

Open

Description

@mlange-42

With the changes introduced in #101, no graph is shown when running with small -n values

How to reproduce:

  • Go to any folder containing a git repository with several commits
  • Run git-graph -n 5

Activity

  1. peso commented on Sep 22, 2025

    @peso
    Collaborator

    The bug is due to the implementation of -n. GitGraph::new counts off the desired number of commits before the final filtering of unused commits. This means that the displayed number of commits often is lower than the requested number.

    To get an accurate number, while saving effort and doing the unused filtering, the code should add commits until the limit is reached. This is similar to the behavior of an incremental load of commits.

  2. mlange-42 commented on Sep 23, 2025

    @mlange-42
    CollaboratorAuthor

    The bug is due to the implementation of -n. GitGraph::new counts off the desired number of commits before the final filtering of unused commits. This means that the displayed number of commits often is lower than the requested number.

    To get an accurate number, while saving effort and doing the unused filtering, the code should add commits until the limit is reached. This is similar to the behavior of an incremental load of commits.

    Are you sure? The PR that introduced the bug only changes main.rs.

  3. peso commented on Sep 23, 2025

    @peso
    Collaborator

    The bug related to -n depends on the repository. I do not yet have a script that can reproduce it.

    Regarding commit d018124 "Add scroll up (#101)"

    At this commit I get no output from git-graph -n 5, nor from git-graph, but git-graph --no-pager -n 5 worked as expected. I think there may be a second bug, related to the pager. I have not investigated that bug.

  4. Universal-Invariant commented on Oct 9, 2025

    @Universal-Invariant

    Same issue here. Likely the pager doesn't print anything if the # of commits is not large enough since it doesn't fill a page? Hence for small repos with few commits they are not shown unless the paper is turned off. Like a simple fix to this would be to detect the number of commits and if it is below the paging threshold then simply execute the no-pager branch.

    Alternatively, just print whatever buffer it is accumulating rather than ignoring it.

  5. added this to the 1.0 milestone on Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions