Commit Graph

2815 Commits

Author SHA1 Message Date
Matthias Sohn f777ed1d24 Replace deprecated release() methods by close() in NoteMapMerger
Change-Id: Iaa76f0e853bb82cd7f231fd2f462a319f4196d8c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-04 00:36:28 +02:00
Matthias Sohn f434f29fd9 Ensure that NameRevCommand.call() closes RevWalk
Change-Id: Icc35a81081759d664fe9e2b05e962ff3cd9aad92
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-04 00:32:59 +02:00
Matthias Sohn 8e332f1057 Replace deprecated release() methods by close() in Merger
Change-Id: I80ce98511a6e9048f1eea93288d6960dcbf3326f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-04 00:19:39 +02:00
Matthias Sohn ed42bad1c6 Use try-with-resource to close resources in GC
Change-Id: I62a755a4ce839a252a5e80abf3f0d21243862376
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-04 00:17:03 +02:00
Matthias Sohn 2693d6075d Use try-with-resource to close resources in FetchProcess
Change-Id: If489d530ca39ae279c8da848f870b561c38eac3c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-04 00:05:14 +02:00
Matthias Sohn 787ca168a9 Reduce visibility of DirCacheCheckout.checkValidPath()
This was deprecated and should only be used by DirCacheCheckout and
friends. Other classes should use SystemReader.checkPath() instead.

Change-Id: I37cf753b1f081602dee9f0f47979eff39d735f92
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-03 02:03:00 +02:00
Matthias Sohn b84623ac64 Use try-with-resource to close resources in DirCache
Change-Id: I7dd3fd38784689816a1a8e9d8ccb499ae2138a8a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-03 01:25:45 +02:00
Matthias Sohn ff0a7b719e Fix resource leak in DiffFormatter
- close RevWalk allocated in scan()
- replace use of deprecated ObjectReader.release() method

Change-Id: I41b2b10a1a44270a6ceaa1741e996c0921439852
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-03 01:23:31 +02:00
Matthias Sohn b8658e486c Use try-with-resource to close resources in DiffCommand
Change-Id: I13d7c8bd0eb049aa69effd8b74384746226414cb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-03 01:15:37 +02:00
Matthias Sohn 5f8308bdb9 Replace call to deprecated RevWalk.release() in DescribeCommand
Change-Id: Ie4bfdeb37d345d6ff1525a737f3b7653b2f8e23e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-03 00:58:50 +02:00
Matthias Sohn 4bae608e84 Use try-with-resource to close resources in CloneCommand
Change-Id: I9536bc208a5f3ec34f0a82fb565b4253be38e074
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-03 00:38:42 +02:00
Matthias Sohn b53e2a99b3 Silence non-externalized string warnings in CherryPickResult
Change-Id: I515abbcb4319b744c5074de5a0c56caed13c2fb5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-03 00:36:36 +02:00
Matthias Sohn 588965c6da Silence non-externalized string warning in CherryPickCommand
Change-Id: I8c06635ce655470b5b650fa5c0c546e64445420c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-03 00:33:01 +02:00
Matthias Sohn 58c2c52219 Use try-with-resource to close resources in CherryPickCommand
Change-Id: I62d6de7d67c7de2460f4cbe918ad2bb8109650b9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-03 00:32:08 +02:00
Matthias Sohn 3f79182081 Fix resource leak in ChangeIdUtil
Change-Id: I5cb3e9c7e167248697932933eef925c446514683
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 01:30:14 +02:00
Matthias Sohn d4380a9c81 Use try-with-resource to close resources in BundleWriter
Change-Id: I5341973737f6d21c04982bcbefc2ed672ac9bcff
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 01:25:46 +02:00
Matthias Sohn 9e37f6d144 Use try-with-resource to close resources in BundleFetchConnection
Change-Id: Id79c01133b835e278d5b494b5bc5972d7aeed9a9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 01:24:05 +02:00
Matthias Sohn d6692d54a9 Use try-with-resource to close resources in BlobBasedConfig
Change-Id: Idb890788a88049d07326cd48e7c5534148f18e32
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 01:21:55 +02:00
Matthias Sohn 48622e0ec2 Replace use of deprecated release() method in BlameResult
Change-Id: Ic555e6e0443337aed694bc6445a60abe08e07ad2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 01:18:42 +02:00
Matthias Sohn e03b6c5cf8 Use try-with-resource to close BlameGenerator
Change-Id: Id4cb9a236dddfc674b55e9e7037329a885455288
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 01:15:59 +02:00
Matthias Sohn 21eee62f7d Remove unnecessary $NON-NLS comment in BaseReceivePack
Change-Id: I184945ee29fb9a6b1f30aec88958375e7b5239b3
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 01:12:22 +02:00
Matthias Sohn c1edc1a07e Use try-with-resources to close resources in BaseReceivePack
Change-Id: Iacaad1a7e0719541e5616d231422ea6fd4c95161
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 01:11:22 +02:00
Matthias Sohn 6691c20bc2 Replace use of deprecated release() in BasePackPushConnection
Change-Id: I28a5c7e222daf35e3d1a1a6fda8ed6ef9b960f78
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 01:06:08 +02:00
Matthias Sohn b61be2cf3e Replace use of deprecated release() in BasePackFetchConnection
Change-Id: If90a6cca9a2ae80474f5ad023cb2a0a8905010be
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 01:02:21 +02:00
Matthias Sohn 81c84c088f Use try-with-resources to close walks in ArchiveCommand
Change-Id: I77120d77a12f1bab5c918a23b0e3eac90e320b2b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 00:58:13 +02:00
Matthias Sohn 114dee6770 Silence warning for non-translatable String in AddNoteCommand
Change-Id: Iad4d41271eff4e8744efece5bc777c1cb06dead7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 00:51:02 +02:00
Matthias Sohn 3206f37cc3 Use try-with-resources to fix warnings in AddNoteCommand
Replaces use of deprecated release() methods.

Change-Id: I0211bcf0a76a2fccc2c85fa74778e20c256984ba
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 00:46:59 +02:00
Matthias Sohn e5b81e49e8 Use try-with-resources to fix warnings in AddCommand
- replaces use of deprecated ObjectInserter.release()
- auto-close TreeWalk

Change-Id: I540ee711b8c3430a71fdff07add506b7d9c039dc
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 00:41:19 +02:00
Matthias Sohn 5d22a7b108 Remove obsolete API warning filters to silence warnings
Change-Id: I958d540a6afb1462a3fbb3d76c8f51f386ac068e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 00:29:34 +02:00
Shawn Pearce d94ce9c754 Buffer overflow output stream
Most callers/users of TemporaryBuffer are sizing the in-memory
portion large enough that most outputs fit into RAM. With this
assumption they don't pay close attention to the size of IOs
being written, as it "should" just be a copy from one byte array
to another.

Overflow sets up a local file handle, which is costly to write to
for small IO units. Wrap the local file in a BufferedOutputStream
to combine small writes together. Larger writes can still bypass the
buffer as BOS automatically avoids copying for larger writes.

