libgit2/libgit2 — pull request #1662 by arrbee (2013-06-20 21:36:50+00:00)
Title: Command line status example (with bug fixes)

This adds `examples/status.c` which is maybe 80% of an emulation of `git status` using the libgit2 status APIs.

In implementing this, I found a bug where a diff between the index and the working directory will fail with a `GIT_ENOTFOUND` error if an untracked directory contains an empty directory inside it.

Also, to make it easier to display status lists, I added flags to the status code to force the output to be in either case-sensitive order or case-insensitive order - without those flags, status defaults to the case-sensitivity of the file system.

The example itself is largely a lot of printfs, but it should have to use the status APIs to traverse and access the data and the types of variations that might be found in data coming from the status APIs. It's a lot of code, but most of that comes from the formatting code to generate short and long format status output.

The diff API provides helper functions that make it easy to generate typical diff output formats (i.e. `git_diff_print_compact`, `git_diff_print_raw`, and `git_diff_print_patch`). Right now, those helper functions don't exist for the status API, but we could add them if desired. Since the long form status output is somewhat complicated (index changes, then workdir changes, then untracked files, then ignored files if requested), having a helper might be nice for apps that want to mirror Git output. Even a helper for the short format might be nice, at least for translating the status code into a pair of letters that compactly summarize the status info.