objective-git

How to “unstage” a file with Objective-Git (libgit2)?

倖福魔咒の 提交于 2020-01-17 03:17:25
问题 I am writing an app that allows performing basic git operations using Objective-Git, but I am having trouble figuring out how to "unstage" a file. More specifically, I have a file with changes that have previously been added to the current GTIndex and I now want to discard those changes (without losing the file's current state on disk). Here is a rough outline of the relevant logic my program currently follows when toggling the "staged" state of a file: - Fetch current GTIndex using

Un-stage file with libgit2

最后都变了- 提交于 2019-12-11 21:25:37
问题 Using objective-git and libgit2 it has been fairly easy to stage a file ready for commit: GTIndex *repoIndex = [self.repository indexWithError:&error]; [repoIndex removeFile:path error:&error]; if (status != GTFileStatusIgnored && status != GTFileStatusWorkingDeleted) { // Now add the file to the index [repoIndex addFile:path error:&error]; } [repoIndex write:&error]; However un-staging a file is proving to be a tad more tricky. Simply removing it from the repository's index doesn't work as

In libgit2, what do the git_index_entry->flags_extended mean (and when are they set)?

筅森魡賤 提交于 2019-12-11 12:36:42
问题 I am attempting to manage a repository's index vs. its HEAD tree using libgit2 (via Objective-Git, but I'm increasingly finding myself heading down the vanilla libgit2 rabbit hole), and am wondering what exactly the flags_extended field's bitmasks on git_index_entry struct actually mean. Additionally, when are these flags set? I've been digging through the libgit2 source, but cannot seem to find where flags_extended comes into play. The reason I ask: I have a simple test repository with one