Change-Id: I09f4136dd65c48830cfda86d9101bc647581018a
2015-04-01 13:02:09 -07:00
Shawn Pearce e4433e5e37 Fix overflow stream leak during merge conflicts
When reading back from an overflowed TemporaryBuffer the InputStream
must be closed to close the FileInputStream that is reading from
the backing file.

Change-Id: Id83d8f16f5b2c2618a9f841ec3508508455a6ae1
2015-04-01 13:02:09 -07:00
Shawn Pearce 6884ea24cd Use local GIT_DIR for overflow during merge conflicts
By writing the temporary overflow merge result to $GIT_DIR JGit
can ensure the same filesystem permissions apply to protect the
file contents.

If no directory is available from the repository (e.g. DfsRepository)
null will be passed and the system temporary directory will be used
instead.

Change-Id: I95532aa092676d18f1dc1e3fdbe6dcb1f91b782e
2015-04-01 13:02:08 -07:00
Shawn Pearce 835955fc5b Use try-with-resources and BufferedOutputStream for local merge conflicts
Change-Id: If5539aab1de19bb22400c862bbe2cdf7c3e85535
2015-04-01 13:02:08 -07:00
Shawn Pearce 1b63323212 Optimize EolAwareOutputStream for bulk output
Formatting merge conflicts one byte at a time is going to be very
slow when the final OutputStream is a FileOutputStream and the JVM
is making system calls for each byte output.

When outputting a range of bytes from a byte[] the bol (beginning
of line) value only depends on the value of the last byte written.
Other bytes in the array can be passed directly to the lower stream
for more efficient output.

Change-Id: I3415f9a390ee215210a17bb5bf39164d197e1348
2015-04-01 13:02:07 -07:00
Matthias Sohn bda5e76420 ResolveMerge only needs to visit differing TreeEntries
This should considerably speed up the treewalk on larger repositories.

Found by discussing new EGit API to support model merge in change
eda23bb556d342f421f03b93c7faa160998598aa

Change-Id: I822721c76c64e614f87a080ced2457941f53adcd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
cc: Laurent Delaigue <laurent.delaigue@obeo.fr>
2015-03-31 17:33:31 +02:00
Matthias Sohn 6e653aef1d FS.readPipe() shouldn't log IOException as an error
This unintentionally was changed from severity debug to error which is
causing unexpected log entries.

Bug: 463349
Change-Id: I4b6d42a1420652ab6824e237bd231ba86896acbf
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-03-28 10:10:47 +01:00
André de Oliveira 3cd7d0d85a Do not add a newline at the end if neither merged side had one
Bug: 390833
Change-Id: I29f7b79b241929877c93ac485c677487a91bb77b
Signed-off-by: André de Oliveira <andre.oliveira@liferay.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-03-27 20:42:49 -04:00
Laurent Delaigue a5c40a3862 Make RepositoryState.REBASING_MERGE reachable again.
If a non interactive rebase is launched, stopping after a conflict
should set the repository state to RepositoryState.REBASING_MERGE
instead of RepositoryState.REBASING_INTERACTIVE.

Bug: 452623
Change-Id: Ie885aab6d71dabd158a718af0d14fff643c9b850
Also-by: Arthur Daussy <arthur.daussy@obeo.fr>
Signed-off-by: Laurent Delaigue <laurent.delaigue@obeo.fr>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-03-27 15:58:05 +01:00
Christian Halstrick 2bd3556e7e Fix RecursiveMerger in case of multiple, independent base commits
When RecursiveMerger found that there are multiple base-commits for the
commits to be merged it tries to temporarily merge the base commits. But
if these base commits have no common predecessor there was a bug in JGit
leading to a NPE. This commit fixes this by enforcing that an empty tree
is used as base when merging two unrelated base commits.

This logic was already there when merging two commits which have no
common predecessor (ThreeWayMerger.mergeBase()). But the code which was
computing a new temporary base commit in case of criss-cross merges
didn't take care to pick an empty tree when no common predecessor can be
found.

Bug: 462671
Change-Id: Ibd96302f5f81383f36d3b1e3edcbf5822147b1a4
2015-03-25 10:49:58 +01:00
Matthias Sohn 197e3393a5 Merge bundle org.eclipse.jgit.java7 into org.eclipse.jgit
As we moved minimum Java version to 7 we don't need a separate bundle
and feature for JGit features depending on Java 7 anymore.

Change-Id: Ib5da61b0886ddbdea65298f1e8c6d65c9879ced1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-03-23 14:23:07 +01:00
Matthias Sohn 8ec01500e2 Add missing @since tag to DiffInterruptedException
Change-Id: Ibadbc1b476bfe0d1fe11979ec237a3554966eb59
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-03-19 14:53:43 +01:00
Jonathan Nieder 5967b65838 Revert "CommitBuilder should check for duplicate parents"
This reverts commit 6bc48cdc62.

Until git v1.7.10.2~29^2~1 (builtin/merge.c: reduce parents early,
2012-04-17), C git merge would make merge commits with duplicate parents
when asked to with a series of commands like the following:

  git checkout origin/master
  git merge --no-ff origin/master

Nowadays "git merge" removes redundant parents more aggressively
(whenever one parent is an ancestor of another and not just when
duplicates exist) but merges with duplicate parents are still permitted
and can be created with git fast-import or git commit-tree and history
viewers need to be able to cope with them.

CommitBuilder is an interface analagous to commit-tree, so it should
allow duplicate parents.  (That said, an option to automatically remove
redundant parents would be useful.)

Reported-by: Dave Borowitz <dborowitz@google.com>
Change-Id: Ia682238397eb1de8541802210fa875fdd50f62f0
Signed-off-by: Jonathan Nieder <jrn@google.com>
2015-03-18 16:26:05 -07:00
Dave Borowitz 65c379e02d Merge changes I51167503,I794eca3a
* changes:
  TemporaryBuffer: Clear block pointer list instead of reallocating
  TemporaryBuffer: Allow presizing block pointer list
2015-03-18 17:19:52 -04:00
Dave Borowitz e3e9e1f003 TemporaryBuffer: Clear block pointer list instead of reallocating
The block pointer list may have been relatively large, so no need to
make more garbage. Instead, just clear the list and null out all the
elements.

Another possible motivation: a caller may have provided an inaccurate
estimated size, so the list might have been resized several times. If
the list is reused later for a similarly underestimated workload, this
fix will prevent additional resizing on subsequent usages.

Change-Id: I511675035dcff1117381a46c294cc11aded10893
2015-03-18 13:38:58 -07:00
Dave Borowitz edf4368b0c TemporaryBuffer: Allow presizing block pointer list
Callers may wish to use TemporaryBuffer as an essentially unbounded
buffer by passing Integer.MAX_VALUE as the size. (This makes it
behave like ByteArrayOutputStream, only without requiring contiguous
memory.) Unfortunately, it was always allocating an array in the
backing block pointer list to hold enough blocks to MAX_VALUE--all
262,016 of them. It wasn't allocating the blocks themselves, but this
array was still extremely wasteful, using about 2MiB of memory on a
64-bit system.

Tweak the interface to specify an estimated size, and only allocate
the block pointer list enough entries to hold that size. It's an
ArrayList, so if that estimate was wrong, it'll grow. We assume the
cost of finding enough contiguous memory to grow that array is
acceptable.

