libgit2 / libgit2/rugged

Update Commit example documentation to mention index.write after committing

Open
#441 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

docs
Dominant language
C
Stars
2.3k
Forks
293
PR merge metrics
No merged PRs in 30d

Description

The documentation mentions, in one place, at least, how to commit a newly written index (using index.write_tree(repo)), but fails to mention that index.write should be called after the commit has been performed. This is a bit unintuitive to me, so it'd be nice if the API could be improved, but barring that, at least add that one line to the documentation (index.write).


This issue seems somewhat common -- it's come up at least twice: on GitHub as well as on StackOverflow. On the SO question, Carlos does say That example does not emulate the git-commit command, it just creates a new commit., but since some people (at least me and two others) expect it to work this way, it seems like it'd be worth calling out, at least.

Contributor guide

No contributing guide indexed for this repository

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.

Research direction

Open the linked “Writing to a repository” documentation section and read the existing commit example. Update that example to mention index.write after the commit, while preserving the existing index.write_tree(repo) guidance. Done means the documented sequence clearly explains how to persist the updated index.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.