Commit Graph

1356 Commits

Author SHA1 Message Date
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 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 d49c9ee848 Fix unit tests for windows by explicitly closing test repos
Change-Id: If5f67d739f744f19b45e6f5c7597a213fd5bf025
2014-12-22 10:13:41 +01: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
Shawn Pearce d8eaf5a395 Replace "a." with "a-" in unit tests
Windows does not like naming files "a.".  The trailing "." may be
dropped by the filesystem, which is confusing.  Even though these
tests currently do not write to disk, future tests like them might.

Replace "." with "-", which has the same sorting properties that
were desirable about ".", but does not have the same limitations.

Change-Id: Ie5b7594bf5e79828d1341883c73ddb70123d5055
2014-12-18 14:48:29 +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
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 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
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
Andrey Loskutov 147e24a7b2 Consider parent rules if ignore rule is negated
The change tries to make jgit behave more like native CLI git regarding
the negation rules. According to [1] "... prefix "!" which negates the
pattern; any matching file excluded by a previous pattern will become
included again." Negating the pattern should not automatically make the
file *not ignored* - other pattern rules have to be considered too.

The fix adds test cases for both bugs 448094 and 407475.

[1] https://www.kernel.org/pub/software/scm/git/docs/gitignore.html

Bug: 448094
Bug: 407475
Change-Id: I322954200dd3c683e3d8f4adc48506eb99e56ae1
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-29 01:24:20 +01:00
Shawn Pearce 75b4a23748 Deprecate checkoutEntry variant that accepts File
Entries should only be written to the working tree managed by the
Repository. Simplify callers by passing only the entry and computing
the work tree location inside of the checkoutEntry method.

Change-Id: I574e41280d0407f1853fda12f4bd0d30f75d74e7
2014-11-27 13:37:12 -08:00
Shawn Pearce 61b632ee5a 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
2014-11-25 10:21:48 -08:00
Shawn Pearce f31323745f 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
2014-11-25 10:21:48 -08:00
Shawn Pearce 3bc5188900 Deprecate checkoutEntry without ObjectReader
Callers should manage the ObjectReader, as this allows the JGit library to cache
context relevant information across files checked out at the same time. If the
caller only has one file to checkout, it should still explicitly manage the life
span of the ObjectReader.

Change-Id: Ib57fba6cb4b774ccff8c416ef4d32e2b390f16a9
2014-11-24 12:59:45 -08:00
Andrey Loskutov 2c940fa18a Don't use java.util.regex for two simple wildcard cases
To improve ignore parser performance we can avoid using java.util.regex
code on simple wildcard patterns with leading or trailing asterisk. As
those patterns represent a majority of ignore rules, the index diff
performance can be drastically increased on huge repository with lot of
ignore rules.

Bug: 450466
Change-Id: I80428441cc8d5de5468813f841d89322413eed8b
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-18 10:58:26 +01:00
Matthias Sohn 3521712032 Prepare 3.5.3-SNAPSHOT builds
Change-Id: Ia37eb66a0deaf6e86a726b1b12eaea25416d4a36
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-12 08:32:54 -05:00
Matthias Sohn b5e5abcf4d JGit v3.5.2.201411120430-r
Change-Id: I217d25ee712cbde52bc9319ef1dd15d2f571d37a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-12 10:38:44 +01:00
Stefan Beller 423ad8b0ad Fix variable name and error message for sideband testing
Actually the test only allows a range from [1,255], so let's name the
variable so.

Change-Id: Iecdb8149b83389c67e3cd2f64f4a654c175475be
Signed-off-by: Stefan Beller <sbeller@google.com>
2014-11-10 18:18:34 -08:00
Shawn Pearce 0cf902e473 Expand wildcard imports to specfic classes
JGit style is to import exactly the classes required, and never
to use "import foo.*" as the foo package could add new classes
in the future which are conflicting/confusing with the imports
already used by a source file.

Change-Id: I5693408c777e5843ec65fff1163d5d717849fa34
2014-11-10 15:35:20 -08:00
Christian Halstrick 9597c41ea9 Fix possible NPE in IndexDiff when not all submodules are cloned
The latest changes to IndexDiff just assumed that all configured
submodules are allways cloned. If a configured submodule did not exist
an exception was thrown. This is fixed by this commit.

Bug: 450567
Change-Id: Iabe3b196d998c19483082e5720038ebddaeb1890
2014-11-09 22:44:07 +01:00
Christian Halstrick 8456927b1b Make sure checkout doesn't report conflicts on ignored paths
In a situation where a certain path was ignored but a working tree file
with this path existed jgit didn't allow to checkout a branch which
didn't ignore this path but contained different content. JGit considered
this to be a checkout conflict to prevent overwriting the file in the
working tree and raised an error. This commit fixes this by ensuring
that ignored dirty working tree files don't lead to a checkout conflict.

Bug: 450169
Change-Id: I90288d314ffac73c24a9c70a5181f8243bd4679a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-06 15:27:46 -05:00
Christian Halstrick 95172dea17 Support for Submodule configuration submodule.<name>.ignore
For each submodule native git allows to configure which modifications to
submodules should be ignored by the status command. It is possible to
ignore "none", "all", "dirty", "untracked" [1]. This configuration is
now supported by IndexDiff. The StatusCommand offers the possibility to
specify this mode.

[1] http://git-scm.com/docs/gitmodules

Change-Id: Ifd81d574a680f9b4152945ba70f8ec4af4f452c9
2014-11-03 04:32:03 -05:00
Andrey Loskutov 2f5a08798e Reimplementation of ignore rule parser
The current IgnoreRule/FileNameMatcher implementation scales not well
with huge repositories - it is both slow and memory expensive while
parsing glob expressions (bug 440732). Addtitionally, the "double star"
pattern (/**/) is not understood by the old parser (bug 416348).

The proposed implementation is a complete clean room rewrite of the
gitignore parser, aiming to add missing double star pattern support and
improve the performance and memory consumption.

The glob expressions from .gitignore rules are converted to Java regular
expressions (java.util.regex.Pattern). java.util.regex.Pattern code can
evaluate expression from gitignore rules considerable faster (and with
less memory consumption) as the old FileNameMatcher implementation.

CQ: 8828
Bug: 416348
Bug: 440732
Change-Id: Ibefb930381f2f16eddb9947e592752f8ae2b76e1
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-10-27 19:26:42 +01:00
Robin Stocker 6eca51923f Merge "Initialize 'pathLen' field also for empty directories" 2014-10-23 06:50:00 -04:00
Andrey Loskutov 4ea8c655d6 Initialize 'pathLen' field also for empty directories
Bug: 445363
Change-Id: Ia8428af84fb61ba0d572374a19e8e8c55b138a63
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
2014-10-23 12:31:49 +02:00
Robin Stocker 590e1b7602 BundleWriter: Support including HEAD in bundle
Bug: 446813
Change-Id: Ide64aec2a995dd7ff6c1325c3ada242a4eb4565e
Signed-off-by: Robin Stocker <robin@nibor.org>
2014-10-19 14:40:29 +11:00
Matthias Sohn dcb52291a9 Prepare 3.5.2-SNAPSHOT builds
Change-Id: Ib2ccdebe80bad0b09d2d31889a3ab89d77e341f6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-10-14 01:29:37 +02:00
Matthias Sohn 450ce163ef JGit v3.5.1.201410131835-r
Change-Id: I37e049c8e81f963cfb7c17f1af91fd4245766aee
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-10-14 00:38:49 +02:00
Matthias Sohn 13ffda0666 Fix ResetCommand to default to mixed reset
ResetCommand threw an NPE if neither mode nor path was defined. Instead
it should default to a mixed reset like native git does.

Change-Id: I455902394f9e7b0c7afae42381f34838f7f2a138
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-10-13 16:41:58 +02:00
Matthias Sohn 9fd1325ecb Merge branch 'stable-3.5'
* stable-3.5:
  Prepare 3.5.1-SNAPSHOT builds
  JGit v3.5.0.201409260305-r
  Fix PackWriterBitmapWalker handling non-existing uninteresting objects
  Enable maven site generation for jgit
  Generate javadocs as part of Maven site project reports
  Compare API changes with clirr against 3.4.1
  [cli] Use chaining credentials provider to enable .netrc
  Add chaining credentials provider
  [Java 8] Configure doclint to accept missing descriptions
  Do not use .netrc implicitly if no CredentialsProvider was set
  Prepare post 3.5.0-rc1 builds
  JGit 3.5.0.201409071800-rc1
  Fix the ls-remote command when there is no local repo

Change-Id: Iaa4485cac6ff9c7917380e89e12e416e0f52a557
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-09-26 15:45:46 +02:00
Matthias Sohn 848186da86 Prepare 3.5.1-SNAPSHOT builds
Change-Id: Ibf89f996c9d9a7e431ee09261987bb76246de441
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-09-26 14:56:34 +02:00
Matthias Sohn 24a2f9e53d JGit v3.5.0.201409260305-r
Change-Id: Ibf382bda3dcbb4b70829b1dd3a8abfd07bc4879e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-09-26 09:02:45 +02:00
Christian Halstrick fa4f00b7ed Fix PackWriterBitmapWalker handling non-existing uninteresting objects
When writing new packs it should be allowed to specify objects as "have"
(objects which should not be included in the pack) which do not exist in
the local repository.