While we're in there, fix an off-by-one error: due to integer division
we were undercounting the number of blocks needed to store n bytes of
data as (n / SZ).

Change-Id: I794eca3ac4472bcc605b3641e177922aca92b9c0
2015-03-18 13:38:57 -07:00
Christian Halstrick ebed526329 Merge "Make MyersDiff interruptible" 2015-03-18 14:40:29 -04:00
Dave Borowitz 89b91ad406 InMemoryRepository: Use a real Builder class
Change-Id: I161b98a58503415955a21f2720395611f439ce98
2015-03-18 10:22:12 -04:00
Dave Borowitz fd402f71a3 Git: Don't close underlying repo if it came from from a caller
Since 27ae8bc65 Git has implemented AutoCloseable, which means Eclipse
may warn if close() is never called on a Git instance. For example,
the following would result in a resource warning:

  Repository repo = openRepository(foo);
  Git git = new Git(repo);
  try {
    git.someCommand().call();
  } finally {
    repo.close();
  }

(The same warning would occur if repo were created in a try-with-
resources block.)

The "obvious" fix is to open git in a try-with-resources block:

  try (Repository repo = openRepository(foo);
      Git git = new Git(repo)) {
    git.someCommand().call();
  }

Unfortunately, this construction was subtly broken: it would call both
git.close() and repo.close(), but git.close() would call repo.close()
again. Depending on the repository implementation, this might or might
not be ok. If it's not ok, it might not immediately cause an error, if
the reference count of repo was >2 at the time of closing.

Of course, explicitly calling git.close() followed by repo.close() in
two finally blocks has had the same double-closing problem since
forever. But the problem became worse when Git started implementing
AutoCloseable, because now Eclipse is _actively encouraging_
developers to change working code into broken code.

To work around this, keep track in Git's constructor of whether the
repository was passed in or opened at construction time, and only
close the repository if it was opened by Git.

Note that in the original example, there was not _actually_ a resource
leak, since repo was closed exactly once; git did not _need_ to be
closed in this case. But at least fixing this false-positive warning
no longer introduces a real bug.

Change-Id: Ie927a26ce3ae2bf8c3ef5cb963a60847067db95a
2015-03-17 17:05:55 -07:00
Hugo Arès 954306be81 Make MyersDiff interruptible
For some specific file, MyersDiff goes into an infinite loop[1]. Since
this problem is hard to reproduce and possibly harder to fix, this
change makes the MyersDiff interruptible so the diff can be aborted at
least when such infinite loop happens.

[1]https://bugs.eclipse.org/bugs/show_bug.cgi?id=444623

Change-Id: I6e006ccb122d1e68c9846a24d5399d94776c2858
Signed-off-by: Hugo Arès <hugo.ares@ericsson.com>
2015-03-17 16:28:46 -04:00
Christian Halstrick 6bc48cdc62 CommitBuilder should check for duplicate parents
When setting the parents of a commit with setParentIds() or
addParentId() it should be checked that we don't have duplicate parents.
An IllegalArgumentException should be thrown in this case.

Change-Id: I9fa9f31149b7732071b304bca232f037146de454
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2015-03-12 18:18:45 -07:00
Dave Borowitz d79cadb3cf TestRepository: Add a reset method to move HEAD around
This flushed out a number of bugs in the way DfsRefUpdate, or at least
the InMemoryRepository implementation, processes symrefs. These have
been fixed, to an extent, in InMemoryRepository, but other
implementations may still suffer from these bugs.

Change-Id: Ifd12115a0060b9ff45a88d305b72f91ca0472f9a
2015-03-12 12:45:46 -07:00
Markus Duft ede4b3d5a3 Fix compile error due to missing dependencies and since tags
Change-Id: I98a9f17f987c4f3ea19d107f681c44754ed83dca
Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
2015-03-12 15:17:27 +01:00
Shawn Pearce d1bda470d4 Merge "ArchiveCommand: Allow to pass options to underlying stream" 2015-03-11 13:27:18 -04:00
Shawn Pearce 0f51246b0e Merge changes I627681be,I334034a2
* changes:
  TreeWalk: Do not close reader passed explicitly to constructor
  TreeWalk: Stop using deprecated ObjectReader#release()
2015-03-10 19:55:20 -04:00
Dave Borowitz 6f4281b11a TreeWalk: Do not close reader passed explicitly to constructor
The TreeWalk(ObjectReader) constructor is explicitly to handle the case
where the caller is responsible for opening and closing the reader.
The reader should only be closed when it was created in the
TreeWalk(Repository) constructor.

Change-Id: I627681be80d69ea549f953255a64c7b3b68bcec9
2015-03-10 16:27:22 -07:00
Dave Borowitz 421e69a4a0 TreeWalk: Stop using deprecated ObjectReader#release()
Change-Id: I334034a2991a07664302bc8d1f3dead85c2caffe
2015-03-10 16:27:22 -07:00
Matthew Spurrier 1383bdd5bc Make s3 domain dynamic to support different s3 regions
Change-Id: If8f9e85368c56d88bb6ae9efe1b3a29cc18cc1d5
Signed-off-by: Matthew Spurrier <matthew@spurrier.com.au>
2015-03-10 16:11:48 -07:00
Dave Borowitz 1e694f3847 RevWalk: Do not close reader passed explicitly to constructor
The RevWalk(ObjectReader) constructor is explicitly to handle the case
where the caller is responsible for opening and closing the reader.
The reader should only be closed when it was created in the
RevWalk(Repository) constructor.

Change-Id: Ic0d595dc8d10de79e87549546c6c5ea2dc617e9b
2015-03-10 15:27:53 -07:00
Dave Borowitz a91f87d9e1 RevWalk: Stop using deprecated ObjectReader#release()
Change-Id: If4d34f18352bd17467aeded6fd3478f29244657b
2015-03-10 15:24:53 -07:00
Christian Halstrick af3faa764f Merge "Add "--long" option to JGit describe" 2015-03-10 15:17:58 -04:00
Shawn Pearce 7ab6ffdf50 Remove AutoCloseable from internal PackFile and friends
PackFile is held by the block cache and cannot be auto closed in a
try-with-resources statement.  Remove the interface as JGit does
explicit management of the instances.

ObjectDatabase and RefDatabase are internal details of Repository
and are managed with the Repository. Marking them AutoCloseable
provides no value to the library or an application using the API.

Change-Id: Ibee19eadd66233e6666b601583daa1834a7778f1
2015-03-09 20:59:09 -04:00
Shawn Pearce ce3997344e PushCertificateParser: Fix check for blank line after header
Reference equality (!= or ==) cannot be used to check for
String equality. String objects are not necessarily interned
to the same instance.

Use .isEmpty() since the function only cares about an empty
string and does not need to test a specific string value.

Change-Id: If530cb59666a8196d57d2348c893706a517ea541
2015-03-09 17:30:08 -07:00
Shawn Pearce 8cf14cfdad Cleanup some push certificate related javadoc
Change-Id: I319ee4e99462598bf6a934b1efc7939bc4b057a5
2015-03-09 17:28:16 -07:00
David Pletcher fe7c556f34 Fix an invalid format string
The %x format specifier is not valid for a byte array.
This patch fixes a bug that would cause an IllegalFormatConversionException.

