2

i get all commits of a repo with:

curl  -I -k -u ${api_user}:${api_token} "${api_url}/commits?sha=${api_branch}&per_page=1" | sed -n '/^[Ll]ink:/ s/.*"next".*page=\([0-9]*\).*"last".*/\1/p'

Is there a similar way for git rev-list with the GitHub Rest API and curl?

Thanks in advance!

  • I'm a bit confused: are you looking for a `git rev-list` command that does what your `curl` does, or are you looking for a `curl` operation that does what `git rev-list` does? – torek Aug 24 '21 at 07:43

1 Answers1

1

The GitHub API v3 Commits API is the closest:

GET /repos/{owner}/{repo}/commits

It could be the very same you are using, depending on what ${api_url}.
Like git rev-list, it includes a commit reference from which the list starts.
And a path, to only list commits modifying the given <paths>.

It would not, howver, allow more complex commit specification, like git rev-list foo bar ^baz, which lists all the commits which are reachable from foo or bar, but not from baz.

For that, you would need a GraphQL query, using Commit object, like in [those] examples.6

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • okay, maybe i can get all commits with curl and extracting the commits who have 2+ parents? – Roman Bürkle Aug 24 '21 at 16:46
  • @RomanBürkle Yes: any commit reachable from the starting point will be listed, including commits with two+ parents. – VonC Aug 24 '21 at 18:29