DirCache: Buffer TREE extension to $GIT_DIR

Increase the in-memory buffer for the TREE extension to 5 MiB, and
overflow to $GIT_DIR instead of /tmp.  Using a larger buffer reduces
the chances a repository will overflow and need to spool the extension
to disk.  Using $GIT_DIR allows the TREE extension contents to have
the same file system protections as the final $GIT_DIR/index.

Wrap the entire thing in a try/finally to ensure the temp file is
deleted from disk after the block has finished using it. To avoid
dangling NFS files, LocalFile.destroy() does close the local file
before deleting it.

Change-Id: I8f871181a4689e3ebf0cdd4fd1769333cf7546c3
AmazonS3: Buffer pushed pack content under $GIT_DIR

This applies the same filesystem permissions as the source objects.
Users may override in properties files using the tmpdir value.

Change-Id: I3ec332cf41f12eae246cfaee9fd792c52cb2908b
Switch FileHeader.extractFileLines to TemporaryBuffer.Heap

File contents are processed into a single byte[] for character
conversion. The data must fit entirely in memory, so avoid any
file IO.

Change-Id: I3fe8be2e5f37d5ae953596dda1ed3fe6d4f6aebc
Deprecate TemporaryBuffer.LocalFile without parent directory

Encourage callers to explicitly name a directory to hold any
overflow data. Call sites have more information about what is
going into the buffer and how it should be protected at the
filesystem level than just throwing content to the system wide
temporary directory.

Callers that still really don't care (or need to care) can pass
null for the File argument to have the system directory used.

Change-Id: I89009bbee49d3850d42cd82c2c462e51043acda0
Detect buffering failures while writing rebase todo file

By routing writes through SafeBufferedOutputStream the caller can be
alerted to any flush at close failures while writing or appending to
the rebase todo script.

Switch the character encoding to be done at the line granularity, as
this is sufficiently long enough that encoding overheads will not be a
bottleneck, but short enough that the amount of temporary data will
not cause memory problems for the JVM.

Change-Id: Ice5ec10a7cbadc58486d481b92940056f9ffc43a
Fix two nits about DirCacheEntry constructors

Explicitly pass STAGE_0 when creating a DirCacheEntry from String.
This matches the immediate next constructor that accepts the int
stage argument better, making the code easier to read.

Fix a weird line break where the comma was orphaned by itself.

Change-Id: Icf0970dd02a63877f9e41b51b982b0265e8b8887
Apache HttpClientConnection: replace calls to deprecated LocalFile()

Change-Id: I79f422e004f386b3f2875de6997e5a0949fff566
Merge changes Icf0970dd,Ice5ec10a into stable-3.4

* changes:
  Fix two nits about DirCacheEntry constructors
  Detect buffering failures while writing rebase todo file
Make sure modifications to config-param trustFolderStat are detected

ObjectDirectory.searchPacksAgain() should always read trustFolderStat
from the config and not rely on a cached value.

Change-Id: I90edbaae3c64eea0c9894d05acde4267991575ee
Implement FileSnapshot.toString() to help debugging

Change-Id: Ic18d051327e491d5834929ff7fa28381f0f972c4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Do not use deprecated tasks in maven-antrun-plugin.

Maven-antrun-plugin deprecated tasks in favor of target, this patch
fixes JGit poms to do the same.

Change-Id: I420fd2ce88c61cf8e786ed45fbb8235dc30c124e
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Build with Tycho 0.22.

Change-Id: I32444e926179827be31d9201a6bbc5d514672110
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Extract path info from requests without decoding

Gitiles malfunctions in conjunction with jgit and guice
because of a recent Guice bug fix. Work around the problem
by parsing the URI directly, bypassing the unescaping
performed by the getPathInfo method.

This rest of this message is copied from
https://gerrit-review.googlesource.com/#/c/60820/ :

The fix for Guice issue #745[1] causes getPathInfo() within the
GuiceFilter to return decoded values, eliminating the difference
between "foo/bar" and "foo%2Fbar". This is in spec with the servlet
standard, whose javadoc for getPathInfo[2] states that the return
value be "decoded by the web container".

Work around this by extracting the path part directly from the request
URI, which is unmodified by the container. This is copying the Guice
behavior prior to the bugfix.

[1] https://github.com/google/guice/issues/745
[2] http://docs.oracle.com/javaee/7/api/javax/servlet/http/HttpServletRequest.html#getPathInfo()

Change-Id: I7fdb291bda377dab6160599ee537962d5f60f1e8
Signed-off-by: David Pletcher <dpletcher@google.com>
CheckoutCommand: Fix checking out ours/theirs when no base stage exists

In case of an add/add conflict, no base stage exists. The previous
implementation would skip over the entries because the condition
expected the base stage to always exist.

Change-Id: Ie2b3685d958c09b241991b74e6177401e8a1ebc9
Signed-off-by: Robin Stocker <robin@nibor.org>
Merge "Extract path info from requests without decoding"
AWTPlotRenderer: use float arithmetic instead of double followed by a conversion

Multiplying by 0.9 and converting back to float is slightly more
complicated and achieves the same effect as multiplying by the float
0.9f directly.

Change-Id: I555863bb1251badee8887b9b93c5463eda0a3509
Signed-off-by: Jonathan Nieder <jrn@google.com>
Fix DirCacheCheckout to set correct file length if core.autocrlf=true

To update the file length stat we need to use the length of the
temporary file since it's not yet renamed to the target file name here.
The incorrect file length stat update was introduced in
a606dc363d0f6b09e4527cca6b645d3cb1ec407d.

Bug: 453962
Change-Id: I715c048227553efae6f8f6b6878c0f04f2609d9c
Also-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
Also-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Merge "CheckoutCommand: Fix checking out ours/theirs when no base stage exists" into stable-3.6
Merge "Fix DirCacheCheckout to set correct file length if core.autocrlf=true" into stable-3.6
Prevent NPE if ref can't be resolved when executing ReflogCommand

If the specified ref can't be resolved we should throw a
RefNotFoundException instead of an NPE.

Bug: 455005
Change-Id: I6ec9bf1c0f330eea5eb8277268f62663bdf58f66
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>