Change-Id: I025975eca7b2f10bbafa39f5519f8668e6536541
Signed-off-by: David Pletcher <dpletcher@google.com>
2015-03-09 15:47:01 -07:00
Christian Halstrick 0e3ddea1b0 Add "--long" option to JGit describe
Native git supports "git describe --long". This will enforce returning a
long description of a commit even if a tag is directly pointing to the
commit (in contrast to just returning the tag name as it is now). This
commit teaches JGits DescribeCommand and the describe command in the pgm
package to support "--long".

Bug: 460991
Change-Id: I65e179b79e89049c6deced3c71cb3ebb08ed0a8f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-03-09 13:48:04 -07:00
Matthias Sohn a8fb77853a Merge "Support for the commit-msg hook." 2015-03-02 18:17:57 -05:00
Shawn Pearce a75bd35fa4 Merge "Allow public access to PackIndex" 2015-03-02 16:28:35 -05:00
David Pletcher cc8c270c9b Allow public access to PackIndex
The index provides access to a list of objects in a pack.
This will be helpful for repository integrity checking.

Change-Id: I435eeeb3fe1b1f5632d40528936416e97491d412
Signed-off-by: David Pletcher <dpletcher@google.com>
2015-03-02 15:52:27 -05:00
Laurent Delaigue efeb02bf2b Support for the commit-msg hook.
This hook uses the file .git/COMMIT_EDITMSG to receive and potentially
modify the commit message.

Change-Id: Ibe2faadfb5d3932a5a3da2252d8156c4c04856c7
Signed-off-by: Laurent Delaigue <laurent.delaigue@obeo.fr>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-03-02 17:45:15 +01:00
Laurent Delaigue 26fd56f167 Refactored pre-commit hook to make it less invasive.
Hooks are now obtained via a convenient API like git commands, and
callers don't have to check for their existence.
The pre-commit hook has been updated accordingly.

Change-Id: I3383ffb10e2f3b588d7367b9139b606ec7f62758
Signed-off-by: Laurent Delaigue <laurent.delaigue@obeo.fr>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-03-02 15:33:30 +01:00
Dave Borowitz 12a55c3475 Add an in-process pack transport for use in tests
This allows for testing arbitrary sets of push/fetch hooks (e.g.
PreReceiveHook) without depending on either an external protocol (e.g.
HTTP) or the local filesystem.

Change-Id: I4ba2fff9c8a484f990dea05e14b0772deddb7411
2015-02-27 16:26:39 -08:00
Dave Borowitz 900d7da8ab Extract classes for transport within a JGit process
TransportLocal knows how to spin up a thread to allow two repositories
in the same process to communicate using the wire protocol. However,
it is still tied to local on-disk filesystems, and needs to be able to
fork processes if not using the default git-{upload,receive}-pack
implementation.

Extract out the connection classes so they can be used by other
transport implementations.

Change-Id: I5db59086740735508c2e70a597c2d1a89014b072
2015-02-27 15:22:15 -08:00
Matthias Sohn 360071d75d Add missing since tags for new API
Change-Id: I90d4d7566b2e220b8ea8ea1c644fe4b7fa81c0a3
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-02-27 02:33:05 +01:00
Matthias Sohn 1350f7ea1d Merge branch 'stable-3.7'
* stable-3.7:
  Prepare 3.7.1-SNAPSHOT builds
  JGit v3.7.0.201502260915-r
  Read user.name and email from environment first
  Provide more details in exceptions thrown when packfile is invalid

Change-Id: I427f861c6bc94da5e3e05dbbebbf0ad15719a323
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-02-27 01:54:12 +01:00
Matthias Sohn 9b486e3906 Prepare 3.7.1-SNAPSHOT builds
Change-Id: I2e97610ea9e552e5800e7ca895fd193c8bc507aa
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-02-27 01:41:30 +01:00
Matthias Sohn a312131d79 JGit v3.7.0.201502260915-r
Change-Id: Iec17746cad81cfb1d775e782b30f9d8a13c938b6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-02-26 15:13:01 +01:00
Christian Halstrick 1adac45550 Merge "Read user.name and email from environment first" into stable-3.7 2015-02-25 12:01:43 -05:00
Matthias Sohn 102c50e177 Add/fix since tags for new API for push certificates
This was missed in change I249869cadb2d55aef016371b9311b8583591b9cf

Change-Id: I19c9d4c04b6aa92b9e04c192dee70775d6985b58
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-02-25 14:18:12 +01:00
Matthias Sohn d216ce4143 Merge branch 'stable-3.7'
* stable-3.7:
  Add log4j and slf4j-log4j bridge to jgit feature
  Use slf4j to log instead of printing to System.err
  Use Target Platform Definition DSL to generate target platforms

Change-Id: Ic8779868150c910fa55fd20348e35723e6add0f1
2015-02-24 23:45:19 +01:00
Matthias Sohn a8fd029a93 Read user.name and email from environment first
According to [1] user name and email are taken first from the
environment variables:
GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL
GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL

In case (some of) these environment variables are not set, the
information is taken from the git configuration.

JGit doesn not yet support the environment variables GIT_AUTHOR_DATE and
GIT_COMMITTER_DATE.

[1] https://www.kernel.org/pub/software/scm/git/docs/git-commit-tree.html#_commit_information

Bug: 460586
Change-Id: I3ba582b4ae13674cf319652b5b13ebcbb96dd8ec
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-02-24 16:39:19 +01:00
Stefan Beller b9725a54fd Port push certificates
Push certificates ("git push --signed") have been part of
git-core since version 2.2.0 (released Nov 26 2014). We also
want to support that feature.

This is not complete and is lacking the actual functionality
to validate the signature for now.

Change-Id: I249869cadb2d55aef016371b9311b8583591b9cf
Signed-off-by: Stefan Beller <sbeller@google.com>
2015-02-23 17:15:43 -08:00
David Ostrovsky c0c4c6f09a ArchiveCommand: Allow to pass options to underlying stream
Current ArchiveCommand design doesn't allow to pass in options to
underlying stream implementations. To overcome this, client has to
implement custom format implementation (it cannot be derived from
the existing one, because the classes are marked as final), and set
the options using ThreadLocal, before the method

  ArchiveOutputStream createArchiveOutputStream(OutputStream s)

is get called.

This change extends the ArchiveCommand.Format by allowing to pass
option map during creation of ArchiveOutputStream.

ArchiveCommand is extended correspondingly. That way client can
easily pass options to the underlying streams:

  Map<String, Object> level = ImmutableMap.<String, Object> of(
      "level", new Integer(9));
  new ArchiveCommand(repo)
      .setFormat("zip")
      .setFormatOptions(level)
      .setTree(tree)
      .setPaths(paths)
      .setPrefix(prefix)
      .setOutputStream(sidebandOut)
      .call();

Change-Id: I1d92a1e5249117487da39d19c7593e4b812ad97a
Signed-off-by: David Ostrovsky <david@ostrovsky.org>
2015-02-20 01:40:06 +01:00
Matthias Sohn 57644f23a1 Provide more details in exceptions thrown when packfile is invalid
Mention packfile path in exceptions thrown when we detect that a
packfile is invalid and make excplicit that corrupt packs are removed
from the pack list.

