Skip to content

Draft: Add an option to select commits from refs/tags and refs/heads only

Vasilii Iakliushin requested to merge 422152_extend_find_commits_request into master

Contributes to gitlab#422152

Add an option to exclude commits from special references "refs/merge-requests", "refs/keep-around" and so on.

Problem

Commits API has an option "All" that returns commits from all branches and tags.

http://127.0.0.1:3000/api/v4/projects/84/repository/commits?all=true

On Gitaly side we call:

git log --all

However, it also returns commits from special references like refs/merge-requests/1/heads. These references include "deleted" commits and that leads to confusion. Users see additional commits that they cannot find in their branches or tags.

Proposal

Add an option to exclude commits from special references and only return commits from refs/tags/* and refs/heads/*.

I discovered several ways how to achieve that:

  1. Use a combination of branches and tags flags
git log --branches --tags
  1. Exclude special references from --all response
git log --exclude="refs/merge-requests/*" --exclude="refs/keep-around/*" --all
  1. Use glob flag to select only branches and tags.
git log --glob="refs/heads/*" --glob="refs/tags/*"
  1. Something else? 🤔

I don't have a strong preference which one to use and I'm open to suggestions.

Edited by Vasilii Iakliushin

Merge request reports