This works with the traditional PackWriter, but when PackWriter was
working on a repository with bitmap indexes and used
PackWriterBitmapWalker then this feature was broken. Non-existing "have"
objects lead to MissingObjectExceptions. That broke push and Gerrit
replication. When the replication target had branches unknown to the
replication source then the source repository wanted to build pack files
where "have" included branch-tips which were unknown in the source 
repository.

Bug: 427107
Change-Id: I6b6598a1ec49af68aa77ea6f1f06e827982ea4ac
Also-by: Matthias Sohn <matthias.sohn@sap.com>
2014-09-25 19:01:42 -04:00
Christian Halstrick 227357f929 Add "aggressive" option to GC
JGit should offer the possibility to do a garbage collection in
"aggressive" mode. In this mode garbage collection more aggressively
optimize the repository at the expense of taking much more time.
Technically a aggressive mode garbage collection differs from a
non-aggressive one by:
- not reusing packed objects found in old packs. Recompress every object
- the configuration pack.window is set to 250 (the default is 10)
- the configuration pack.depths is set to 250 (the default is 50)

The associated classes in org.eclipse.jgit.api and the command line
command in org.eclipse.jgit.pgm expose this new option.

The configuration parameters gc.aggressiveDepth and gc.aggressiveWindow
have been introduced to configure this feature.

Bug: 444332
Change-Id: I024101f2810acf6be13ce144c9893d98f5c4ae76
2014-09-19 09:17:41 -04:00
Matthias Sohn 66559681dd Prepare post 3.5.0-rc1 builds
Change-Id: Id9e01b867bff0ed10e887c15a12e5399b788b68e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-09-08 01:01:57 +02:00
Matthias Sohn 48820c7b07 JGit 3.5.0.201409071800-rc1
Change-Id: I59e5e2492820da111df1837fbf3649a2ae03841c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-09-07 23:58:44 +02:00
Matthias Sohn 6ccf609e89 Prepare 3.6.0-SNAPSHOT builds
Change-Id: I2d8c3768998c0cfc8d02d11009bc5b7ed1d75778
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-09-05 14:32:01 +02:00
Konrad Kügler 9ac59efbbd PlotCommitList: Close plot lanes at root commits
Bug: 443006
Change-Id: I40b1eb044fa2d9e6c5d4b956c17e32ca6c1bd39f
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
2014-09-02 07:57:04 -04:00
Axel Richard 46f3007b52 Handle -m option for Merge command
Set the commit message to be used for the merge commit (in case one is
created)

Bug: 442886
Change-Id: Ie5ecc13822faa366f00b3daa07f74c8441cae195
Signed-off-by: Axel Richard <axel.richard@obeo.fr>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-08-30 01:17:24 +02:00
Saša Živkov c4797fe986 Let ObjectWalk.markUninteresting also mark the root tree as
uninteresting

Using the ObjectWalk and marking a commit as uninteresting didn't mark
its root tree as uninteresting. This caused the "missing tree ..."
error in Gerrit under special circumstances. For example, if the
patch-set 2 changes only the commit message then the patch-set 1
and patch-set 2 share the same root-tree:

  ps1 -> o   o <- ps2
          \ /
           o root-tree

The transported pack will contain the ps2 commit but not the root-tree
object.

When using the BaseReceivePack.setCheckReferencedObjectsAreReachable
JGit will check the reachability of all referenced objects not provided
in the transported pack. Since the ps1 was advertised it will properly
be marked as uninteresting. However, the root-tree was reachable because
the ObjectWalk.markUninteresting missed to mark it as uninteresting.
JGit was then rejecting the pack with the "missing tree ..." exception.

Gerrit-issue: https://code.google.com/p/gerrit/issues/detail?id=1582
Change-Id: Iff2de8810f14ca304e6655fc8debeb8f3e20712b
Signed-off-by: Saša Živkov <sasa.zivkov@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-08-28 18:05:59 -04:00
Robin Stocker ce312d8afb Strip "<", ">", and "\n" from name/email in UserConfig
This matches what C Git does, see "stripped" in `man git-commit-tree`.

It also fixes the bug of the user where an user.email like "<>" would
show up as "<<>>" in EGit.

Bug: 439844
Change-Id: I567a3c620e191ce9d37d318417e63cb5d4483419
Signed-off-by: Robin Stocker <robin@nibor.org>
2014-08-21 23:21:27 +10:00
Yuxuan 'fishy' Wang 66fc834530 Support remote aliases in repo manifest.
Change-Id: Icbe5761b9d8a4ae5305bfe45b2d042f214156fc8
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-08-18 11:12:08 -07:00
Yuxuan 'fishy' Wang 5a26c538b3 Support non-default remotes in project tag.
Change-Id: I3c730a1ce379d142d3ed81dda4a73f86f1f9c3eb
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-08-18 10:57:09 -07:00
Robin Stocker 8e19fea1a9 Add tests for checking out tags with CheckoutCommand
Change-Id: Ifec3ac59264c91e154b832fdd907736faf8a8412
Signed-off-by: Robin Stocker <robin@nibor.org>
2014-08-17 19:12:04 -04:00
Yuxuan 'fishy' Wang 34dd64f6fe Add support to <include> tag in repo manifest xml.
Change-Id: I32d468f92e24701ea680435bf3417e3850857303
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-08-13 13:04:28 -07:00
Shawn Pearce d70419ab00 Revert "Add a method to DfsOutputStream to read as an InputStream"
This reverts commit b646578d89.

openInputStream() is never used in JGit, nor is it used by any
known working DFS implementation. The method was added as a
utility for reading back from a DfsInserter, but the final
implementation of that feature does not requrire this method.

Change-Id: I075ad95e40af49c92b554480f8993ef5658f7684
2014-08-13 10:42:43 -07:00
Dave Borowitz e1856dbf44 Add a method to ObjectInserter to read back inserted objects
In the DFS implementation, flushing an inserter writes a new pack to
the storage system and is potentially very slow, but was the only way
to ensure previously-inserted objects were available.  For some tasks,
like performing a series of three-way merges, the total size of all
inserted objects may be small enough to avoid flushing the in-memory
buffered data.

DfsOutputStream already provides a read method to read back from the
not-yet-flushed data, so use this to provide an ObjectReader in the
DFS case.

In the file-backed case, objects are written out loosely on the fly,
so the implementation can just return the existing WindowCursor.

Change-Id: I454fdfb88f4d215e31b7da2b2a069853b197b3dd
2014-08-13 10:27:12 -07:00
Robin Stocker 544f65e655 Fix CheckoutCommand not setting up tracking
Instead of passing on the start point as is to CreateBranchCommand, the
resolved ObjectId was used. Given this, CreateBranchCommand did not set
up tracking.

This also fixes CreateBranchCommand with setStartPoint(null) to use HEAD
(instead of NPEing), as documented in the Javadoc.

Bug: 441153
Change-Id: I5ed82b4a4b4a32a81a7fa2854636b921bcb3d471
Signed-off-by: Robin Stocker <robin@nibor.org>
2014-08-05 23:38:07 +10:00
Robin Rosenberg d97558fb1c Merge "Add isRebase to API of BranchConfig" 2014-08-03 07:33:28 -04:00
Robin Stocker f5494c186f Add isRebase to API of BranchConfig
Change-Id: I9819f49410e30d32c2157db0556a0dd6a0bcc5a4
Signed-off-by: Robin Stocker <robin@nibor.org>
2014-08-03 18:38:38 +10:00
Alexey Kuznetsov a4f560551d NetRC parser and credentials provider.
Adds default git command line behaviour of reading credentials
for https connections from .netrc file.

Bug: 428229
Change-Id: I88699ca5da6a20bdeaed24b7e3899cc1022b8e7c
Signed-off-by: Alexey Kuznetsov <axet@me.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-08-03 01:47:43 +02:00
Laurent Goubet 1fd150d565 Add IndexDiff tests for merge conflict state BOTH_ADDED
JGit handled this case improperly which these tests demonstrate. Fixed
by I25915880f304090fe90584c79bddf021231227a2.

Bug: 440537
Change-Id: Ia29c1d6cf8c0ce724cc3ff5ed9e0b396949b44bf
Signed-off-by: Laurent Goubet <laurent.goubet@obeo.fr>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-08-02 23:36:31 +02:00
Christian Halstrick ddbf67e058 IndexDiffFilter should never filter entries with stage!=0
If the IndexDiffFilter is asked whether it should include or filter out
a certain path and for that path there is a dircache entry with a stage
different from 0, then the filter should never filter out this entry.
IndexDiffFilter is an optimized version of AnyDiffFilter and there is no
case where the index contains non-0 stages but we still don't see any
diff for that path.

Change-Id: I25915880f304090fe90584c79bddf021231227a2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-08-02 23:04:26 +02:00
Maik Schreiber 7ff1e0d8f5 Fix RevertCommand to correctly revert multiple commits at once.
The fix is to move the new head commit to the newly-created revert
commit, so that additional revert commits will use the correct head.

Change-Id: I5de3a9a2a4c276e60af732e9c507cbbdfd1a4652
Signed-off-by: Maik Schreiber <blizzy@blizzy.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-07-30 16:20:08 +02:00
Yuxuan 'fishy' Wang a9b9c5b324 Remove overlapping submodules from repo manifest.
Apparently repo allows projects overlapping, e.g. one project's path is "foo"
and another project's path is "foo/bar". This is not supported in git submodule.
At JGit repo side we'll skip all the submodules that are in subdirectories of
other submodules, and on repo side we'll make them submodules to resolve this
problem.

Change-Id: I6820c4ef400c530a36150b1228706adfcc43ef64
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-07-29 16:16:36 -07:00
Christian Halstrick 5171a1843a Merge "RecursiveMerger should not fail on content-merge conflicts of parents" 2014-07-29 03:46:52 -04:00
Yuxuan 'fishy' Wang 73d38bfb33 Strip trailing /s in repo base URI.
Change-Id: I71040db2cca69638cfad89acdc9179ee80592b27
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-07-28 16:13:50 -07:00
Christian Halstrick 3b031fe3dc RecursiveMerger should not fail on content-merge conflicts of parents
Previously when RecursiveMerger was trying to create a single virtual
common base for the merge it was failing when this lead to content-merge
conflicts. This is different from what native git is doing. When native
git's recursive merge algorithm creates a new common base it will merge
the multiple parents and simply take the merge result (potentially
including conflict markers) as common base. See my discussion with Shawn
here: http://www.spinics.net/lists/git/msg234959.html :

  > - How should workingtree, index (stage1,2,3) look like if during
that
  > merge of common ancestors a conflict occurs? Will I see in stage2
and
  > stage3 really see content of X1 and X2?

  Its done entirely in memory and never touches the working tree or
  index. When a conflict exists in the X1-X2 merge the conflict is
  preserved into the new virtual base.

There is still the possibility that the merge of parents lead to
conflicts. File/Folder conclicts, conflicts on filemodes. This commit
only fixes the situation for conflicts when merging content.

Bug: 438203
Change-Id: If45bc3d078b3d3de87b758e71d7379059d709603
2014-07-28 14:52:07 +02:00
Christian Halstrick 0c4553d28a Fix RecursiveMerger's internal use of merge to find a merge base
When RecursiveMerger tried to determine a common base tree it was
recursively tried to merge multiple common bases. But these intermediate
merges which have just been done to determine a single common base for
the final merge already filled some important fields (toBeCheckedOut,
toBeDeleted, ...). These side effects of the intermediate merges led to
wrong results of the final merge. One symptom was that after a recursive
merge which should be succesful you could still see leftover files in
the worktree: files which existed in the (virtual) common base but which
don't exist anymore in the branches to be merged.

The solution is easy: Clear the appropriate fields after common base
determination and start the final merge with a clean state.

Change-Id: I644ea9e1cb15360f7901bc0483cdb9286308c226
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2014-07-25 03:32:38 -04:00
Christian Halstrick cf9b01b09a Handle initial checkout correctly
As described in native gits file "git-read-tree.txt" git has in a
special mode when doing the "initial" checkout. "Initial" means that the
index is empty before the checkout. This was not handled correctly in
JGit and is fixed in this commit. Also see
https://github.com/git/git/blob/master/Documentation/git-read-tree.txt#L181

Change-Id: I9b9d1bd9ebf349cfca420c891c7b099a18d07ba4
2014-07-25 03:31:31 -04:00
Konrad Kügler 48544e27ae Preserve merges during pull if configured to do so
Setting branch.<name>.rebase or pull.rebase to 'preserve' will preserve
merges during rebase. Also, pull.rebase is now consulted if there is no
branch-specific configuration.

Bug: 429664
Change-Id: I345fa295c7e774e0d0a8e6aba30fbfc3552e0084
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
2014-07-15 19:08:19 -04:00
Konrad Kügler e0fbae5dc3 Rebase: Add --preserve-merges support
With --preserve-merges C Git re-does merges using the rewritten merge
parents, discarding the old merge commit. For the common use-case of
pull with rebase this is unfortunate, as it loses the merge conflict
resolution (and other fixes in the merge), which may have taken quite
some time to get right in the first place.

To overcome this we use a two-fold approach:
If any of the (non-first) merge parents of a merge were rewritten, we
also redo the merge, to include the (potential) new changes in those
commits.
If only the first parent was rewritten, i.e. we are merging a branch
that is otherwise unaffected by the rebase, we instead cherry-pick the
merge commit at hand. This is done with the --mainline 1 and --no-commit
options to apply the changes introduced by the merge. Then we set up an
appropriate MERGE_HEAD and commit the result, thus effectively forging a
merge.

Apart from the approach taken to rebase merge commits, this
implementation closely follows C Git. As a result, both Git
implementations can continue rebases of each other.

Preserving merges works for both interactive and non-interactive rebase,
but as in C Git it is easy do get undesired outcomes with interactive
rebase.

CommitCommand supports committing merges during rebase now.

Bug: 439421
Change-Id: I4cf69b9d4ec6109d130ab8e3f42fcbdac25a13b2
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
2014-07-15 19:00:58 -04:00
Konrad Kügler 0f679dbda5 Cherry-Pick: Support --no-commit
Change-Id: Ic4c313a8971a5aa15745518c49e2587a1a0fe8d4
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
2014-07-14 20:01:04 +02:00
Robin Rosenberg 89ad10ec27 Handle diff formatting when there is nothing to compare with
DiffFormatter now suports either side being null and the log program
will output the diff for the first commit.

Bug: 395791
Change-Id: I378957b57e9ad1f7195ba416f402178453f0ebd3
2014-07-06 18:45:48 +02:00
Robin Rosenberg 71c18201c1 Eliminate warning about overlapping variable names
Change-Id: I7e749092c5b51e2857c186088e2c5c6c6d295367
2014-07-04 10:30:54 -04:00
Robin Rosenberg a03bdcbbb4 Don't warn for methods that can be static
Making the methods static would gain little in performance,
make the code harder to change. Removing unncessary warnings
is more important.

Change-Id: If3e6aa9c1d92e58b4e7a8e246cf4aace237d7a7b
2014-07-02 00:36:38 +02:00
Robin Rosenberg 8032b64980 Add new default settings from Eclipse 4.4
These settings were added by Eclipse simply by touching
the project settings. Adding these makes it simpler to see
what local changes have been made.

Change-Id: Iab0aa62530312eb0c78b03b5c6a632742bcc4978
2014-07-02 00:34:41 +02:00
Matthias Sohn 64dde09b85 Merge branch 'stable-3.4'
* stable-3.4:
  Prepare 3.4.2-SNAPSHOT builds
  JGit v3.4.1.201406201815-r
  Allow retrying connecting SshSession in case of an exception

Change-Id: I7efb009b9e012637a16c57e2e93e074023b8e46c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-06-21 01:28:55 +02:00
Matthias Sohn 7865d7100e Prepare 3.4.2-SNAPSHOT builds
Change-Id: If88217d84b88cda6d04c159418d5bc86233fe28c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-06-21 00:57:43 +02:00
Matthias Sohn 03f6e83c40 JGit v3.4.1.201406201815-r
Change-Id: I4383a90fd91a243cd5ce5d0ae4e53874b36c1f47
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-06-21 00:16:29 +02:00
Stefan Lay 4b2b3294b8 Allow retrying connecting SshSession in case of an exception
Connecting to an SshSession may fail due to different reasons. Jsch for 
example often throws an com.jcraft.jsch.JschException: verify: false.[1]
The issue is still not fixed in JSch 0.1.51.
 
In such a case it is worth retrying to connect. The number of connection
attempts can be configured using ssh_config parameter
"ConnectionAttempts" [2].

Don't retry if the user canceled authentication.

[1] http://sourceforge.net/p/jsch/bugs/58/
[2] http://linux.die.net/man/5/ssh_config

Bug: 437656
Change-Id: I6dd2a3786b7d3f15f5a46821d8edac987a57e381
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-06-20 11:48:53 +02:00
Dave Borowitz eb69cef35c Rename RewriteTreeFilter to TreeRevFilter and make it public
The current behavior of passing a TreeFilter to RevWalk has limited
usefulness, since the RevFilter derived from the TreeFilter is always
ANDed together with any other RevFilters. It is also tied fairly
tightly to the parent rewriting mechanism.

Make TreeRevFilter a generic RevFilter that matches modified paths
against any TreeFilter. This allows for more complex logic like
(modified this path OR authored by this person).

Leave the rewrite flag logic in this class, since it's closely tied to
the parent comparison code, but hidden behind a protected constructor.

Change-Id: Ia72ef591a99415e6f340c5f64583a49c91f1b82f
2014-06-12 13:52:09 -07:00
Matthias Sohn 126eb94f77 Prepare post 3.4.0 builds
Change-Id: I49f3741f3973b247a635f7c99b72309d2381a377
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-06-11 17:45:39 +02:00
Matthias Sohn d0daad884f JGit v3.4.0.201406110918-r
Change-Id: I56543234316f04bff4e45628bcb8286a6e52e31f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-06-11 15:20:26 +02:00
Robin Rosenberg 64b0531c35 Prepare 3.5.0-SNAPSHOT builds
Change-Id: I53bd500188e09ae2e007a58b3cd89aa0805d6f2a
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2014-06-04 18:23:29 -04:00
Matthias Sohn 3b83e1a398 Prepare post 3.4 RC3 builds
Change-Id: I9730bb349d0295c811aa3a9ba0f67bd946e86d1e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-06-04 22:14:52 +02:00
Matthias Sohn dd06dcdcf2 JGit v3.4.0.201406041058-rc3
Change-Id: If0cfec023788cae7713dd1ccc250e221365ef984
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-06-04 16:58:04 +02:00
Matthias Sohn 386dff2271 Prepare post 3.4.0 RC2 builds
Change-Id: Id8d784ba7b0aba7c6a00f459bf1ac54c1d36d061
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-05-28 17:41:20 +02:00
Matthias Sohn 314fade855 JGit v3.4.0.201405281120-rc2
Change-Id: Ifd376f58cf867fc84d39582c49e971d998abf63d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-05-28 17:19:39 +02:00
Shawn Pearce e03b5623ba Merge "Unit test for the updating behavior in RepoCommand API." 2014-05-27 17:02:02 -04:00
Yuxuan 'fishy' Wang eb98ebcc27 Unit test for the updating behavior in RepoCommand API.
When update the manifest against a bare repository, RepoCommand will replace
every existing content from the repository with contents populated from the
manifest. Added note for that and a unit test to make sure this behavior.

Change-Id: I1d5960e84bca5aa2a4e86f424d2ddd4197894cdc
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-05-27 12:50:15 -07:00
Roberto Tyley 568df19845 Remove a bit of repetition and casting in PackFileTest
PackFileTest lives in o.e.j.internal.storage.file, so I think it's OK for
it to acknowledge the existence of FileRepository in order to avoid some
unnecessary casting, and probably nicer to avoid the repetition too.

Change-Id: I0de592a32f6178e6d6bf114848101e185b3111a1
Signed-off-by: Roberto Tyley <roberto.tyley@gmail.com>
2014-05-26 11:09:22 +01:00
Andreas Hermann 44f81d956b Allow to include untracked files in stash operations.
Unstashed changes are saved in a commit which is added as an additional
parent to the stash commit.
This behaviour is fully compatible with C Git stashing of untracked
files.

Bug: 434411
Change-Id: I2af784deb0c2320bb57bc4fd472a8daad8674e7d
Signed-off-by: Andreas Hermann <a.v.hermann@gmail.com>
2014-05-22 23:56:08 +02:00
Andreas Hermann b7e46c07f9 Fix for reflog corruption caused by multiline message
If a client passes a multiline message as argument to ReflogWriter.log()
the Reflog gets corrupted and cannot be parsed. ReflogWriter.log() is
invoked implicitly from various commands such as StashCreate, Rebase and
many more. However the message is not always filtered for line feeds.

Such an example is the StashCreateOperation of EGit which passes
unchecked user input as commit message. If a multiline comment is pasted
to the stash create dialog, the reflog gets corrupted.

ReflogWriter now replaces line endings in log message with spaces.

Bug: 435509
Change-Id: I3010cc902e13bee4d7b6696dfd11ab51062739d3
Signed-off-by: Andreas Hermann <a.v.hermann@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-05-22 22:58:44 +02:00
Konrad Kügler 7d6dcd4b34 Improve layout of branches in the commit graph
The aim of this change is to place all commits of a branch on the same
lane and commits of other (side) branches on different lanes.

The algorithm treats first parents of a commit specially by placing them
on the same lane as the commit itself. When a commit is the first parent
of multiple children it could be placed on any of these children's
lanes. In this case it is placed on the longest child lane, as this is
usually the lane of the branch the commit actually was made on.

Other (non-first) parents are placed on new lanes. This creates a layout
that should make it easier to see branches and merges and follow linear
branch histories.
This differs from the previous approach, which sometimes plotted the
commits of a side branch on the same lane as the base branch commits and
further commits on the base branch appeared on a different lane.
This made the base branch appear as if it was the side branch and
the side branch appears to be the base branch.

In addition to lane assignment, also the plotting code changed to start
drawing a branch lane from the commit where it forks out. Previously it
started only when the first commit on the branch appeared.

Active lanes are continued with every commit that is processed.
Previously lanes were only continued when the next commit on the lane
was encountered. This could produce (temporarily) dangling commits if
the next commit on the lane was not processed yet.

CQ: 8299
Bug: 419359
Bug: 434945
Change-Id: Ibe547aa24b5948ae264f7d0f56a492a4ef335608
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-05-22 22:34:22 +02:00
Matthias Sohn 0e13adb9cf Prepare post 3.4.0 RC1 builds
Change-Id: Ia8d29046439bc9134acdf7c88ab85ea49c4ddf47
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-05-21 22:04:43 +02:00
Matthias Sohn d2d56e9efb JGit v3.4.0.201405211411-rc1
Change-Id: Ia3834770b9719f64cbdfd0338034c392fa3ae5db
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-05-21 20:11:56 +02:00
Laurent Goujon 4cb0bd8a43 Adds support for SPNEGO
Adds support for Negotiate(SPNEGO) HTTP authentication method. This method
is set to have a higher priority as Digest HTTP authentication method.

Bug: 428836
Change-Id: Ib181096d39f538df1dd7d3f36516843777bf12ae
Signed-off-by: Laurent Goujon <lgoujon@twitter.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2014-05-21 11:00:26 -05:00
Robin Rosenberg a5ee6fe904 Merge "Cherry-Pick: Support --mainline to pick merges" 2014-05-19 15:43:22 -04:00
Konrad Kügler b84057ad62 Cherry-Pick: Support --mainline to pick merges
By specifying a mainline parent, a merge is cherry picked as if this
parent was its only parent. If no mainline parent is given, cherry
picking merges is not allowed, as before.

Change-Id: I391cb73bf8f49e2df61428c17b40fae8c86a8b76
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
2014-05-17 19:18:07 +02:00
Robin Rosenberg 1a9f122773 Fix a number of failing conflict situations
Adds further tests where the working tree is dirty (differs from
index) and where we have staged but uncommitted changes.

Fixed the test case 9 for file/directory conflicts.

Bug: 428819
Change-Id: Ie44a288b052abe936ebb74272d0fefef3b218a7a
Signed-off-by: Axel Richard <axel.richard@obeo.fr>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2014-05-17 19:06:07 +02:00
Robin Rosenberg f7ac527ca7 Merge "Archive: Add the ability to select one or more paths." 2014-05-17 13:00:26 -04:00
Shaul Zorea 17604c77a8 Archive: Add the ability to select one or more paths.
Previously, it was only possible to archive the entire repository.
This patch introduces the ability to select specific files and
directories to archive.
Archiving the entire repository remains the default behaviour.

org.eclipse.jgit.api.ArchiveCommand: Adding setPaths(String... paths)
method.

Change-Id: Iedcd40fbfd71238b0088174bbe2717fae196e047
Signed-off-by: Shaul Zorea <shaulzorea@gmail.com>
2014-05-14 18:42:29 +03:00
Yuxuan 'fishy' Wang 0b15b48f74 Handle repo copyfile in bare repositories.
Change-Id: Ie06f0c3d1bc9b2123102efaa5542ec3c232b72cd
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-05-09 17:25:50 -07:00
Yuxuan 'fishy' Wang d998bc938a Handle the revision attribute in repo manifest.
Change-Id: I77fe073aeb13c58029551b7d6e1451a9b62dc766
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-05-09 17:25:41 -07:00
Yuxuan 'fishy' Wang 056135a148 Handle repo submodules for bare repositories.
Change-Id: Id028a7bc9600baf0f3e2316a1f4b99e53ccc746a
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-05-07 11:03:51 -07:00
Dave Borowitz 79448bcf94 Merge changes I9ba0e70f,I1f38e055,Idb55a303
* changes:
  Do not rewrite parents in RevWalkTextBuiltins
  RevWalk: Allow disabling parent rewriting
  RevWalkTextBuiltin: Add -n to limit number of commits returned
2014-05-06 14:05:14 -04:00
Dave Borowitz dbf922ce91 RevWalk: Allow disabling parent rewriting
Previously, setting any TreeFilter on a RevWalk triggered parent
rewriting, which in the current StartGenerator implementation ends up
buffering the entire commit history in memory. Aside from causing poor
performance on large histories, this does not match the default
behavior of `git rev-list`, which does not rewrite parent SHAs unless
asked to via --parents/--children.

Add a new method setRewriteParents() to RevWalk to disable this
behavior. Continue rewriting parents by default to maintain backwards
compatibility.

Change-Id: I1f38e05526071c75ca58095e312663de5e6f334d
2014-05-05 16:41:08 -07:00
Matthias Sohn 3a47e45c32 Prepare 3.4.0-SNAPSHOT builds
Change-Id: I5cf20c875c3e92e12c2b22465774ba42513b9add
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-05-06 00:04:09 +02:00
Matthias Sohn f6c42684d9 JGit v3.4.0.201405051725-m7
Change-Id: I8d941d22becdf019199a1c0fe28aa5835038647d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-05-05 23:33:03 +02:00
Konrad Kügler c2fb432cde blame: Fix merges, where merge result differs only by whitespace
When blaming a merge commit with "Ignore whitespace changes" enabled,
don't discard blame candidates for other parents when we encounter a
parent that only has whitespace changes compared to the merge result.

The algorithm early prepares parents for blaming, removing the
appropriate blame regions from the list of regions still to blame. Only
at the end, the prepared blame candidates are submitted for blaming.

When looking at a non-first parent which only differs in whitespace to
the merge result, it submitted that parent, but only to blame it for the
(usually few) lines not already prepared to blame on other parents. Due
to an early return the blame candidates for the previous parents were
forgotten, leaving many lines unannotated.

bug: 433024
Change-Id: I43c9caf2078b92b05e652dbed2192568907bf199
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
2014-05-03 15:17:08 +02:00
Jean-Jacques Lafay 8b65a4e6c6 Fix push to repo with non-fetched refs
When JGit uses bitmaps (which is the case after a gc), the push command
doesn't go through the code where MissingObjectExceptions are caught
for remote objects not found locally.

Fixed by removing earlier non-locally-found remote objects.

This was seen withing gerrit, see:
https://code.google.com/p/gerrit/issues/detail?id=2025

Bug: 426044
Change-Id: Ieda718a0530e3680036edfa0963ab88fdd1362c0
Signed-off-by: Jean-Jacques Lafay <jeanjacques.lafay@gmail.com>
Signed-off-by: Doug Kelly <dougk.ff7@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-04-30 17:43:44 -04:00
Robin Rosenberg 6605255d99 Add methods to Repository to handle remote names
Instead of requiring the caller to know how to list remote
names or parse remote branch names, add a few utilities for
that.

Change-Id: Ib6b2403532f4abbce594a03c0b9da49d30b19f70
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2014-04-27 10:35:21 +02:00
Shawn Pearce d8754aa4f4 Merge changes Ia4df9808,I83e8a321,Id0e7663b,Ib809b00c,I88a6ee07
* changes:
  Commit changes generated during repo command
  Added implementation of copyfile rule.
  Added groups support to repo subcommand.
  Added the command line of jgit repo.
  Implemented first part of the repo sub-command.
2014-04-25 14:01:06 -04:00
Doug Kelly 62697c8d33 Remove streaming delta support from JGit
Streaming packed deltas is so slow that it never feasibly completes
(it will take hours for it to stream a few hundred megabytes on
relatively fast systems with a large amount of storage).  This
was indicated as a "failed experiment" by Shawn in the following
mailing list post:
http://dev.eclipse.org/mhonarc/lists/jgit-dev/msg01674.html

Change-Id: Idc12f59e37b122f13856d7b533a5af9d8867a8a5
Signed-off-by: Doug Kelly <dougk.ff7@gmail.com>
2014-04-24 11:39:01 -07:00
Yuxuan 'fishy' Wang 51cccc9dae Added implementation of copyfile rule.
Change-Id: I83e8a3218be2984321342039fda507fdb1aa5f30
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-04-23 23:03:02 -07:00
Yuxuan 'fishy' Wang a44a687fed Added groups support to repo subcommand.
Change-Id: Id0e7663b6ac4f6938fdcacaf2158107b6285fc25
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-04-23 23:03:00 -07:00
Yuxuan 'fishy' Wang 0ad8fa7b36 Implemented first part of the repo sub-command.
Currently the repo sub-command only "works", but the submodules will have .git
directories themselves, and lacks group support.

Change-Id: I88a6ee07109187c6c9bfd92a044775fcfb5befa6
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-04-23 22:48:51 -07:00
Konrad Kügler 551f3a0fa5 Blame correctly in the presence of conflicting merges
Problem:
The BlameGenerator used the RevFlag SEEN to mark commits it had
already looked at (but not necessarily processed), to prevent
processing a commit multiple times. If a commit is a conflicting
merge that contains lines of the merge base, that have been deleted
in its first parent, either these lines or the lines untouched
since the merge base would not be blamed properly.

This happens for example if a file is modified on a main branch in an
earlier commit M and on a side branch in a later commit S. For this
example, M deletes some lines relative to the common base commit B,
and S modifies a subset of these lines, leaving some other of these
lines untouched.

Then side is merged into main, creating a conflict for these
lines. The merge resolution shall carry over some unmodified lines
from B that would otherwise be deleted by M. The route to blame
these lines is via S to B. They can't be blamed via M, as they
don't exist there anymore.

    Q
    |\
    | \
    | S
    | |
    M |
    | /
    |/
    B

Blaming the merged file first blames via S, because that is the
most recent commit. Doing so, it also looks at B to blame the
unmodified lines of B carried over by S into the merge result. In the
course of this, B is submitted for later processing and marked SEEN.

Later M is blamed. It notices that its parent commit B has been
SEEN and aborts processing for M. B is blamed after that, but only
for the lines that survived via S.

As a result, only the lines contributed by S or by B via S are
blamed. All the other lines that were unchanges by both M and S,
which should have been blamed to B via M, are not blamed.

Solution:
Don't abort processing when encountering a SEEN commit. Rather add the
new region list of lines to be blamed to those of the already SEEN and
enqueued commit's region list. This way when the B commit of the
above example is processed, it will blame both the lines of M and S,
yielding a complete blame result.

Bug: 374382
Change-Id: I369059597608022948009ea7708cc8190f05a8d3
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
Signed-off-by: Shawn Pearce <spearce@spearce.org>
2014-04-17 14:05:51 -07:00
Robin Rosenberg 6654baddae Merge changes Id9a641dd,If2ee1f42
* changes:
  Added TestCase for 7d5e1f Fixed RevWalk.isMergedInto()
  Fixed RevWalk.isMergedInto() returning wrong results
2014-04-09 16:14:28 -04:00
Sven Selberg 0f8a18cfca Added TestCase for 7d5e1f Fixed RevWalk.isMergedInto()
Change-Id: Id9a641dd67c4182bb3a0dc83a6864fee43e7653f
Signed-off-by: Gustaf Lundh <gustaf.lundh@sonymobile.com>
Signed-off-by: Sven Selberg <sven.selberg@sonymobile.com>
2014-04-09 14:51:14 +02:00
Robin Rosenberg 4a11b7137f Fix ValidRefNameTest on Windows
There are certain ref names which native git can be create only on
non-windows systems (e.g. "refs/tags/>"). On Windows systems we can't
persist this refs because the ref names are not valid file names. Our
tests in ValidRefNameTest assumed that these are valid refs on all
systems. This broke the tests on Windows.

Change-Id: Ic53c396c88b84cbdf579a636953f7519952270c0
2014-04-06 12:16:41 -04:00
Robin Rosenberg ecade47a89 Fix FileTreeIteratorTest#testIsModifiedFileSmudged() on Windows
This would be a problem for any OS where Java lets the subscond
part through to the File API. The fix is to force the timetamp
of the index rather than trusting it to just happen to be right.

Bug: 430765
Change-Id: Id6b3ba003f58427a3ffaacd224649e2d6c93566b
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2014-04-06 12:16:20 -04:00
Shawn Pearce 94330d9cb5 Fix ObjectChecker when normalization is enabled
When safeForMacOS is enabled the checker verifies a name does not
match against another name in the same tree after normalization to
NFC. The check was incorrect and failed when the first name was put
in, rejecting simple trees containing only one file like "F".

Add a test for this simple tree to verify it is accepted.
Fix the test for NFC normalization to actually normalize
and have a collision.

Change-Id: I39e7d71150948872bff6cd2b06bf8dae52aa3c33
2014-04-03 11:15:25 -07:00
Robin Rosenberg c8d2040722 Add launchers for running tests with Java 8
Change-Id: I91a7225cff350f11cc224129439622c7dfd9f4f3
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-03-29 20:07:10 +01:00
Robin Rosenberg bb9a4850b5 Make sure we include the Java 7 module in tests when using JDK 8
Change-Id: Idfb3b16725d8f2ad25338dd0910fb1334c00cde4
2014-03-29 20:03:51 +01:00
Stefan Lay e56d50a94b Interactive rebase: Fix order of commit messages on squash
Bug: 431214
Change-Id: I295bfdc5751545b046d7fe7efc3f8b39ab4f5415
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
Signed-off-by: Robin Rosennberg <robin.rosenberg@dewire.com>
2014-03-27 16:11:15 -04:00
Christian Halstrick 16436ef6d9 Fix GarbageCollection not to pack HEAD
When working on a non-bare repository with a detached HEAD jgit's GC was
packing the ref named "HEAD" into the packed-refs file and deleted the
loose ref (the file .git/HEAD!). This made the repo unusable for native
git. This is fixed by telling jgit to only pack refs starting from
"refs/"

Change-Id: I50018aa006f18b244d2cae2ff78b5ffe1b821d63
2014-03-26 15:27:48 +01:00
Dave Borowitz 27473d8e66 Fix NameRevCommand when repo has no annotated tags
Previously, calling addAnnotatedTags() did not modify any state when
there were no annotated tags in the repository. This caused the code
to assume no addFoo() methods had been called, and fell back to the
default of adding refs/*. Instead, use null to indicate neither
addRefs() nor addAnnotatedTags() was called.

Add a test for this behavior.

Change-Id: I9926e5ac17e1a983cd399798993031c72bd79c2c
2014-03-25 18:39:48 -07:00
Rüdiger Herrmann 24921e12d0 Fix text alignment in history plot renderer
When more than one lane is drawn, some commits are vertically misaligned
(off by two pixels). This change fixes the alignment.

Bug: 426047
Change-Id: Icbe7ce9f5a6b281b2aaab66e4d76dfc1010b2fb5
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
Signed-off-by: Rüdiger Herrmann <ruediger.herrmann@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-03-13 23:39:36 +01:00
Shawn Pearce 088e80315b Merge changes I1a225c1b,Ie4d5f082,I41f24363,I9440dd25,I170b6f64,I02e964d1,Iec6ce9e6,Ic700ea8f,Ic3042444,I90a1eaf2,I66eaee5c,Ib921dfd7
* changes:
  Allow configuration of receive pack's ObjectChecker through fsck.*
  Correct fetch to use fetch.fsckObjects and transfer.fsckObjects
  Default receive.fsckObjects to transfer.fsckObjects
  Allow ReceivePack callers to configure their own ObjectChecker
  Check for duplicate names after folding case in ObjectChecker
  Change DirCacheCheckout to verify path using ObjectChecker
  Reject mixed case .git on Mac OS in ObjectChecker
  Reject special Windows device names in ObjectChecker
  Allow an ObjectChecker to reject special characters for Windows
  Reject '.git' as a tree name in ObjectChecker
  Extract path segment check function in ObjectChecker
  Permit ObjectChecker to optionally accept leading '0' in trees
2014-03-12 23:18:32 -04:00
Shawn Pearce 0aa682fc68 Check for duplicate names after folding case in ObjectChecker
Mac OS X and Windows filesystems are generally case insensitive and
will fold 'a' and 'A' to the same directory entry. If the checker is
enforcing safe semantics for these platforms, track all names and
look for duplicates after folding case and normalizing to NFC.

Change-Id: I170b6f649a72d6ef322b7254943d4c604a8d25b9
2014-03-12 16:06:10 -07:00
Shawn Pearce e2f6378847 Change DirCacheCheckout to verify path using ObjectChecker
Reuse the generic logic in ObjectChecker to examine paths.
This required extracting the scanner loop to check for bad
characters within the path name segment.

Change-Id: I02e964d114fb544a0c1657790d5367c3a2b09dff
2014-03-12 16:06:10 -07:00
Shawn Pearce ed3879e389 Reject mixed case .git on Mac OS in ObjectChecker
Most Mac OS X systems use a case insensitive HFS+ volume. Like
Windows ".git" and ".GIT" are the same path and can confuse a Git
program into expecting a repository where one does not exist.

Change-Id: Iec6ce9e6c2872f8b0850cc6aec023fa0fcb05ae4
2014-03-12 16:06:08 -07:00
Shawn Pearce ba0f89b421 Reject special Windows device names in ObjectChecker
If Windows rejection is enabled reject special device names like
NUL and PRN, including NUL.txt. This prevents a tree that might
be used on a Windows client from referencing a confusing name.

Change-Id: Ic700ea8fa68724509e0357d4b758a41178c4d70c
2014-03-12 15:53:30 -07:00
Shawn Pearce 5019471ccb Allow an ObjectChecker to reject special characters for Windows
Repositories that are frequently checked out on Windows platforms
may need to ensure trees do not contain strange names that cause
problems on those systems. Follow the MSDN guidelines and refuse
to accept a tree containing a special character, or names that end
with " " (space) or "." (dot).

Since Windows filesystems are usually case insensitive, also reject
mixed case versions of the reserved ".git" name.

Change-Id: Ic3042444b1e162c6d01b88c7e6ea39b2a73c4eca
2014-03-12 15:43:38 -07:00
Shawn Pearce 09f513cb37 Reject '.git' as a tree name in ObjectChecker
Using .git as a name in a tree is invalid for most Git repositories.
This can confuse clients into thinking there is a submodule or another
repository deeper in the tree, which is incorrect.

Change-Id: I90a1eaf25d45e91557f3f548b69cdcd8f7cddce1
2014-03-12 15:43:38 -07:00
Shawn Pearce 2f1bd3618d Permit ObjectChecker to optionally accept leading '0' in trees
The leading '0' is a broken mode that although incorrect in the
Git canonical tree format was created by a couple of libraries
frequently used on a popular Git hosting site. Some projects have
these modes stuck in their ancient history and cannot easily
repair the damage without a full history rewrite. Optionally permit
ObjectChecker to ignore them.

Bug: 307291
Change-Id: Ib921dfd77ce757e89280d1c00328a88430daef35
2014-03-12 15:43:20 -07:00
Christian Halstrick f1d8ce1dce Rename test class so it is also executed during maven test phase
One specific test was executed when running tests from inside eclipse
(e.g. by using one of our checked in launch configurations). But when
running tests from maven this test was not executed. Maven (the surefire
plugin) looks for Tests only in java files which are named like
"Test*.java", "*Test.java" or "*TestCase.java". Tests in files named
"*Tests.java" are not found.

Change-Id: I62a80fd6e6fda8bd76fdf3f3f2b8cbc56460fb2c
2014-03-12 16:03:20 +01:00
Konrad Kügler efd91ef8a7 Take core.autocrlf into account for blame annotations
Blaming with core.autocrlf set to 'true' - even for freshly checked out
files - showed all lines as being locally modified. For autocrlf = true
the line breaks of the local file will be converted to LF for blaming.
This results in useful diffs and therefor in the desired blame
annotations.

For autocrlf = input no conversion takes place to cope with CRLF line
breaks in the repository, in addition to the usual LF. For autocrlf =
true CRLF line breaks in the repo can't be supported without additional
effort. In that case the whole local file will be blamed as being
locally modified.

Change-Id: If020dcca54d16b2fb79210a070b8480aec82e58e
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2014-03-10 12:22:57 +01:00
Matthias Sohn 47207e98d4 Prepare 3.4.0-SNAPSHOT builds
Change-Id: I907c6f1834c06b8ab4d3e0f76dde475faea7b4a5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-03-05 02:20:38 +01:00
Matthias Sohn 71b90400bb Merge branch 'stable-3.3'
* stable-3.3:
  Update scripts to deploy jgit on Maven central
  Prepare 3.3.1-SNAPSHOT builds
  JGit v3.3.0.201403021825-r
  Fix merge/cherry-picking in CRLF mode
  Expose the received pack size in ReceivePack
  Revert "Add getPackFile to ReceivePack to make PostReceiveHook more usable"
  Avoid an NPE after 7b01a53692
  Add a launcher for Java 7 tests
  Remove obsolete getRepositoryMethod from WorkingTreeIterator
  Fix NPE when WorkingTreeIterator does not have a repository set
  Add getPackFile to ReceivePack to make PostReceiveHook more usable
  Possibility to limit the max pack size on receive-pack
  Package httpclient and httpcore in o.e.j.http.apache.feature

Change-Id: I814a150980854bbaabd767f97b062d247af6cb50
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-03-05 02:02:16 +01:00
Matthias Sohn c1fee1d16b Prepare 3.3.1-SNAPSHOT builds
Change-Id: If15560f2731e54dbf9db88d8a308b4c25ce27e8e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-03-05 00:34:15 +01:00
Robin Rosenberg b640e3ab31 Merge "Add setContains to ListBranchCommand (branch --contains)" 2014-03-03 18:10:44 -05:00
Matthias Sohn 3d855dbfc6 JGit v3.3.0.201403021825-r
Change-Id: Iaf3da455f7d6f691617299e881154ff8185a9d46
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-03-03 00:26:54 +01:00
Robin Rosenberg fd62a45649 Fix merge/cherry-picking in CRLF mode
This fixes a case where we have CRLF in the repo but
LF in the worktree and are in autocrlf mode.

Change-Id: I0388270c1cf0fd22dfd513bcaa404eb97268d39d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-03-02 20:30:42 +01:00
Matthias Sohn 3cebf9c466 Prepare post 3.3.0RC1 builds
Change-Id: I0d808f8733a490b75bbcaacedb4b095e05fab32e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-20 01:04:07 +01:00
Matthias Sohn 8bf45c23df JGit v3.3.0.201402191814-rc1
Change-Id: Ida3a0417ae646ce37214153f49a85de2be3dd4fd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-20 00:14:45 +01:00
Matthias Sohn 514719aa67 [findBugs] Don't ignore exceptional return value of File.mkdir()
Change-Id: Ic4c61472412aa158a355bb444805cde8c5d2833a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-18 22:08:09 +01:00
Matthias Sohn db1877628d [findBugs] Don't rely on default encoding
Change-Id: I9be2ffe95e8d716326ba63b67672741ac316f9a5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-18 22:08:08 +01:00
Matthias Sohn 8fe327a8a1 [findBugs] Don't call toString() on a string
Change-Id: I0b91ffd473e2f14623ddf409e4f0f342c8941e42
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-18 22:08:08 +01:00
Shawn Pearce f2f24a304d Fix diff header on renamed or copied files
When git-core renames or copies a file and the mode differs the
header shows the mode change first, then the rename or copy data:

  diff --git a/COPYING b/LICENSE
  old mode 100644
  new mode 100755
  similarity index 92%
  rename from COPYING
  rename to LICENSE
  index d645695..54863be
  --- a/COPYING
  +++ b/LICENSE
  @@ -56,20 +56,6 @@

JGit relies on this ordering inside of FileHeader. Parsing "new file
mode NNN" after "copy from/to" or "rename from/to" resets the change
type to be ADD, losing the COPIED or RENAMED status and old path.

This fixes a 4 year old bug in Gerrit Code Review that prevents
opening a file for review if the file was copied from another file,
modified in this change, and the mode was updated (e.g. execute
bit was added).

Change-Id: If4c9ecd61ef0ca8e3e1ea857301f7b5c948efb96
[ms: added test case]
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-18 22:08:07 +01:00
Christian Halstrick 38c4f35d8b Introduce an abstraction for HTTP connections
Previously all HTTP communication was done with the help of
java.net.HttpUrlConnection. In order to make JGit usable in environments
where the direct usage of such connections is not allowed but where the
environment provides other means to get network connections an
abstraction for connections is introduced. The idea is that new
implementations of this interface will be introduced which will not use
java.net.HttpUrlConnection but use e.g.
org.apache.client.http.HttpClient to provide network connections.

One example: certain cloud infrastructures don't allow that components
in the cloud communicate directly with HttpUrlConnection. Instead they
provide services where a component can ask for a connection (given a
symbolic name for the destination) and where the infrastructure returns
a preconfigured org.apache.http.client.HttpClient. In order to allow
JGit to be running in such environments we need the abstraction
introduced in this commit.

Change-Id: I3b06629f90a118bd284e55bb3f6465fe7d10463d
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-18 21:04:10 +01:00
Matthias Sohn 1eae309723 Allow programmatic remote configuration for PullCommand
Also imply remoteBranchName to match current branch name if it wasn't
configured in branch configuration.

Bug: 424812
Change-Id: Id852cedaefb2a537b6aa3c330b9861efad052f11
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-14 16:10:59 +01:00
Konrad Kügler 48e36d8cb3 Use branch.<x>.mergeoptions and merge.ff as defaults for merging
Read options that control squashing, whether or not to commit the merge
and regarding fast forwarding from the configuration and use them if no
explicit values for these options have been provided to MergeCommand.

Change-Id: Ifdaed4b5e4adc142657c03c8e78b709a99eeddbd
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-14 00:34:01 +01:00
Roberto Tyley 2b722815c9 Non-Fast-Forward Ref-Updates: Omit isMergedInto() calls
When the caller specifies to JGit in advance that a ref-update is a
non-fast-forward update, and that those are permitted, we should never
need to call the potentially expensive isMergedInto() check. Re-checking
that the older commit is /not/ reachable from the newer is superfluous.

http://dev.eclipse.org/mhonarc/lists/jgit-dev/msg02258.html

Change-Id: I4bbf593de4dcea6b6f082881c1a33cb3a6a7fb89
Signed-off-by: Roberto Tyley <roberto.tyley@gmail.com>
2014-02-13 18:05:03 -05:00
Roberto Tyley 47f47ffc07 Initialise ReceiveCommand status to NOT_ATTEMPTED for all constructors
Formerly the 4-arg constructor did not do this, which was unfortunate
as that constructor's the only way for an external user of JGit to set
the /type/ of the ref-update - which you might want to do to indicate
that the update is expected to be a UPDATE_NONFASTFORWARD, and thus does
not require expensive isMergedInto() calculations:

http://dev.eclipse.org/mhonarc/lists/jgit-dev/msg02258.html

Change-Id: I84c5e4927131e105bed93e31a62da6367c78de32
Signed-off-by: Roberto Tyley <roberto.tyley@gmail.com>
2014-02-13 17:45:41 -05:00
Robin Rosenberg 14cd43e6df Use fileAttributes to get more attributes in one go
On Windows the length reported by FileAttributes is the size
of the target file (a bug, I guess) rather than the link,
so we read the linke and look at the length of the link instead.

Bug: 353771
Change-Id: I834b06d0447f84379612b8c9190fa77093617595
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-12 01:35:25 +01:00
Robin Stocker 2852b6a07d Fix RevWalkUtils.findBranchesReachableFrom not finding some branches
The "cut off" optimization causes it to not include branches that
contain the specified commit but happen to share commits with a branch
that does not contain the commit.

An example:

      -B foo
        \
    -A---C master

findBranchesReachableFrom for commit A with both branches as input may
not return master (depending on the order of the input). The reason is
that A is not contained in foo, and therefore the old code would put B
in the cutOff set. When then walking the master commits and B is
checked, it is found in the cutOff set and the walk is aborted, causing
master not to be returned even though it should.

Bug: 425674
Change-Id: I2c0c406ce5fcc9a03538b483473af930d4895d30
Signed-off-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-11 22:43:35 +01:00
Robin Rosenberg 078a9f6066 Add symlink support to JGit
The change includes comparing symbolic links between disk and index,
adding symbolic links to the index, creating/modifying links on
checkout. The behavior is controlled by the core.symlinks setting, just
as C Git does. When a new repository is created core.symlinks will be
set depending on the capabilities of the operating system and Java
runtime.

If core.symlinks is set to true, the assumption is that symlinks are
supported, which may result in runtime errors if this turns out not to
be the case.

Measuring the cost of jgit status on a repository with ~70000 files,
of which ~30000 are tracked reveals a penalty of about 10% for using
the Java7 (really NIO2) support module.

Bug: 354367
Change-Id: I12f0fdd9d26212324a586896ef7eb1f6ff89c39c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-10 22:53:33 +01:00
Robin Rosenberg ff83f54d29 Failing to delete a directory with untracked content is actually ok
We had a test, but it was wrong.

Bug: 424630 
Change-Id: I926e0954c8623a323a50fe8be3ebe5e0ac6944c8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-10 11:25:02 +01:00
Robin Rosenberg e03f18941f Ban dangerous ref names in Windows
Bug: 423551 
Change-Id: I3e71ef1b4a8181f46d2902c9169859f150cd6ad0
Also-By: Robin Stocker <robin@nibor.org>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-05 10:47:12 +01:00
Robin Rosenberg 871ee53b52 Reset internal state canonical length in WorkingTreeIterator when moving
Bug: 426514
Change-Id: Ifb75a4fa12291aeeece3dda129a65f0c1fd5e0eb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-03 14:51:11 +01:00
Robin Rosenberg 5404e70dc6 Fix for core.autocrlf=input resulting in modified file
This version does not attempt to unsmudge, unlike the first attempt
in Idafad150553df14827eccfde2e3b95760e16a8b6.

Bug: 372834
Change-Id: I9300e735cb16d6208e1df963abb1ff69f688155d
Also-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Robin Stocker <robin@nibor.org>
2014-02-02 13:16:19 +01:00
Matthias Sohn 75b31767c4 Do not report ignored directories as untracked
Change-Id: I7e3f6b9fb1ac4b99d2cc9a78c63aad86f4fa5744
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-01-19 00:20:42 +01:00
SATO taichi 2f425cf30c Add git checkout --orphan implementation
Change-Id: I7bb583674641efed210d3cd5b86af27d7bb48e97
Signed-off-by: SATO taichi <ryushi@gmail.com>
2014-01-17 15:37:39 +09:00
Stefan Lay 3db6e05e52 Fix fast forward rebase with rebase.autostash=true
The folder .git/rebase-merge was not removed in this case. The
repository was then still in rebase state, but neither abort nor
continue worked.

Bug: 425742
Change-Id: I43cea6c9e5f3cef9d6b15643722fddecb40632d9
2014-01-15 13:23:49 +01:00
Robin Stocker c096b42e3e Add setContains to ListBranchCommand (branch --contains)
To correspond to the behavior of "git branch", also return HEAD in case
it is detached.

Bug: 425678
Change-Id: Ie615731434d70b99bd18c7a02e832c0a2c3ceef3
Signed-off-by: Robin Stocker <robin@nibor.org>
2014-01-14 17:45:50 +01:00
Colby Ranger ce5fd525be Upgrade javaewah to version 0.7.9
Package was renamed, so I had to update the imports. Also, I verified
bitmap serialization was still compatible.

Change-Id: I161ad3875b963b56001beab477ef8d072accee4f
2014-01-13 11:47:58 -08:00
Matthias Sohn aad7dee3ef Merge branch 'stable-3.2'
* stable-3.2:
  Canonicalize worktree path in BaseRepositoryBuilder if set via config
  Add missing @since tags for new public methods in Config
  Don't use API exception in RebaseTodoLine
  Fix aborting rebase with detached head
  Add recursive variant of Config.getNames() methods
  Prepare post 3.2.0-m3 builds
  JGit v3.2.0.201311130903-m3

Change-Id: Iad6e284e0fe2c7950f156372b334e47ebd82f3f7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-12-13 12:55:59 +01:00
Christian Halstrick ea04d2329d Don't use API exception in RebaseTodoLine
This came up while testing the proposed buck build for jgit. With buck
we can introduce smaller modules to allow for more concurrency during
build and to better control inner structure of jgit. Trying to put the
porcelain API into a different module than lower level implementation
classes failed since RebaseTodoLine used a porcelain API exception
causing a dependency cycle on the proposed modules. Using an exception
defined on the same abstraction level fixes this problem.

Change-Id: I26a5353e1a8fc23e67d8ce61309bd964f7665bcb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2013-12-11 23:27:36 +01:00
Robin Rosenberg 3a063a0ed4 Merge "Fix aborting rebase with detached head" into stable-3.2 2013-12-10 16:15:55 -05:00
Stefan Lay e90438c0e8 Fix aborting rebase with detached head
Bug: 423670 
Change-Id: Ia6052867f85d4974c4f60ee5a6c820501e8d2427
2013-12-10 15:54:48 +01:00
Matthias Sohn 2e0d178855 Add recursive variant of Config.getNames() methods
These methods allow to find all configuration entry names for a given
section or section/subsection searching recursively through all base
configurations of the given configuration.

These methods are needed to calculate the names for the effective
configuration of a git repository which combines the configuration entry
names found in the repository, global and system configuration files

Bug: 396659
Change-Id: Ie3731b5e877f8686aadad3f1a46b2e583ad3b7c6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-12-06 14:27:42 +01:00
Matthias Sohn b14a939718 Prepare 3.3.0-SNAPSHOT builds
Change-Id: I7c7e7c1beec0c5d15b96c14c73ce93e3f09855c8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-12-05 22:42:47 +01:00
Stefan Lay f86a488e32 Implement rebase.autostash
This feature was introduced in native git with version 1.8.4.

Bug: 422951
Change-Id: I42f194174d64d7ada6631e2156c2a7bf93b5e91c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-12-04 22:02:22 +01:00
Christian Halstrick 77432969d3 Merge "More helpful InvalidPathException messages (include reason)" 2013-12-04 03:23:56 -05:00
Robin Stocker e0502ebb03 More helpful InvalidPathException messages (include reason)
Instead of just a generic "Invalid path: $path", add a reason for the
cases where it's not obvious what the problem is (e.g. "aux" being
reserved on Windows).

Bug: 413915
Change-Id: Ia6436bd2560e4f049c92d9aac907cb87348605e0
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-12-03 23:10:05 +01:00
Robin Stocker f4dae204a6 Fix IgnoreRule#isMatch returning wrong result due to missing reset
The matcher has to be reset before using it, as was already done in the
other cases.

Bug: 423039
Change-Id: I87abaa7ad7f0aac8651db6e88d41427cacb4d776
Also-by: Ondrej Vrabec <ovrabec@netbeans.org>
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-12-03 22:30:14 +01:00
Robin Stocker 7dc8a4f089 Fix exception on conflicts with recursive merge
When there are conflicts with a recursive merge, the conflicting paths
are stored in unmergedPaths (field in ResolveMerger). Later, when the
MergeResult is constructed in MergeCommand, getBaseCommit is called,
which computes the merge base a second time.

In case of RecursiveMerger, getBaseCommit merges the multiple merge
bases into one. It does this not by creating a new ResolveMerger but
instead calling mergeTrees. The problem with mergeTrees is that at the
end, it checks if unmergedPaths is non-empty and returns false in that
case.

Because unmergedPaths was already non-empty because of the real merge,
it thinks that there were conflicts when computing the merge base again,
when there really were none.

This can be fixed by storing the base commit when computing it and then
returning that instead of computing it a second time.

Note that another possible fix would be to just use a new ResolveMerger
for merging the merge bases instead. This would also remove the need to
remember the old value of dircache, inCore and workingTreeIterator (see
RecursiveMerger#getBaseCommit).

Bug: 419641
Change-Id: Ib2ebf4e177498c22a9098aa225e3cfcf16bbd958
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-12-03 21:05:37 +01:00
Stefan Lay 591998c2d6 Do not allow non-ff-rebase if there are uncommitted changes
With this change jgit checks for uncommitted changes before a rebase is
started. This is also done by native git. One reason is that an abort
would override such changes. The check is skipped for a non-interactive
rebase when it will result in a fast-forward. In this case there can be
only checkout conflicts but no merge conflicts, so there cannot be an
abort which overrides uncommitted changes.

Bug: 422352
Change-Id: I1e0b59b2a4d80a686b67a6729e441924362b1236
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-12-02 09:45:15 +01:00
Christian Halstrick af40635aba Fix handling of file/folder conflicts during a checkout
JGit was not handling certain file/folder conflicts during a checkout
correctly. This was reported by Axel Richard in
http://dev.eclipse.org/mhonarc/lists/jgit-dev/msg02358.html.
This commit fixes this problem.

Still JGit behaves intentionally different than native git.
If HEAD contains a tree, and workingtree, Index and Merge contain a file
with same content ... then JGit allows a conflict free checkout of
Merge. Native git always complains that it doesn't want to overwrite
local changes. But there is no need to update the working tree because
Index and Merge are already equal.

A shell script which shows how native git behaves can be found here.
https://gist.github.com/chalstrick/7694959#file-gistfile1-sh

Change-Id: Ifd6a68974d61cd4fa23bc575f3a40773db66cafc
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2013-11-29 22:32:36 +01:00
Stefan Lay dcd0dd4d9e Fix applying stash on other commit
Applying a stash on another commit failed because the merge base for the
cherry-pick of the stashed index state was not corectly set.

Bug: 422684
Change-Id: I9355352b2b9a7abefa3248ca3c17a9301177d0d6
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2013-11-29 10:36:53 -05:00
Shawn Pearce 53616a85ef Break up GCTest to run in parallel
Separate some sections of the GC tests into different test classes.
Individual classes permits running in parallel under Buck, reducing
test latency if there are sufficient CPUs available.

Change-Id: I5eb177f78efd4aa8ac857d0d8b1a1fd81ca07790
2013-11-24 11:37:49 +01:00
Shawn Pearce 531d577658 Modify T0004_PackReaderTest to use existing pack
Instead of making a new PackFile from a resource, lookup
the existing PackFile that was already created by the base
class SampleDataRepositoryTestCase.

Change-Id: Ib5da18c832ae0cb29703706b99e99503f5cc819d
2013-11-24 05:27:21 -05:00
Shawn Pearce d54d19740a Move SampleDataRepositoryTestCase to org.eclipse.jgit.test
This class requires resources which are private to another
bundle. Move the class next to its resources, removing an
odd cross bundle dependency.

Change-Id: I30d5568b09ea5fb3bd3bb60b602f149c0867f49a
2013-11-24 05:27:14 -05:00
Matthias Sohn 7f7dd171df Cache SimpleDateFormat in GitDateParser per locale
Otherwise switching to another locale yields wrong results when parsing
date strings in GitDateParser. Since the MockSystemReader explicitly
uses english locale the tests need to specify the locale to be used when
parsing date strings.

Bug: 420772
Change-Id: I313ef6b1e9ef3bfb43d929ce34712ebd21f2cd9c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-11-23 22:06:08 -05:00
Stefan Lay 8339a07e83 Fix FIXUP error for blank lines in interactive rebase
Empty lines of discarded commit messages were added to the commit
message because they were not commented out properly.

Bug: 422246
Change-Id: I263e8a6b30a3392d8b4f09c0695505068a0a485d
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2013-11-22 16:50:44 -05:00
Stefan Lay 4feace2b9e Fix parsing Rebase todo lines when commit message is missing
Bug: 422253
Change-Id: I9739b16c91d2df31a481360a712d3479a4eeee2e
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2013-11-21 14:47:24 +01:00
Christian Halstrick 7dce16018e Add close() method to API
The API in org.eclipse.jgit.api does allow to open repositories but it
did not allow to close them. This commit fixes this and allows
API users to close a repository without having to use lower-level
classes.

Bug: 420502
Change-Id: I866225cc8534ae5916113fa24eb1c7513fd4472e
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-11-20 00:16:39 +01:00
Christian Halstrick 8da939221c Don't delete .idx file if .pack file can't be deleted
If during an garbage collection old packfiles are deleted it could
happen that on certain platforms the index file can be deleted but the
packfile can't be deleted (because someone locked the file). This led
to repositories with packfiles without corresponding index files. Those
zombie-packfiles potentially consume a lot of space on disk and it is
never tried to delete them again. Try to avoid this situation by
deleting packfiles first and don't try to delete the other files if we
can't delete the packfile. This gives us the chance to delete the
packfile during next GC.

This commit only improves the situation - there is still the chance for
orphan files during packfile deletion. We don't have an atomic delete
of multiple files .

Change-Id: I0a19ae630186f07d0cc7fe9df246fa1cedeca8f6
2013-11-13 08:59:43 +01:00
Matthias Sohn f1c086f692 [findBugs] Remove nonsense call
Result of c.containsAll(c)  is always true for any collection c.

Change-Id: I853cbb44bdc03e2b54229bb9c36ae42e02dcc4d9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-11-10 16:01:09 -05:00
Matthias Sohn 1ec72e9a1c Remove unnecessary @SuppressWarnings("null")
Change-Id: I5bddcdab2c5cc92622144a7b207bad90cb601609
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-11-10 16:00:12 -05:00