Change-Id: I454ada5f8e69307d3f34d1c1b8f3cb87607ddf35
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-02-17 14:13:22 +01:00
Matthias Sohn c18694e0d1 Use slf4j to log instead of printing to System.err
CQ: 9206
Bug: 458445
Change-Id: Ic68fb7dbe0fb46bf30f157db45bf18d8f3a704c0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-02-17 01:06:17 +01:00
Matthias Sohn 77030a5e94 Implement AutoClosable interface on classes that used release()
Implement AutoClosable and deprecate the old release() method to give
JGit consumers some time to adapt.

Bug: 428039
Change-Id: Id664a91dc5a8cf2ac401e7d87ce2e3b89e221458
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-02-09 14:11:50 +01:00
Matthias Sohn 27ae8bc655 Implement AutoClosable interface to support try-with-resources block
Bug: 428039
Change-Id: I41880862db5303b5bea4b2184ba7844d69c997b5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-02-09 14:11:50 +01:00
Matthias Sohn c26bc63ef1 Set minimum required Java version to Java 7
Bug: 458475
Change-Id: Iea8f2236d4e6a94a8d14bb8cc685006ea3fd1bb7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-02-09 14:11:50 +01:00
Matthias Sohn 21f667edba Merge branch 'stable-3.7'
* stable-3.7:
  Add option --orphan for checkout
  Prepare post 3.7.0.201502031740-rc1 builds
  JGit v3.7.0.201502031740-rc1
  Support for the pre-commit hook
  Fix FileUtils.testRelativize_mixedCase which failed on Mac OS X
  Add a hook test
  Introduce hook support into the FS implementations
  If a pack isn't found on disk remove it from pack list

Conflicts:
	org.eclipse.jgit.java7.test/META-INF/MANIFEST.MF

Change-Id: I936acd24d47b911fa30ab29856094e1b2c6ac3db
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-02-04 14:21:52 +01:00
Matthias Sohn 3c2b4086b6 Prepare post 3.7.0.201502031740-rc1 builds
Change-Id: Id3728e771a4441757de016cc9d68055f668126b0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-02-04 02:04:47 +01:00
Matthias Sohn 8fe6e51be2 JGit v3.7.0.201502031740-rc1
Change-Id: Ia2ea65945b7e1d4120da3d6e6c9f6d5fdb642ae6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-02-03 23:36:31 +01:00
Laurent Goubet 494e893c54 Support for the pre-commit hook
Introduce support for the pre-commit hook into JGit, along with the
--no-verify commit command option to bypass it when rebasing /
cherry-picking.

Change-Id: If86df98577fa56c5c03d783579c895a38bee9d18
Signed-off-by: Laurent Goubet <laurent.goubet@obeo.fr>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-02-02 21:23:32 +01:00
Laurent Goubet 6aed51e3ce Introduce hook support into the FS implementations
This introduces the background plumbing necessary to run git hooks from
JGit. This implementation will be OS-dependent as it aims to be
compatible with existing hooks, mostly written in Shell. It is
compatible with unix systems and windows as long as an Unix emulator
such as Cygwin is in its PATH.

Change-Id: I1f82a5205138fd8032614dd5b52aef14e02238ed
Signed-off-by: Laurent Goubet <laurent.goubet@obeo.fr>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-02-02 10:22:53 +01:00
Matthias Sohn f5936405a3 If a pack isn't found on disk remove it from pack list
If accessing a pack throws FileNotFoundException the pack was deleted
and we need to remove it from the pack list. This can be caused e.g. by
git gc.

Change-Id: I5d10f87f364dadbbdbfb61b6b2cbdee9c7457f3d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-01-27 18:37:39 -05:00
Dave Borowitz 23ad3a3763 Add BatchRefUpdate#toString()
Change-Id: I58c342a91911763055c1073d2f426340fbf94fa4
2015-01-27 10:04:29 -08:00
Matthias Sohn 94ebdbfada Prepare 4.0.0-SNAPSHOT builds
Change-Id: I414ba8ccc82866d3107ba7083a567ea70c879bdf
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-01-27 08:48:26 +01:00
Shawn Pearce 66cbf9255c Merge "Fix integer overflow in DiffFormatter when context is set to large int" 2015-01-27 00:53:04 -05:00
Shawn Pearce 9a2c506845 Merge "Handle invalid tree extensions" 2015-01-27 00:49:02 -05:00
Dave Borowitz d612468c5c InMemoryRepository: Ensure new ref targets exist in the repo
ObjectInserter recently learned to read back inserted objects before
they have been flushed. It is in general unsafe to create refs to such
objects, but it is now much more possible to do so, by passing "new
RevWalk(inserter.newReader())" into RefUpdate#execute(RevWalk).

We can't change the RefUpdate interface to remove execute(RevWalk);
nor would we necessarily want to, for performance reasons. And in any
case, RefUpdate#safeParse explicitly ignores MissingObjectExceptions.
But we can enforce object existence in InMemoryRepository, which will
allow callers using this class in their tests to ensure they are using
the RefDatabase correctly.

Change-Id: I5c696ba23bcd2a536a0512fa7f5b6130961905c5
2015-01-26 09:43:12 -08:00
Christian Halstrick 3d17be85ba Handle invalid tree extensions
In case the index contains wrong tree extensions don't throw a
ArrayIndexOutOfBounds exception but revalidate the tree extension.

It happened that the git index written by Git for Windows contained valid
(means entryCount>0) tree extensions for pathes which are not existing
in the index. Native git handles this inconsistency silently but JGit
was crashing with a ArrayIndexOutOfBounds exception. Teach JGit to
better recognize such cases and revalidate such extensions.

It's hard to write a test because JGit doesn't write such extensions. It
only reads, validates and makes use of them. But the bug tells how to
create such situations.

Bug: 457152
Change-Id: Id3ffd7dc7ae1c55674d88bf1b43953234fe0b68d
2015-01-26 11:16:53 +01:00
Christian Halstrick e314e42d41 Merge "Ensure GitCommand's "callable" guard is thread-safe" 2015-01-23 02:55:06 -05:00
Christian Halstrick 8f8724c857 Merge changes I05be0a5b,Ieee334f4
* changes:
  Document that repo returned by SubmoduleAddCommand needs to be closed
  Document that Git instance returned by CloneCommand needs to be closed
2015-01-23 02:54:33 -05:00
Matthias Sohn 83d7ea1988 Document that repo returned by SubmoduleAddCommand needs to be closed
Bug: 448570
Change-Id: I05be0a5b07f8e22f55637b9a3080362978368bcb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-01-22 17:25:06 +01:00
Matthias Sohn 9ffe6deced Silence non-externalized string warnings in RepoCommand
Change-Id: Ia25543c0d80817f8eb35c667ba5dcce046131a7c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-01-22 00:42:22 +01:00
Matthias Sohn 3623aa0c54 Document that Git instance returned by CloneCommand needs to be closed
Bug: 448570
Change-Id: Ieee334f4d82cd71ba98b26abb8667e8f64cac665
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-01-22 00:23:13 +01:00
Matthias Sohn 1a729bec9c Ensure GitCommand's "callable" guard is thread-safe
This way we can ensure that the same command instance can't be used
concurrently in multiple threads.

