Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I create a history graph
    text
    copied!<p>I am trying to get enough information to create a history graph using libgit2 but am unsure how I get things like branch names for commits as appropriate.</p> <p>I want to reproduce something like that which is produced with the following git command:</p> <pre><code>git log --oneline --graph --decorate --all </code></pre> <p>This is the code I am using:</p> <pre><code>git_commit* old_head = NULL; error = git_revparse_single( (git_object**) &amp;old_head, open_repo, "refs/heads/master" ); if( error != 0 ) { return SG_PLUGIN_OK; } const git_oid *head_oid = git_object_id( (git_object*)old_head ); git_revwalk *walk; git_revwalk_new( &amp;walk, open_repo ); git_revwalk_sorting( walk, GIT_SORT_TOPOLOGICAL | GIT_SORT_TIME ); git_revwalk_push( walk, head_oid ); const git_signature *cauth; const char *cmsg; git_time_t ctime; git_oid newoid; while( ( git_revwalk_next( &amp;newoid, walk ) ) == 0 ) { git_commit *wcommit; error = git_commit_lookup( &amp;wcommit, open_repo, &amp;newoid ); if( error != 0 ) { return SG_PLUGIN_OK; } ctime = git_commit_time( wcommit ); cmsg = git_commit_message( wcommit ); cauth = git_commit_author( wcommit ); TRACE("\t%s (%s at %d)\n", cmsg, cauth-&gt;email, ctime ); git_commit_free( wcommit ); } git_revwalk_free( walk ); </code></pre> <p>I can traverse the commits but i have several issues with the code above:</p> <ul> <li>i just get commits of the main master branch, if i iterate the code changing the revparse_single for each branch name then I get all commits but some are obviously duplicated where the commit is under more than one branch</li> <li>I just get commit msg, author and time, so how do i find out what the branch names are?</li> <li>Am I doing it right?</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload