Fix examples to make the important stuff more obvious

This extracts some common utility functions and reorganizes the code in the examples to move the important stuff closer to the top of the files and leave the less important stuff (like parsing command line arguments) down towards the bottom. Sometimes the command line parsing is important because it shows how to translate command line arguments that you may already understand into libgit2 equivalents, but usually the actual use of the functions and objects is the hard part, I suspect.

* [x] Create common utility functions (`examples/common.h` and `examples/common.c`)
* [x] Update `examples/add.c`
* [x] Update `examples/cat-file.c`
* [x] Update `examples/diff.c`
* [x] ~~Update `examples/general.c`~~ (separate PR)
* [x] Update `examples/init.c`
* [x] Update `examples/log.c`
* [x] Update `examples/rev-list.c`
* [x] Update `examples/rev-parse.c`
* [x] Update `examples/showindex.c`
* [x] Update `examples/status.c`
* [x] ~~Relicense examples to make it clear that code copying is okay~~ (separate PR)