Bug: 458023
Change-Id: I4884a1ef2f609f9fb24dda4bd5819dffb9f174b6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-01-21 23:52:28 +01:00
Matthias Sohn e7f153bf3a Merge remote-tracking branch 'origin/stable-3.6'
* origin/stable-3.6:
  Prepare 3.6.3-SNAPSHOT builds
  JGit v3.6.2.201501210735-r
  Don't remove pack from pack list for problems which could be transient
  Log reason for ignoring pack when IOException occurred

Change-Id: I61141b52839511d58e5a5b193bfde31e9f444a6c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-01-21 22:27:46 +01:00
Matthias Sohn 58f3ecea9b Prepare 3.6.3-SNAPSHOT builds
Change-Id: Ie753dc77a23558d1993e959f48b7eb06557ea686
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-01-21 16:48:51 +01:00
Matthias Sohn debb1e25d1 JGit v3.6.2.201501210735-r
Change-Id: I483fc7bbff1561721cf621dc67ce4a193624fa64
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-01-21 13:43:30 +01:00
Matthias Sohn 27ee334213 Don't remove pack from pack list for problems which could be transient
If we hit a corrupt object or invalid pack remove the pack from the pack
list. Other IOException could be transient hence we should not remove
the pack from the list to avoid the problem reported on the Gerrit list
[1]. It looks like in the reported case the pack was removed from the
pack list causing MissingObjectExceptions which disappear when the
server is restarted.

[1] https://groups.google.com/forum/#!topic/repo-discuss/Qdmbl-YZ4NU

Change-Id: I331626110d54b190e46cddc2c40f29ddeb9613cd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-01-21 02:14:34 +01:00
Frank Wagner e09e7c064e Fix RawText.getLineDelimiter() for empty first line
Bug: 456776
Change-Id: Iae50be89ea6d5aee33bd938a937ac5ca578aabca
Signed-off-by: Frank Wagner <frank.wagner@fr.ibm.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-01-17 23:28:20 +01:00
Matthias Sohn 9b86ebb4f6 Log reason for ignoring pack when IOException occurred
This should help to identify the root cause of the problem discussed on
the Gerrit list [1].

[1] https://groups.google.com/forum/#!topic/repo-discuss/Qdmbl-YZ4NU

Change-Id: I871f70e4bb1227952e1544b789013583b14e2b96
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-01-15 17:23:24 +01:00
Matthias Sohn 05078f5de1 Silence API warning raised since 7fafd372
This new git capability isn't yet in the wild in the git-core camp.
Hence we can silence this API warning.

Change-Id: I9e030959f658c58344b04ef2f9edd28060f0c964
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-01-13 16:44:15 +01:00
Stefan Beller 7fafd37298 Update atomic constant
The atomic feature is now cooking in -next in git-core. Very rarely
features are ejected from the the next branch in git-core, so I consider
it reasonable to come up with this patch now to make the 2 implementations
interoperable.

Change-Id: I806a8ae3c045ca5936f69cb903baf9b99ee39181
Signed-off-by: Stefan Beller <sbeller@google.com>
2015-01-12 16:49:21 -08:00
Arthur Daussy c185484dcf Add basic support for .gitattributes
Core classes to parse and process .gitattributes files including
support for reading attributes in WorkingTreeIterator and the
dirCacheIterator.

The implementation follows the git ignore implementation. It supports
lazy reading attributes while walking the working tree.

Bug: 342372
CQ: 9078
Change-Id: I05f3ce1861fbf9896b1bcb7816ba78af35f3ad3d
Also-by: Marc Strapetz <marc.strapetz@syntevo.com>
Also-by: Gunnar Wagenknecht <gunnar@wagenknecht.org>
Also-by: Arthur Daussy <arthur.daussy@obeo.fr>
Signed-off-by: Gunnar Wagenknecht <gunnar@wagenknecht.org>
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
Signed-off-by: Arthur Daussy <arthur.daussy@obeo.fr>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2015-01-07 10:52:06 -08:00
Andrey Loskutov 428d31efd3 AIOOB in ChangeIdUtil.indexOfChangeId if amended message is a newline
Bug: 456792
Change-Id: Idf38a0db7dc72d672ff185dcac2f41f0012a6673
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
2015-01-06 14:33:07 +01:00
Matthias Sohn 79dacba922 Merge branch 'stable-3.6'
* stable-3.6:
  Prepare 3.6.2-SNAPSHOT builds
  JGit v3.6.1.201501031845-r
  Trim author/committer name and email in commit header
  Rename detection should canonicalize line endings
  PathMatcher should respect "assumeDirectory" flag

Change-Id: Idd48c6d94cf1ab09abc07f70d50890b1b78e1833
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-01-04 02:18:27 +01:00
Matthias Sohn 741ebca8b7 Prepare 3.6.2-SNAPSHOT builds
Change-Id: I9699d84af2d4b5382d8ee88ed3517d6b91305421
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-01-04 01:19:35 +01:00
Matthias Sohn f1b2a5361f JGit v3.6.1.201501031845-r
Change-Id: I56e235a271f90ea2d8cdb7d99706f726d4a59c43
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-01-04 00:46:52 +01:00
Rüdiger Herrmann a4c2c8a3ee Trim author/committer name and email in commit header
C Git trims name and email before inserting them into the commit header
so that " A U Thor  " and "  author@example.com " becomes 
"A U Thor <author@example.com>" with a single separating space.

This changes PersonIdent#toExternalString() to trim name and email
before concatenating them.

Change-Id: Idd77b659d0db957626824f6632e2da38d7731625
Signed-off-by: Rüdiger Herrmann <ruediger.herrmann@gmx.de>
2015-01-03 00:28:15 +01:00
Marc Strapetz 1cb5668441 Rename detection should canonicalize line endings
Native Git canonicalizes line endings when detecting
renames, more specifically it replaces CRLF by LF.
See: hash_chars in diffcore-delta.c

Bug: 449545
Change-Id: Iec2aab12ae9e67074cccb7fbd4d9defe176a0130
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-01-02 23:23:22 +01:00
Andrey Loskutov c053900c5b PathMatcher should respect "assumeDirectory" flag
The path matcher should not fail if the rule ends with trailing slash,
target pattern does not ends with the slash and the "assumeDirectory"
flag is set.

E.g. */bin/ should also match a/bin if this pattern is threated as
directory by WorkingTreeIterator (FileMode.TREE).

The old code/tests have never tested directory rules with patterns
*without* trailing slashes but with the "assumeDirectory" flag set.
Unfortunately this is exactly what WorkingTreeIterator does... The tests
are changed to test *both* cases now (with trailing slash and without)
if the target pattern has trailing slash (represents directory).

