CommitFilter / CommitSortStrategies Understanding

Open
#1,145 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
25/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Stale
Tech stack
csharp, git
Domain
devtools

Research direction

Start with the CommitFilter, CommitSortStrategies, and QueryBy entry points referenced in the issue, then compare their behavior with the listed git command examples. Document whether each proposed equivalence is correct and specify the ordering semantics of CommitSortStrategies.None; completion means the questions have an authoritative explanation.

Written by the indexing model from the issue text.

Description

I am trying to understand what "CommitSortStrategies" is actually doing to the commit collections that I am getting back and am just looking for clarification if this is correct.

Git, by default (cmd line app), are shown in reverse chronological order, so:

  • git (default sort) == CommitFilter/SortBy of (Undefined)
  • git --reverse != CommitFilter/SortBy of Reverse
  • git --reverse == CommitFilter/SortBy of Reverse | Time
  • git --topo-order == CommitFilter/SortBy of Topological
  • git --reverse --topo-order == CommitFilter/SortBy of Reverse | Topological
  • git --______ ?= CommitFilter/SortBy of None
  • CommitFilter/SortBy of None != CommitFilter/SortBy of (Undefined)

Is that list correct/complete?

(FYI: I have a multi-million object repo with millions of refs and have reverted to shelling to git to get the commit lists between cross-merge branches as I can not get a direct match between libgit2's ls-trees and gits, my head hurts....)

BTW: What order does CommitSortStrategies.None follow? Based on ref creation order on the file-system, maybe?

A sample for a future reader:
# Note: Piping to head as you can not use -n <number>, --max-count=<number> as that is applied before commit ordering
git log HEAD..master --format="%ci %h %s" --reverse | head -10

So based upon the equivalence list above, in libgit2sharp this becomes:

var filter = new CommitFilter {
    SortBy = CommitSortStrategies.Reverse | CommitSortStrategies.Time,
    Since = master,  // determined by a prior repo.Lookup<Tree>
    Until = head, // determined by a prior repo.Lookup<Tree>                    
};
repo.Commits.QueryBy(filter).Take(10);
Dominant language
C#
Stars
3.5k
Forks
925
PR merge metrics
No merged PRs in 30d

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.

More from libgit2/libgit2sharp

All issues in libgit2/libgit2sharp

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.