test_helpers: fix unepextected closing of file on error
Merge pull request #602 from arrbee/more-error-handling

More error handling conversions
Reimplment git_status_foreach using git diff

This is an initial reimplementation of status using diff a la
the way that core git does it.
Adding new tests for new status command

This is a work in progress.  This adds two new sets of tests,
the issue_592 tests from @nulltoken's pull request #601 and
some new tests for submodules.  The submodule tests still have
issues where the status is not reported correctly.  That needs
to be fixed before merge.
New status fixes

This adds support for roughly-right tracking of submodules
(although it does not recurse into submodules to detect
internal modifications a la core git), and it adds support
for including unmodified files in diff iteration if requested.
More status testing

This "fixes" the broken t18 status tests to accurately reflect
the new behavior for "created" untracked subdirectories.  See
discussion in the PR for more details.

This also contains the submodules unit test that I forgot to
git add, and ports most of the t18-status.c tests to clar (still
missing a couple of the git_status_file() single file tests).
Migrate remaining status tests to Clar

This finishes up the migration of remaining tests from
tests/t18-status.c over the tests-clar/status/worktree.c.
Merge pull request #607 from nulltoken/fix/file-close-on-error

test helpers: Fix file close on error
Fix crash in new status and add recurse option

This fixes the bug that @nulltoken found (thank you!) where
if there were untracked directories alphabetically after the
last tracked item, the diff implementation would deref a NULL
pointer.

The fix involved the code which decides if it is necessary
to recurse into a directory in the working dir, so it was
easy to add a new option `GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS`
to control if the contents of untracked directories should be
included in status.
Restore default status recursion behavior

This gives `git_status_foreach()` back its old behavior of
emulating the "--untracked=all" behavior of git.  You can
get any of the various --untracked options by passing flags
to `git_status_foreach_ext()` but the basic version will
keep the behavior it has always had.
Fix error in tree iterator when popping up trees

There was an error in the tree iterator where it would
delete two tree levels instead of just one when popping
up a tree level.  Unfortunately the test data for the
tree iterator did not have any deep trees with subtrees
in the middle of the tree items, so this problem went
unnoticed.  This contains the 1-line fix plus new test
data and tests that reveal the issue.
Eliminate hairy COITERATE macro

I decided that the COITERATE macro was, in the end causing
more confusion that it would save and decided just to write
out the loops that I needed for parallel diff list iteration.
It is not that much code and this just feels less obfuscated.
Fix handling of submodules in trees
Added submodule API and use in status

When processing status for a newly checked out repo, it is
possible that there will be submodules that have not yet been
initialized.  The only way to distinguish these from untracked
directories is to have some knowledge of submodules.  This
commit adds a new submodule API which, given a name or path,
can determine if it appears to be a submodule and can give
information about the submodule.
Improve config handling for diff,submodules,attrs

This adds support for a bunch of core.* settings that affect
diff and status, plus fixes up some incorrect implementations
of those settings from before.  Also, this cleans up the
handling of config settings in the new submodules code and
in the old attrs/ignore code.
Fix bug when join_n refers to original buffer

There was a bug in git_buf_join_n when the contents of the
original buffer were joined into itself and the realloc
moved the pointer to the original buffer.
Merge pull request #610 from arrbee/status-rewrite

Rewrite status using diff
error-handling: remote, transport
error-handling: protocol, pkt
error-handling: git transport