Bug: 454672
Change-Id: I621c1644d9e94df3eb9f6f09c6de0fe51f0950a4
Also-by: Markus Duft <markus.duft@salomon.at>
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
2014-12-28 02:03:08 +01:00
Matthias Sohn cdfd22da30 Prepare 3.7.0-SNAPSHOT builds
Change-Id: Ib3e7b5f46ee1e27b9cf25b3b2d01d681a5c4904c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-12-24 01:17:40 +01:00
Matthias Sohn 9882915810 Merge branch 'stable-3.6'
* stable-3.6:
  Prepare 3.6.1-SNAPSHOT builds
  JGit v3.6.0.201412230720-r
  [pgm] Add option --bare to clone command
  [pgm] Implement clone using CloneCommand
  Fix junit tests under windows when the platform is explicitly changed
  Fix unit tests for windows by explicitly closing test repos
  [pgm] Add option --tags for ls-remote
  [pgm] Add option --heads for ls-remote
  [pgm] Use LsRemoteCommand to implement ls-remote and add a test

Change-Id: I8f31e76cb7e9416919f37e02c7e51ab1d221df40
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-12-24 01:09:25 +01:00
Matthias Sohn 02b0660b8b Prepare 3.6.1-SNAPSHOT builds
Change-Id: Ie620c90ffafbffc6755b4e1ed55a61a15b118a2a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-12-23 23:38:20 +01:00
Matthias Sohn b2ca2ffd7d JGit v3.6.0.201412230720-r
Change-Id: Ic28e2bbbdb1099e948c64a005c39f6b8d8ac69a8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-12-23 13:56:43 +01:00
Christian Halstrick 3226e35db8 Fix junit tests under windows when the platform is explicitly changed
SystemReader used a chached ObjectChecker which was instantiated only
once. But in case of unit tests where we can change the platform
dynamically (e.g. MockSystemReader.setWindows()) this is wrong and
caused DirCacheCheckoutMaliciousPathTest.
testMaliciousAbsoluteCurDrivePathWindowsOnUnix() to fail. This change
allows 
user of SystemReader to force the creation of a new ObjectChecker. 
MockSystemReader.setWindows() and .setUnix() make use of this feature.

Change-Id: I87458d1dc63c1f5c18979f972b1c1f0d670a9ed8
2014-12-22 15:19:09 +01:00
Shawn Pearce 90cccb96d2 Merge branch 'stable-3.6'
* stable-3.6: (26 commits)
  JGit v3.5.3.201412180710-r
  JGit v3.4.2.201412180340-r
  ObjectChecker: Disallow names potentially mapping to ".git" on HFS+
  ObjectChecker: Disallow Windows shortname "GIT~1"
  ObjectChecker: Disallow ".git." and ".git<space>"
  Always ignore case when forbidding .git in ObjectChecker
  DirCache: Refuse to read files with invalid paths
  DirCache: Replace isValidPath with DirCacheCheckout.checkValidPath
  Replace "a." with "a-" in unit tests
  Support the new repository layout for submodules
  Allow explicit configuration of git directory in CloneCommand
  Allow explicit configuration of git directory in InitCommand
  Fix tests on windows by closing repos
  RepoCommand should close opened repos
  Fix LocalDiskRepositoryTestCase to create correct type of repos
  Prevent NPE if ref can't be resolved when executing ReflogCommand
  Fix DirCacheCheckout to set correct file length if core.autocrlf=true
  CheckoutCommand: Fix checking out ours/theirs when no base stage exists
  Make sure modifications to config-param trustFolderStat are detected
  Apache HttpClientConnection: replace calls to deprecated LocalFile()
  ...

Change-Id: Ife6f21d64a148dbb0d0d9055356b1568188806fe
2014-12-19 07:59:22 -08:00
Shawn Pearce 3f27b9135b Merge "Implement FileSnapshot.toString() to help debugging" 2014-12-19 10:55:24 -05:00
Matthias Sohn 75272ccdfc Merge branch 'stable-3.5' into stable-3.6
* stable-3.5:
  JGit v3.5.3.201412180710-r
  JGit v3.4.2.201412180340-r
  ObjectChecker: Disallow names potentially mapping to ".git" on HFS+
  ObjectChecker: Disallow Windows shortname "GIT~1"
  ObjectChecker: Disallow ".git." and ".git<space>"
  Always ignore case when forbidding .git in ObjectChecker
  DirCache: Refuse to read files with invalid paths
  DirCache: Replace isValidPath with DirCacheCheckout.checkValidPath
  Replace "a." with "a-" in unit tests
  Apache HttpClientConnection: replace calls to deprecated LocalFile()
  Fix two nits about DirCacheEntry constructors
  Detect buffering failures while writing rebase todo file
  Deprecate TemporaryBuffer.LocalFile without parent directory
  Switch FileHeader.extractFileLines to TemporaryBuffer.Heap
  AmazonS3: Buffer pushed pack content under $GIT_DIR
  DirCache: Buffer TREE extension to $GIT_DIR

Change-Id: Iee8acbaa9d4d9047b550641db1b8845d64530785
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-12-19 00:17:54 +01:00
Matthias Sohn 8899006c09 JGit v3.5.3.201412180710-r
Change-Id: Iadbd460da494c04fba71f98c200d6b65ce1709c6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-12-18 15:23:10 +01:00
Matthias Sohn 4d6f66400e Merge branch 'stable-3.4' into stable-3.5
* stable-3.4:
  JGit v3.4.2.201412180340-r
  ObjectChecker: Disallow names potentially mapping to ".git" on HFS+
  ObjectChecker: Disallow Windows shortname "GIT~1"
  ObjectChecker: Disallow ".git." and ".git<space>"
  Always ignore case when forbidding .git in ObjectChecker
  DirCache: Refuse to read files with invalid paths
  DirCache: Replace isValidPath with DirCacheCheckout.checkValidPath
  Replace "a." with "a-" in unit tests
  Apache HttpClientConnection: replace calls to deprecated LocalFile()
  Fix two nits about DirCacheEntry constructors
  Detect buffering failures while writing rebase todo file
  Deprecate TemporaryBuffer.LocalFile without parent directory
  Switch FileHeader.extractFileLines to TemporaryBuffer.Heap
  AmazonS3: Buffer pushed pack content under $GIT_DIR
  DirCache: Buffer TREE extension to $GIT_DIR

Change-Id: I398cf40b006a05a6537788fc6eb1f84df1ed8814
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-12-18 15:18:07 +01:00
Matthias Sohn dbe8b52c5c JGit v3.4.2.201412180340-r
Change-Id: Ie088cf129b04ec64738edbc8c3ce25aa43b557ca
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-12-18 14:49:20 +01:00
Matthias Sohn d476d2f729 ObjectChecker: Disallow names potentially mapping to ".git" on HFS+
Mac's HFS+ folds concatentations of ".git" and ignorable Unicode
characters [1] to ".git" [2]. Hence we need to disallow all names which
could potentially be a shortname for ".git". Example: in an empty
directory create a folder ".g\U+200Cit". Now you can't create another
folder ".git".

The following characters are ignorable Unicode which are ignored on
HFS+:

