Enable streaming large files put to an edit

If the browser/user-agent sends a Content-Length header in the
request, JGit can stream the payload into the compressed object
format without holding the entire payload inside the server's
heap. This can reduce memory pressure when the user edits a
large XML file.

Push the RawInput down into the ChangeEditModifier, giving it access
to the expected length. If the length is defined (>= 0), JGit can
stream the payload from the input.  If the user agent failed to
supply a length, the payload must be buffered to compute it.

Cleanup the ChangeEditModifier management of the tree by doing blob
insertion before the tree is updated. This allows passing in only
the ObjectId, which is cleaner for the Git style code.

When restoring an entry with RESTORE_ENTRY, reset the file mode to
the original mode. This preserves the execute bit or symlink mode,
instead of resetting them to regular file.

When editing an entry, try to keep the existing mode instead of
forcing to a regular file. This allows editing an executable script
file and keeping the file executable.

Change-Id: I8f45fd4a4a45cef266d994c2457d3e100231c312
3 files changed