unicode   hex         name
-------------------------------------------------
U+200C    0xe2808c    ZERO WIDTH NON-JOINER
U+200D    0xe2808d    ZERO WIDTH JOINER
U+200E    0xe2808e    LEFT-TO-RIGHT MARK
U+200F    0xe2808f    RIGHT-TO-LEFT MARK
U+202A    0xe280aa    LEFT-TO-RIGHT EMBEDDING
U+202B    0xe280ab    RIGHT-TO-LEFT EMBEDDING
U+202C    0xe280ac    POP DIRECTIONAL FORMATTING
U+202D    0xe280ad    LEFT-TO-RIGHT OVERRIDE
U+202E    0xe280ae    RIGHT-TO-LEFT OVERRIDE
U+206A    0xe281aa    INHIBIT SYMMETRIC SWAPPING
U+206B    0xe281ab    ACTIVATE SYMMETRIC SWAPPING
U+206C    0xe281ac    INHIBIT ARABIC FORM SHAPING
U+206D    0xe281ad    ACTIVATE ARABIC FORM SHAPING
U+206E    0xe281ae    NATIONAL DIGIT SHAPES
U+206F    0xe281af    NOMINAL DIGIT SHAPES
U+FEFF    0xefbbbf    ZERO WIDTH NO-BREAK SPACE

[1] http://www.unicode.org/versions/Unicode7.0.0/ch05.pdf#G40025
    http://www.unicode.org/reports/tr31/#Layout_and_Format_Control_Characters
[2] http://dubeiko.com/development/FileSystems/HFSPLUS/tn1150.html#UnicodeSubtleties

Change-Id: Ib6a1dd090b2649bdd8ec16387c994ed29de2860d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-12-18 14:49:20 +01:00
Christian Halstrick a09b1b6c3d ObjectChecker: Disallow Windows shortname "GIT~1"
Windows creates shortnames for all non-8.3 files (see [1]). Hence we
need to disallow all names which could potentially be a shortname for
".git". Example: in an empty directory create a folder "GIT~1". Now you
can't create another folder ".git".

The path "GIT~1" may map to ".git" on Windows. A potential victim to
such an attack first has to initialize a git repository in order to
receive any git commits. Hence the .git folder created by init will get
the shortname "GIT~1". ".git" will only get a different shortname if the
user has created a file "GIT~1" before initialization of the git
repository.

[1] http://en.wikipedia.org/wiki/8.3_filename

Change-Id: I9978ab8f2d2951c46c1b9bbde57986d64d26b9b2
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-12-18 14:49:17 +01:00
Shawn Pearce 10310bf8ef ObjectChecker: Disallow ".git." and ".git<space>"
Windows treats "foo." and "foo " as "foo". The ".git" directory is
special, as it contains metadata for a local Git repository. Disallow
variations that Windows considers to be the same.

Change-Id: I28eb48859a95a89111b4987c91de97557e3bb539
2014-12-18 14:49:03 +01:00
Shawn Pearce 07612a610f Always ignore case when forbidding .git in ObjectChecker
The component name ".GIT" inside a tree entry could confuse a
case insensitive filesystem into looking at a submodule and
not a directory entry.

Disallow any case permutations of ".git" to prevent this
confusion from entering a repository and showing up at a
later date on a case insensitive system.

Change-Id: Iaa3f768931d0d5764bf07ac5f6f3ff2b1fdda01b
2014-12-18 14:48:52 +01:00
Shawn Pearce 8d36fa343c DirCache: Refuse to read files with invalid paths
If the DirCache contains a path that is known to be invalid, refuse to
read the DirCache into memory.  This avoids confusing errors later if
an invalid path read from the DirCache were to be passed into a new
DirCacheEntry constructor.

Change-Id: Ic033d81e23a5fbd554cc4dff80a232504562ffa8
2014-12-18 14:48:46 +01:00
Shawn Pearce d547d0c44b DirCache: Replace isValidPath with DirCacheCheckout.checkValidPath
isValidPath is an older simple form of the validation performed by
checkValidPath. Use the latter as it more consistently matches
git-core's validation rules.

By running the same validation as fsck, callers creating an entry
for the DirCache are more likely to learn early they are trying
to build trees that will fail fsck.

Change-Id: Ibf5ac116097156aa05c18e231bc65c0854932eb1
2014-12-18 14:48:39 +01:00
Christian Halstrick 53ff052998 Support the new repository layout for submodules
When updating a submodule (e.g. during recursive clone) the repository
for the submodule should be located at <gitdir>/modules/<submodule-path>
whereas the working tree of the submodule should be located at
<working-tree>/<submodule-path> (<gitdir> and <working-tree> are
associated to the containing repository). Since CloneCommand has learned
about specifying a separate gitdir this is easy to implement in
SubmoduleUpdateCommand.

Change-Id: I9b56a3dfa50f97f6975c2bb7c97b36296f331b64
2014-12-15 00:22:51 +01:00
Christian Halstrick 6e05d98cce Allow explicit configuration of git directory in CloneCommand
This feature is needed to support the new submodule layout where the
.git folder of the submodules is under .git/modules/<submodule>.

Change-Id: If5f13426cfd09b7677e23478e9700c8c25a6dae5
2014-12-15 00:22:51 +01:00
Christian Halstrick 03e860a7b7 Allow explicit configuration of git directory in InitCommand
Native git's "init" command allows to specify the location of the .git
folder with the option "--separate-git-dir". This allows for example to
setup repositories with a non-standard layout. E.g. .git folder under
/repos/a.git and the worktree under /home/git/a. Both directories
contain pointers to the other side: /repos/a.git/config contains
core.worktree=/home/git/a . And /home/git/a/.git is a file containing
"gitdir: /repos/a.git". This commit adds that option to InitCommand.
This feature is needed to support the new submodule layout where the
.git folder of the submodules is under .git/modules/<submodule>.

Change-Id: I0208f643808bf8f28e2c979d6e33662607775f1f
2014-12-15 00:22:50 +01:00
Matthias Sohn ca7c928eae Merge "Fix tests on windows by closing repos" into stable-3.6 2014-12-12 08:50:20 -05:00
Christian Halstrick da595f093e Fix tests on windows by closing repos
Without explicitly closing repos we can't delete the test repositories
on windows.

Change-Id: Id5fa17bd764cbf28703c2f21639d7e969289c2d6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-12-12 14:49:02 +01:00
Christian Halstrick c893534059 Merge "Prevent NPE if ref can't be resolved when executing ReflogCommand" into stable-3.6 2014-12-12 08:31:16 -05:00
Christian Halstrick 1a054f1229 RepoCommand should close opened repos
RepoCommand opend two repos without closing them or returning them to
the caller. This caused certain tests to fail on Windows.

Change-Id: Ia04924aaaad4d16f883b06404c2a85d3f801231f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-12-12 14:06:51 +01:00
Matthias Sohn a24a99a13d 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>
2014-12-12 13:02:27 +01:00
Christian Halstrick 42b20d4127 Merge "Fix DirCacheCheckout to set correct file length if core.autocrlf=true" into stable-3.6 2014-12-12 04:57:30 -05:00
Christian Halstrick 80b1da1aae Merge "CheckoutCommand: Fix checking out ours/theirs when no base stage exists" into stable-3.6 2014-12-12 04:54:46 -05:00
Matthias Sohn 59c4ea042c 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
a606dc363d.

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>
2014-12-11 16:30:57 +01:00
Robin Stocker 47927ac95e 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>
2014-12-10 12:56:10 +01:00