]> source.dussan.org Git - jgit.git/log
jgit.git
8 years agoFix "remote: Counting objects: ..." formatting 03/63403/2
Shawn Pearce [Fri, 1 Jan 2016 00:12:51 +0000 (16:12 -0800)]
Fix "remote: Counting objects: ..." formatting

Trailing whitespace is usually removed in properties files so
JGitText did not supply a space between : and the remote message.
Ensure the space exists at runtime by reading the localized string
and appending a space if it is missing.

Messages should be dynamically fetched and not held in a static
class variable, as they can be changed using thread locals.

Change-Id: If6a3707d64094253b1a5304fbfafcf195db7497a

8 years agoclone: display progress messages 02/63402/2
Shawn Pearce [Fri, 1 Jan 2016 00:03:13 +0000 (16:03 -0800)]
clone: display progress messages

Also support -q/--quiet flag to disable progress.

Change-Id: I979277502c990f6dec052d095461c996ff8fe577

8 years agobuck: run tests 01/63401/3
Shawn Pearce [Thu, 31 Dec 2015 18:44:30 +0000 (10:44 -0800)]
buck: run tests

Compile each test in its own java_test() target so they can run in
parallel, reducing total time spent testing on large machines.

$ buck test --all
[-] PROCESSING BUCK FILES...FINISHED 0.3s [100%]
[-] BUILDING...FINISHED 2.9s [100%] (351/383 JOBS, 351 UPDATED, 0.0% CACHE MISS)
[-] TESTING...FINISHED 98.1s (3360 PASS/15 SKIP/0 FAIL)

Change-Id: I8d6541268315089299f933ed23d785b1b3431133

8 years agobuck: build standalone jgit binary 00/63400/2
Shawn Pearce [Thu, 31 Dec 2015 19:18:02 +0000 (11:18 -0800)]
buck: build standalone jgit binary

Construct the java_application JAR wrapped with the shell script
header.  This is enough to clone a repository over HTTPs:

  $ buck build :jgit_bin
  $ buck-out/gen/jgit_bin/jgit_bin clone https://...

Change-Id: I4aceb4e77b2ec9be76a32ec93d94f2dafe9acce6

8 years agoImplement Buck driven build 38/61938/3
David Ostrovsky [Fri, 4 Dec 2015 07:27:57 +0000 (08:27 +0100)]
Implement Buck driven build

Today there are plenty of modern build tool systems available in the
wild (in no particular order):

* http://bazel.io
* https://pantsbuild.github.io
* http://shakebuild.com
* https://ninja-build.org
* https://buckbuild.com

The attributes, that all these build tools have in common, are:

* reliable
* correct
* very fast
* reproducible

It must not always be the other build tool, this project is currently
using. Or, quoting Gerrit Code Review maintainer here:

  "Friends, don't let friends use <the other build tool system>!"

This change is non-complete implementation of JGit build in Buck,
needed by Gerrit Code Review to replace its dependency with standlone
JGit cell. This is very useful when a developer is working on both
projects and is trying to integrate changes made in JGit in Gerrit.

The supported workflow is:

  $ cd jgit
  $ emacs <hack>
  $ cd ../gerrit
  $ buck build --config repositories.jgit=../jgit gerrit

With --config repositories.jgit=../jgit jgit cell is routed through
JGit development tree.

To build jgit, issue:

  $ buck build //:jgit
  [-] PROCESSING BUCK FILES...FINISHED 0,0s

Yes, you can't measure no-op build time, given that Buck daemon is
used.

Change-Id: I301a71b19fba35a5093d8cc64d4ba970c2877a44
Signed-off-by: David Ostrovsky <david@ostrovsky.org>
8 years agoMerge "Fix encoding problem from curl repostory on github"
Shawn Pearce [Thu, 31 Dec 2015 04:47:27 +0000 (23:47 -0500)]
Merge "Fix encoding problem from curl repostory on github"

8 years agoMerge "Fix hanging fetch via SSH"
Shawn Pearce [Thu, 31 Dec 2015 04:27:09 +0000 (23:27 -0500)]
Merge "Fix hanging fetch via SSH"

8 years agoFix encoding problem from curl repostory on github 61/50361/2
Eryk Szymanski [Wed, 17 Jun 2015 15:17:17 +0000 (17:17 +0200)]
Fix encoding problem from curl repostory on github

Pushing curl repository to gerrit fails with a message:
remote: error: internal error while processing changes
java.nio.charset.IllegalCharsetNameException: 'utf8'

curl repository url: https://github.com/bagder/curl.git

To avoid this problem encodingAliases in RawParseUtils have
been extended to contain "'utf8'" (single quoted utf8) string.

Change-Id: I40f613cfdcabf0dc9455bee45116ab8d8c7dd6ee
Signed-off-by: Eryk Szymanski <eryksz@gmail.com>
8 years agoMake sure tests don't blindly continue if a command is "silently" failed 89/63389/1
Andrey Loskutov [Wed, 30 Dec 2015 23:48:07 +0000 (00:48 +0100)]
Make sure tests don't blindly continue if a command is "silently" failed

Make the default execute() function fail fast on first command printed
"fatal: " to output.

Introduced executeUnchecked() for few tests which wanted to test fatal
output.

Change-Id: I5b09aad9443515636811fc4d00bf8b8b9587a626
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years agoRename files using NIO2 atomic rename 69/46469/6
Matthias Sohn [Thu, 23 Apr 2015 00:11:00 +0000 (02:11 +0200)]
Rename files using NIO2 atomic rename

Bug: 319233
Change-Id: I5137212f5cd3195a52f90ed5e4ce3cf194a13efd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoObjectChecker: use java.text.Normalizer directly 85/63385/2
Shawn Pearce [Wed, 30 Dec 2015 20:23:06 +0000 (12:23 -0800)]
ObjectChecker: use java.text.Normalizer directly

Base Java version for JGit is now Java 7. The java.text.Normalizer
class was available in Java 6. Reflection is no longer required to
normalize strings for Mac OS X.

Change-Id: I98e14b72629a7a729a2d40a3aa275932841274e8

8 years agoMerge changes I3db332bf,I614e7110,I37a4ccd6,I86b81e7f,Ic8b362e0, ...
Shawn Pearce [Wed, 30 Dec 2015 20:44:29 +0000 (15:44 -0500)]
Merge changes I3db332bf,I614e7110,I37a4ccd6,I86b81e7f,Ic8b362e0, ...

* changes:
  Sort "eager" path-like options to the end of the help
  reset command: provide convenient and meaningful options help
  commit command: allow to specify path(s) argument(s)
  status command: consume more then one argument after --
  repo command: properly name the required 'path' argument
  Un-ignored existing CLI tests which run just fine on Java 7+
  Don't treat command termination due '-h' option as a fatal error

8 years agoUnify fetch and receive ObjectChecker setup 66/63366/2
Shawn Pearce [Wed, 30 Dec 2015 00:53:56 +0000 (16:53 -0800)]
Unify fetch and receive ObjectChecker setup

This avoids duplication of code between receive-pack and fetch-pack paths.
Separate methods are still required to check use of receive.fsckobjects vs.
fetch.fsckobjects, both of which default to transfer.fsckobjects.

Change-Id: I41193e093e981a79fc2f63914e273aaa44b82162

8 years agoPackWriter: use lib.ObjectIdSet to avoid wrapper 61/63361/2
Shawn Pearce [Tue, 29 Dec 2015 23:11:21 +0000 (15:11 -0800)]
PackWriter: use lib.ObjectIdSet to avoid wrapper

Hoist ObjectIdSet up to lib as part of the public API and add
the interface to some common types like PackIndex and JGit custom
ObjectId map types.  This cleans up wrapper code in a number of
places by allowing direct use of the types as an ObjectIdSet.

Future commits can now rely on ObjectIdSet as a simple read-only
type to check a set of objects from a number of storage options.

Change-Id: Ib62b062421d475bd52abd6c84a73916ef36e084b

8 years agoSort "eager" path-like options to the end of the help 44/63344/4
Andrey Loskutov [Tue, 29 Dec 2015 13:27:37 +0000 (14:27 +0100)]
Sort "eager" path-like options to the end of the help

The "--" path option (and all other similar options consuming all
remaining arguments) should be placed at the end of the command line
help.

Currently jgit reset -h shows this:

jgit reset [commit-ish] [path ... ...] [-- path ... ...] [--hard]
[--help (-h)] [--mixed] [--soft]

After the patch the help shows this:

jgit reset [commit-ish] [path ... ...] [--hard] [--help (-h)] [--mixed]
[--soft] [-- path ... ...]

Bug: 484951
Change-Id: I3db332bf293ca8d6bfaab0d546cd35af689bd46e
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years agoreset command: provide convenient and meaningful options help 31/63331/4
Andrey Loskutov [Mon, 28 Dec 2015 20:59:01 +0000 (21:59 +0100)]
reset command: provide convenient and meaningful options help

This commit changes the jgit "reset" command line options help from
this:

jgit reset name [VAL ...] [-- path ... ...] [--hard] [--help (-h)]
[--mixed] [--soft]
 name        : Reset current HEAD to the specified state
 [...]

to this:

jgit reset [commit-ish] [path ... ...] [-- path ... ...] [--hard]
[--help (-h)] [--mixed] [--soft]
 commit-ish  : Reset to given reference name
 [...]

Bug: 484951
Change-Id: I614e71101b4f9f46ef8f02379d1a9d135f3292d2
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years agocommit command: allow to specify path(s) argument(s) 43/63343/3
Andrey Loskutov [Tue, 29 Dec 2015 12:58:58 +0000 (13:58 +0100)]
commit command: allow to specify path(s) argument(s)

This fixes the command below:

jgit commit a -m "added file a"

which currently fails with:

org.eclipse.jgit.api.errors.JGitInternalException: The combination of
arguments --all and --only is not allowed

Bug: 484973
Change-Id: I37a4ccd68101a66520ef99110f7aa0cbdcc8beba
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years agostatus command: consume more then one argument after -- 42/63342/3
Andrey Loskutov [Tue, 29 Dec 2015 12:18:12 +0000 (13:18 +0100)]
status command: consume more then one argument after --

See bug 484951 comment 4: "jgit status -- a b" doesn't work and
complains that "b" is not an allowed argument

Bug: 484951
Change-Id: I86b81e7f2bab6e928bb8e973bd50c8f4b9c6fecf
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years agorepo command: properly name the required 'path' argument 21/63321/4
Andrey Loskutov [Mon, 28 Dec 2015 17:14:05 +0000 (18:14 +0100)]
repo command: properly name the required 'path' argument

Fixes point 4 in bug 484951, where "jgit repo" or "jgit repo -h" dumps a
stack trace.

Bug: 484951
Change-Id: Ic8b362e07a40ad923dc9acde0c0983a1e7932a02
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years agoUn-ignored existing CLI tests which run just fine on Java 7+ 19/63319/5
Andrey Loskutov [Mon, 28 Dec 2015 17:03:45 +0000 (18:03 +0100)]
Un-ignored existing CLI tests which run just fine on Java 7+

Change-Id: I5ef334a49fb2d88d5e856b443687f3dcb126a77a
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years agoDon't treat command termination due '-h' option as a fatal error 30/63330/3
Andrey Loskutov [Mon, 28 Dec 2015 22:27:09 +0000 (23:27 +0100)]
Don't treat command termination due '-h' option as a fatal error

Signal early command termination due '-h' or '--help' option via
TerminatedByHelpException. This allows tests using
CLIGitCommand differentiate between unexpected command parsing errors
and expected command cancellation "on help" (which also allows
validation of expected/unexpected help messages).

Additional side-effect: jgit supports now git style of handling help
option: any unexpected command line options before help are reported as
errors, but after help ignored.

Bug: 484951
Change-Id: If45c41c0d32895ab6822a7ff9d851877dcef5771
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years agoProvide a root cause for aborted commands 20/63320/2
Andrey Loskutov [Mon, 28 Dec 2015 17:13:35 +0000 (18:13 +0100)]
Provide a root cause for aborted commands

Change-Id: Iafaa03dbacbe7f1b2b074d3294db988b08fdb0d7
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years agoSimplify development of commands: added main() to CLIGitCommand 15/63315/3
Andrey Loskutov [Mon, 28 Dec 2015 14:42:04 +0000 (15:42 +0100)]
Simplify development of commands: added main() to CLIGitCommand

This will execute git commands (with arguments) specified on the command
line, handy for developing/debugging a sequence of arbitrary git
commands working on same repository.

The git working dir path can be specified via Java system property
"git_work_tree". If not specified, current directory will be used.

Change-Id: I621a9ec198c31e28a383818efeb4b3f835ba1d6f
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years agoDirCacheEditor: Cleanup DeleteTree constructor 23/63323/1
Shawn Pearce [Thu, 24 Dec 2015 23:46:19 +0000 (15:46 -0800)]
DirCacheEditor: Cleanup DeleteTree constructor

Neaten up formatting and avoid strings, which prevents the need for
NLS comment tags.  Instead check the last character using char
literal, and append a char literal instead of a string.

Change-Id: Ib68e017769a1f5c03200354a805769d585a48c8b

8 years agoDirCacheEditor: Fix formatting to avoid , at start of line 22/63322/1
Shawn Pearce [Thu, 24 Dec 2015 23:38:02 +0000 (15:38 -0800)]
DirCacheEditor: Fix formatting to avoid , at start of line

Change-Id: I1b1d614470c67fe4736fdc9c26ae26fb38dd58b5

8 years agoMerge "AddCommand: Avoid unnecessary string conversions"
Shawn Pearce [Mon, 28 Dec 2015 19:24:30 +0000 (14:24 -0500)]
Merge "AddCommand: Avoid unnecessary string conversions"

8 years agoMerge "AddCommand: Cleanup conditional logic"
Christian Halstrick [Mon, 28 Dec 2015 13:39:06 +0000 (08:39 -0500)]
Merge "AddCommand: Cleanup conditional logic"

8 years agoAllow checkout paths without specifying branch name 79/62879/7
Andrey Loskutov [Wed, 16 Dec 2015 23:12:04 +0000 (00:12 +0100)]
Allow checkout paths without specifying branch name

JGit CLI should allow to do this: checkout -- <path>

Currently, even if "a" is a valid path in the git repo, jgit CLI can't
checkout it:
$jgit checkout -- a
error: pathspec 'a' did not match any file(s) known to git.

The fix also fixes at same time "unnamed" zombie "[VAL ...]" argument
shown on the command line.

Before fix:
$jgit -h
jgit checkout name [VAL ...] [-- path ... ...] [--force (-f)] [--help
(-h)] [--orphan] [-b]

After fix:
$jgit -h
jgit checkout [name] [-- path ... ...] [--force (-f)] [--help (-h)]
[--orphan] [-b]

Bug: 475765
Change-Id: I2b0e77959a72e4aac68452dc3846adaa745b0831
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years agoAddCommand: Avoid unnecessary string conversions 57/63257/4
Shawn Pearce [Thu, 24 Dec 2015 06:06:05 +0000 (22:06 -0800)]
AddCommand: Avoid unnecessary string conversions

Change-Id: I13634caeccd9f675a86adfdfa94099b6fb75463a

8 years agoAddCommand: Cleanup conditional logic 55/63255/1
Shawn Pearce [Thu, 24 Dec 2015 04:15:00 +0000 (20:15 -0800)]
AddCommand: Cleanup conditional logic

Unnest and simplify conditional logic for handling entries.

Change-Id: I3093cab5f0edfaf3efbbd6c644e9c922edc67d38

8 years agoClose copy threads in case of errors 17/63117/2
Dmitry Neverov [Mon, 21 Dec 2015 19:15:42 +0000 (20:15 +0100)]
Close copy threads in case of errors

Bug: 484775
Change-Id: I3c7105188e615b6b994261f4ece0c8abc98eb444
Signed-off-by: Dmitry Neverov <dmitry.neverov@gmail.com>
8 years agoSkip nested copyfiles in RepoCommand. 83/62983/8
Yuxuan 'fishy' Wang [Fri, 18 Dec 2015 02:27:56 +0000 (18:27 -0800)]
Skip nested copyfiles in RepoCommand.

Similar to nested directories, nested copyfiles won't work with git submodule
either.

Change-Id: Idbe965ec20a682fca0432802858162f8238f05de
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
8 years agoRemove unused import 'org.apache.commons.codec.binary' 15/62815/2
Rüdiger Herrmann [Wed, 16 Dec 2015 12:18:52 +0000 (13:18 +0100)]
Remove unused import 'org.apache.commons.codec.binary'

Change-Id: I7db35f4360e29d006d1e4e6ccfaa78ae598e3b4e
Signed-off-by: Rüdiger Herrmann <ruediger.herrmann@gmx.de>
8 years agoCheckout should be able to override modified symbolic links 40/62840/5
Andrey Loskutov [Wed, 16 Dec 2015 15:41:34 +0000 (16:41 +0100)]
Checkout should be able to override modified symbolic links

Handle existing symlink as a file, not as directory if deleting a file
before creating (overriding) a symlink.

Bug: 484491
Change-Id: I29dbf57d1daec2ba98454975b093e1d381d05196
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years agoMerge "ProgressSpinner: Simple busy wait entertainment"
Shawn Pearce [Wed, 16 Dec 2015 21:20:57 +0000 (16:20 -0500)]
Merge "ProgressSpinner: Simple busy wait entertainment"

8 years agoProgressSpinner: Simple busy wait entertainment 46/62846/2
Shawn Pearce [Fri, 4 Dec 2015 22:56:14 +0000 (14:56 -0800)]
ProgressSpinner: Simple busy wait entertainment

Keep a user amused while the server does work by spinning a
little ASCII-art object on a single line.

Change-Id: Ie8f181d1aa606d4ae69e5d3ca4db387cea739f38

8 years agoIncluded cached deltas in delta packStatistics. 64/62864/1
James Kolb [Tue, 15 Dec 2015 22:14:45 +0000 (17:14 -0500)]
Included cached deltas in delta packStatistics.

Previously, non-reuse deltas were only included in packStatistics if they
were not cached by the deltaWindow.

Change-Id: I7684d8214875f0a7569b34614f8a3ba341dbde9c
Signed-off-by: James Kolb <jkolb@google.com>
8 years agoMerge changes Ib4d53bdd,I55bd512c
Jonathan Nieder [Wed, 16 Dec 2015 17:09:48 +0000 (12:09 -0500)]
Merge changes Ib4d53bdd,I55bd512c

* changes:
  Do not let PathFilter.create("a/b") match 'a' unless 'a' is a subtree
  Add tests for PathFilterGroup.Single

8 years agoMerge "Fix InterruptTimer leak in BasePackConnection"
Shawn Pearce [Wed, 16 Dec 2015 15:29:01 +0000 (10:29 -0500)]
Merge "Fix InterruptTimer leak in BasePackConnection"

8 years agoMerge "Fix NPE in HttpSupport"
Shawn Pearce [Wed, 16 Dec 2015 15:28:05 +0000 (10:28 -0500)]
Merge "Fix NPE in HttpSupport"

8 years agoFix InterruptTimer leak in BasePackConnection 67/53767/4
Matthias Sohn [Fri, 14 Aug 2015 12:03:57 +0000 (14:03 +0200)]
Fix InterruptTimer leak in BasePackConnection

When setting timeout on push, BasePackConnection creates a timer, which
will be terminated when push finishes. But, when using
SmartHttpPushConnection, it dropped the first timer created in the
constructor and then created another timer in doPush. If new threads are
created faster than the gc collects then this may stop the service if
it's hitting the max process limit. Hence don't create a new timer if it
already exists.

Bug: 474947
Change-Id: I6746ffe4584ad919369afd5bdbba66fe736be314
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoFix NPE in HttpSupport 12/62112/3
Matthias Sohn [Wed, 2 Dec 2015 12:11:20 +0000 (13:11 +0100)]
Fix NPE in HttpSupport

Bug: 483366
Change-Id: I107f1b44e0e6371e3cfbd1cc18a970412e1fc679
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoMerge "Refspec: loosen restrictions on wildcard "*""
Shawn Pearce [Wed, 16 Dec 2015 04:22:11 +0000 (23:22 -0500)]
Merge "Refspec: loosen restrictions on wildcard "*""

8 years agoMerge "BaseRepositoryBuilder should trim CR from .git symref"
Shawn Pearce [Wed, 16 Dec 2015 04:18:13 +0000 (23:18 -0500)]
Merge "BaseRepositoryBuilder should trim CR from .git symref"

8 years agoMerge "Fix possible arithmetic overflow when setting a timeout"
Shawn Pearce [Wed, 16 Dec 2015 04:16:19 +0000 (23:16 -0500)]
Merge "Fix possible arithmetic overflow when setting a timeout"

8 years agoMerge "Accept UTF8 BOM with BlobBasedConfig"
Shawn Pearce [Wed, 16 Dec 2015 04:12:54 +0000 (23:12 -0500)]
Merge "Accept UTF8 BOM with BlobBasedConfig"

8 years agoMerge "Bug 484342: Support @ in username in SSH url."
Shawn Pearce [Wed, 16 Dec 2015 04:09:29 +0000 (23:09 -0500)]
Merge "Bug 484342: Support @ in username in SSH url."

8 years agoDo not let PathFilter.create("a/b") match 'a' unless 'a' is a subtree 91/62691/2
Jonathan Nieder [Tue, 15 Dec 2015 03:57:24 +0000 (19:57 -0800)]
Do not let PathFilter.create("a/b") match 'a' unless 'a' is a subtree

PathFilter and PathFilterGroup form JGit's implementation of git's
path-limiting feature in commands like log and diff.  To save time
when traversing trees, a path specification

foo/bar/baz

tells the tree walker not to traverse unrelated trees like qux/.  It
does that by returning false from include when the tree walker is
visiting qux and true when it is visiting foo.

Unfortunately that test was implemented to be slightly over-eager: it
doesn't only return true when asked whether to visit a subtree "foo"
but when asked about a plain file "foo" as well.  As a result, diffs
and logs restricted to some-file/non-existing-suffix unexpectedly
match against some-file:

 $ jgit log -- LICENSE/no-such-file
 commit 629fd0d594d242eab26161b0dac34f7576fd4d3d
 Author: Shawn O. Pearce <spearce@spearce.org>
 Date:   Fri Jul 02 14:52:49 2010 -0700

     Clean up LICENSE file
[...]

Fix it by checking against the entry's mode.

Gitiles +log has the same bug and benefits from the same fix.

Callers know not to worry about what subtrees are included in the tree
walk because shouldBeRecursive() returns true in this case, so this
behavior change should be safe.  This also better matches the behavior
of C git:

 $ empty=$(git mktree </dev/null)
 $ git diff-tree --abbrev $empty HEAD -- LICENSE/no-such-file
 $ git diff-tree --abbrev $empty HEAD -- tools/no-such-file
 :000000 040000 0000000... b62648d... A  tools

Bug: 484266
Change-Id: Ib4d53bddd8413a9548622c7b25b338d287d8889d

8 years agoAdd tests for PathFilterGroup.Single 90/62690/2
Jonathan Nieder [Tue, 15 Dec 2015 03:22:25 +0000 (19:22 -0800)]
Add tests for PathFilterGroup.Single

Expand the existing PathFilterGroup tests to check which paths the
tree entry matches.  This expands test coverage by ensuring that
PathFilterGroup's simpler code path to match against a single
PathFilter works correctly.

While at it, move the check on tree entry d/e/f/g.y into two separate
tests: one to check that it doesn't match any of the configured paths,
and another to check that it does not throw StopWalkException to end
the walk early.

Change-Id: I55bd512cd049fc2018659e2f86a4b8650f171fda

8 years agoBug 484342: Support @ in username in SSH url. 86/62686/4
Mike Gilbode [Tue, 15 Dec 2015 06:59:00 +0000 (01:59 -0500)]
Bug 484342: Support @ in username in SSH url.

Change-Id: I5795e925afff796488ba26c83694e806b76a374f
Signed-off-by: Mike Gilbode <gilbode@gmail.com>
8 years agoFix push with jgit pgm failing with "unauthorized" 20/62120/4
Matthias Sohn [Fri, 27 Nov 2015 10:46:21 +0000 (11:46 +0100)]
Fix push with jgit pgm failing with "unauthorized"

Pushing with JGit commandline to e.g. Github failed with "unauthorized"
since HttpUrlConnection calls the configured authenticator implicitly.

The problem is that during a push two requests are sent to the server,
first a GET and then a POST (containing the pack data). The first GET
request sent anonymously is rejected with 401 (unauthorized). When an
Authenticator is installed the java.net classes will use the
Authenticator to ask the user for credentials and retry the request.
But this happens under the hood and JGit level code doesn't see that
this happens.

The next request is the POST but since JGit thinks the first GET request
went through anonymously it doesn't add authentication headers to the
POST request. This POST of course also fails with 401 but since this
request contains a lot of body-data streamed from JGit (the pack file!)
the java.net classes can't simply retry the request with authorization
headers. The whole process fails.

Fix this by using Apache httpclient which doesn't use Authenticator to
retrieve credentials. Instead initialize TransportCommand to use the
default credential provider if no other credentials provider was set
explicitly. org.eclipse.jgit.pgm.Main sets this default for the JGit
command line client.

Change-Id: Ic4e0f8b60d4bd6e69d91eae0c7e1b44cdf851b00
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoEnable retrieval of credentials from .netrc for AwtCredentialsProvider 19/62119/3
Matthias Sohn [Fri, 27 Nov 2015 10:26:38 +0000 (11:26 +0100)]
Enable retrieval of credentials from .netrc for AwtCredentialsProvider

This was done for ConsoleCredentialsProvider earlier, we need the
AwtCredentialsProvider for debugging jgit command line since there is no
console in Eclipse. Hence also add support for .netrc here.

Change-Id: Ibbd45b73efc663821866754454cea65e6d03f832
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoMerge "NetRCCredentialsProvider should return false if any item is missing"
Christian Halstrick [Tue, 15 Dec 2015 11:44:07 +0000 (06:44 -0500)]
Merge "NetRCCredentialsProvider should return false if any item is missing"

8 years agoMerge "Fix ChainingCredentialsProvider"
Christian Halstrick [Tue, 15 Dec 2015 08:52:07 +0000 (03:52 -0500)]
Merge "Fix ChainingCredentialsProvider"

8 years agoFix possible arithmetic overflow when setting a timeout 92/62692/2
Christian Halstrick [Tue, 15 Dec 2015 08:24:07 +0000 (09:24 +0100)]
Fix possible arithmetic overflow when setting a timeout

BasePackPushConnection#readStringLongTimeout() was setting a timeout 10
times bigger than some other timeout or the pack transfer time. This
could lead to negative integer values when we hit an arithmetic
overflow. Add a check for this situation and set the timeout to
Integer.MAX_VALUE when overflow happens.

Bug: 484352
CC: Eugene Petrenko <eugene.petrenko@gmail.com>
Change-Id: Ie2a86312c1bcb1ec3e6388fa490ab3c845d41808

8 years agoNull-annotated Ref class and fixed related compiler errors 09/61509/7
Andrey Loskutov [Fri, 27 Nov 2015 23:15:36 +0000 (00:15 +0100)]
Null-annotated Ref class and fixed related compiler errors

This change fixes all compiler errors in JGit and replaces possible
NPE's with either appropriate exceptions, avoiding multiple "Nullable
return" method calls or early returning from the method.

Change-Id: I24c8a600ec962d61d5f40abf73eac4203e115240
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years agoMerge "push: Do not blindly overwrite peer"
Shawn Pearce [Mon, 14 Dec 2015 22:45:56 +0000 (17:45 -0500)]
Merge "push: Do not blindly overwrite peer"

8 years agopush: Do not blindly overwrite peer 50/62650/2
Shawn Pearce [Mon, 14 Dec 2015 04:26:01 +0000 (20:26 -0800)]
push: Do not blindly overwrite peer

If an application uses PushConnection directly on the native Git wire
protocols JGit should send along the application's expected oldId, not
the advertised value.  This allows the remote peer to compare-and-swap
since it was not tested inside JGit.

Discovered when I tried to use a PushConnection (bypassing the
standard PushProcess) and the client blindly overwrote the remote
reference, even though my app had supplied the wrong ObjectId for
the expectedOldObjectId. This was not expected and cost me over an
hour of debugging, plus "corruption" in the remote repository.

By passing along the exact expectedOldObjectId from the app the
remote side can do the check that the application skipped, and
avoid data loss.

Change-Id: Id3920837e6c47100376225bb4dd61fa3e88c64db

8 years agoFix FileTreeIterator.idSubmodule(Entry) 26/61826/2
Christian Halstrick [Wed, 2 Dec 2015 08:16:03 +0000 (09:16 +0100)]
Fix FileTreeIterator.idSubmodule(Entry)

FileTreeIterator was calling by mistake
WorkingTreeIterator.idSubmodule(Entry). Instead it should always compute
idSubmodule on its own.

Change-Id: Id1b988aded06939b1d7edd2671e34bf756896c0e

8 years agoURIish: fixed full uri pattern not expecting end of line after host name 96/61596/3
Andrey Loskutov [Mon, 30 Nov 2015 21:48:13 +0000 (22:48 +0100)]
URIish: fixed full uri pattern not expecting end of line after host name

Bug: 483326
Change-Id: I8b6e3eb648c8ec2c38f73de22382537b1276b779
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years agoAdd remote command to JGit CLI 53/59553/5
Kaloyan Raev [Mon, 6 Jan 2014 12:40:47 +0000 (14:40 +0200)]
Add remote command to JGit CLI

Supported subcommands are:
 - <none> (lists available remotes)
 - add
 - remove
 - set-url
 - update

Supported options are:
 --verbose
 --push
 --prune

Bug: 481316
Change-Id: I57c34ed6daabb7d308bc383b17c1ef4af433e714
Signed-off-by: Kaloyan Raev <kaloyan.r@zend.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoAccept UTF8 BOM with BlobBasedConfig 56/62356/1
Doug Kelly [Wed, 9 Dec 2015 22:36:37 +0000 (16:36 -0600)]
Accept UTF8 BOM with BlobBasedConfig

In I1f5dc07182dbf6bba2a9f4807fdd25b475da4ead, FileBasedConfig got
support for reading a configuration with UTF8 BOM.  Apply the same
support to BlobBasedConfig, to make SubmoduleWalk able to parse
.gitmodules configurations with BOM.

Change-Id: I25b5474779952fe2c076180b96fc2869eef190a8
Signed-off-by: Doug Kelly <dougk.ff7@gmail.com>
8 years agoNetRCCredentialsProvider should return false if any item is missing 07/62207/1
Matthias Sohn [Tue, 8 Dec 2015 13:11:43 +0000 (14:11 +0100)]
NetRCCredentialsProvider should return false if any item is missing

Change-Id: I894d1621aaccd71dfe100fe83a1bd9d50a1e0808

8 years agoFix ChainingCredentialsProvider 18/62118/2
Matthias Sohn [Fri, 27 Nov 2015 10:23:42 +0000 (11:23 +0100)]
Fix ChainingCredentialsProvider

The ChainingCredentialsProvider gave up chaining to the next provider if
the first one returned no credentials items for the given URI.

Change-Id: I9539c50db35e564db9d43d8ebb71d7e9c6fdcc19
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoMerge "Fix NPE in HttpAuthMethod"
Christian Halstrick [Tue, 8 Dec 2015 07:25:34 +0000 (02:25 -0500)]
Merge "Fix NPE in HttpAuthMethod"

8 years agoUse runtime retention for Nullable annotation 48/62148/5
Jonathan Nieder [Mon, 7 Dec 2015 20:56:32 +0000 (12:56 -0800)]
Use runtime retention for Nullable annotation

JGit's Nullable type was added[1] in the hope of being able to add
nullness annotations that (a) do not preclude building and running
with Java 7 and (b) could be shared by Gerrit, which uses a custom
Nullable type for other reasons[2].  Sharing a type is useful because
Eclipse's null analysis is only able to use one Nullable type at a
time in a given workspace (so for this analysis to function in a
workspace used to develop Gerrit, JGit and Gerrit would need to use
the same Nullable type).

The new Nullable type has CLASS instead of RUNTIME retention because
there wasn't any obvious use for the annotation at run time.

Gerrit uses the Nullable annotation to communicate with Guice.  Guice
injection happens at runtime, so it needs to be able to read the
@Nullable annotations at run time[3].  Otherwise Guice produces
provisioning errors, such as

 3) null returned by binding at com.google.gerrit.lucene.LuceneChangeIndex$Factory.create()
  but parameter 7 of com.google.gerrit.lucene.LuceneChangeIndex.<init>() is not @Nullable

Switch to RUNTIME retention to avoid this.

While at it, update the javadoc to explain more clearly how this
annotation relates to other Nullable types[4].  This should make it
clearer why JGit needed another Nullable type:

 A. Avoiding dependency on Java 8
 B. RUNTIME retention to allow Guice to read the annotation at run time
 C. Named Nullable so Guice can recognize the annotation
 D. Not an addition to Java EE's javax.annotation package, to avoid
    the split-package problem[2] that prevents the annotation from
    being readable at run time when loaded from an OSGi container
 E. Avoiding heavyweight dependencies, deprecated dependencies, and
    dependencies on package internals

 org.checkerframework.checker.nullness.qual.Nullable: A
 com.sun.istack.internal.Nullable: B, E
 *.CheckForNull, *.NullAllowed, etc: C
 edu.umd.cs.findbugs.annotations.Nullable: B, E
 javax.annotation.Nullable: D
 org.eclipse.jdt.annotation.Nullable: B
 org.jetbrains.annotations.Nullable: B
 org.jmlspecs.annotation.Nullable: E
 android.annotation.Nullable, android.support.annotation.Nullable: E

[1] https://git.eclipse.org/r/59993
[2] https://gerrit-review.googlesource.com/50112
[3] https://github.com/google/guice/blob/master/core/src/com/google/inject/internal/Nullability.java
[4] https://github.com/typetools/checker-framework/blob/5832a01f1/checker/src/org/checkerframework/checker/nullness/NullnessAnnotatedTypeFactory.java#L118
    http://types.cs.washington.edu/checker-framework/current/checker-framework-manual.html#nullness-related-work

Change-Id: I6c482653d2b53e3509abb11211b67fc29cf2949c
Signed-off-by: Jonathan Nieder <jrn@google.com>
8 years agoFix NPE in HttpAuthMethod 17/62117/1
Matthias Sohn [Fri, 27 Nov 2015 10:02:32 +0000 (11:02 +0100)]
Fix NPE in HttpAuthMethod

If the password char array is null constructing a new String from this
array fails with a NPE. Add a null check to fix this.

Change-Id: Ifae6eecca38d5f114861f44658a32521e6e96866
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoSupport atomic push in JGit client 41/61841/2
Shawn Pearce [Thu, 3 Dec 2015 05:47:58 +0000 (21:47 -0800)]
Support atomic push in JGit client

This should mirror the behavior of `git push --atomic` where the
client asks the server to apply all-or-nothing. Some JGit servers
already support this based on a custom DFS backend. InMemoryRepository
is extended to support atomic push for unit testing purposes.

Local disk server side support inside of JGit is a more complex animal
due to the excessive amount of file locking required to protect every
reference as a loose reference.

Change-Id: I15083fbe48447678e034afeffb4639572a32f50c

8 years agoFix wrong @since tag In ReceiveCommand 81/61781/1
Matthias Sohn [Wed, 2 Dec 2015 14:24:26 +0000 (15:24 +0100)]
Fix wrong @since tag In ReceiveCommand

Change-Id: I58fa657dd4783fed0ffca94020c87c49d99009c6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoReceiveCommand.filter: Accept Iterable 12/61712/1
Shawn Pearce [Tue, 1 Dec 2015 22:20:44 +0000 (14:20 -0800)]
ReceiveCommand.filter: Accept Iterable

PreReceiveHook is given a Collection<ReceiveCommand> and it can be
very useful here to call ReceiveCommand.filter(cmds, NOT_ATTEMPTED).

Overload filter to accept both Iterable and List.
Keep backwards binary compatibility for List by upcasting to Iterable.

Change-Id: Ib1341876c703670945ef209edc8259715ee86c26

8 years agoMerge changes If1490ca2,Ife950253
Shawn Pearce [Tue, 1 Dec 2015 00:03:10 +0000 (19:03 -0500)]
Merge changes If1490ca2,Ife950253

* changes:
  DirCacheBuilder: Speed up reading from trees
  Delay locating .gitattributes until requested

8 years agoDirCacheBuilder: Speed up reading from trees 18/61518/7
Shawn Pearce [Sat, 28 Nov 2015 17:23:59 +0000 (09:23 -0800)]
DirCacheBuilder: Speed up reading from trees

Recursively copying a tree into a DirCache is a bottleneck for some
algorithms like the in memory merge code in Gerrit Code Review.  Drop
a layer down in the stack and use CanonicalTreeParser directly as the
addition logic only processes 1 tree at a time and does not need the
merge sorting feature (or overhead) of TreeWalk.

Combined with 761814fe9c ("DirCacheEntry: Speed up creation by
avoiding string cast") tree loading 38,900 entries nearly halves
in running time from 70ms to 36ms on some platforms.

Change-Id: If1490ca25de0679a71cf508f59b486f9cc816165

8 years agoDirCache: Add helper to read from a tree 20/61520/3
Shawn Pearce [Sat, 28 Nov 2015 20:34:55 +0000 (12:34 -0800)]
DirCache: Add helper to read from a tree

Application code sometimes wants to read a DirCache from an ObjectId,
but its confusing how to do this because its buried inside the
DirCacheBuilder.

Use this utility in a few places within JGit that also want to read
a DirCache from a tree's ObjectId.

Change-Id: I578b7e18e58753d154937f4ab835012b09e5adca

8 years agoDelay locating .gitattributes until requested 22/61522/5
Shawn Pearce [Sun, 29 Nov 2015 20:04:03 +0000 (12:04 -0800)]
Delay locating .gitattributes until requested

Instead of checking every entry for .gitattributes only look for the
entry on request by TreeWalk.  This avoids impacting uses like RevWalk
filtering history.

When the attrs is requested skip to the start of the tree and look for
.gitattributes until either it is found, or it is impossible to be
present.  Due to the sorting rules of tree entries .gitattributes
should be among the first or second entries in the tree so very few
entries will need to be considered.

Waiting to find the .gitattributes file by native ordering may miss
attrs for files like .config, which sorts before .gitattributes.
Starting from the front of the tree on demand ensures the attributes
are parsed as early as necessary to process any entry in the tree.

Due to TreeWalk recursively processing up the tree of iterators we
cannot just reset the current CanonicalTreeParser to the start as
parent parsers share the same path buffer as their children.
Resetting a parent to look for .gitattributes may overwrite path
buffer data used by a child iterator.  Work around this by building a
new temporary CanonicalTreeParser instance.

Change-Id: Ife950253b687be325340d27e9915c9a40df2641c

8 years agoDirCache: Fix bad code formatting 17/61517/1
Shawn Pearce [Sat, 28 Nov 2015 17:21:31 +0000 (09:21 -0800)]
DirCache: Fix bad code formatting

Line breaking before , is ugly to read.  Most formatters and humans
expect line break after , so update a few offensive locations.

Use String.format() for the construction of the error message when
a bad DirCachEntry is being failed on. This simplifies the code and
its not a performance critical section.

Change-Id: I5d990389e7ba24ef0861cf8ec0026ed030d4aeda

8 years agoDirCacheEntry: Speed up creation by avoiding string cast 16/61516/1
Shawn Pearce [Sat, 28 Nov 2015 16:58:15 +0000 (08:58 -0800)]
DirCacheEntry: Speed up creation by avoiding string cast

The checkPath function is available as a byte[] form, in fact the
String form just converts to byte[] to run the algorithm.

Having DirCacheEntry take a byte[] -> String -> byte[] to check if
each path is valid is a huge waste of CPU time. On some systems it
can double the time required to read 38,999 files from trees to the
DirCache. This slows down any operation using a DirCache.

Expose the byte[] form and use it for DirCacheEntry creation.

Change-Id: I6db7bc793ece99ff3c356338d793c07c061aeac7

8 years agoDirCache: Fix getEntriesWithin("") to not include null entries 13/61513/1
Shawn Pearce [Sat, 28 Nov 2015 05:34:16 +0000 (21:34 -0800)]
DirCache: Fix getEntriesWithin("") to not include null entries

The internal array may be longer than entryCnt, in this case the tail
of the array is padded with null entries. Do not return those to the
caller of getEntriesWithin().

Change-Id: I19efb05e103fab6b739ced407f6e28155a48dba6

8 years agoFix performance regression in CanonicalTreeParser 12/61512/1
Shawn Pearce [Sat, 28 Nov 2015 07:21:33 +0000 (23:21 -0800)]
Fix performance regression in CanonicalTreeParser

Change-Id: I14046559fddb9656d890d3099010117e84cd9439

8 years agoAdd support for smudge filters 19/59319/16
Christian Halstrick [Thu, 29 Oct 2015 13:15:08 +0000 (14:15 +0100)]
Add support for smudge filters

If defined in .gitattributes call smudge filter during checkout.

To support checkout where current HEAD,index do not contain attributes
we need to also consider attributes from the tree we checkout. Therefore
CanonicalTreeParser has to learn how to provide attributes.

Change-Id: I168fdb81a8e1a9f991587b3e95a36550ea845f0a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoAdd support for clean filters 72/50372/25
Christian Halstrick [Wed, 28 Oct 2015 12:25:09 +0000 (13:25 +0100)]
Add support for clean filters

When filters are defined for certain paths in gitattributes make
sure that clean filters are processed when adding new content to the
object database.

Change-Id: Iffd72914cec5b434ba4d0de232e285b7492db868
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoAdd the new class Attributes holding multiple Attribute(s) 01/60601/10
Ivan Motsch [Tue, 17 Nov 2015 12:32:20 +0000 (13:32 +0100)]
Add the new class Attributes holding multiple Attribute(s)

Attributes represents a semantic collector of Attribute(s) and replaces
the anonymous Map<String,Attribute>. This class will be returned by
TreeWalk.getAttributes(). It offers convenient access to the attributes
wrapped in the Attributes object. Adds preparations for a future
Attribute Macro Expansion

Change-Id: I8348c8c457a2a7f1f0c48050e10399b0fa1cdbe1
Signed-off-by: Ivan Motsch <ivan.motsch@bsiag.com>
9 years agoFix unit tests on Windows 03/61203/2
Christian Halstrick [Tue, 24 Nov 2015 14:16:42 +0000 (15:16 +0100)]
Fix unit tests on Windows

PushCommandTest and RunExternalScriptTest didn't succeed on Windows.
Fix this by expecting a simple line-feed as line ending (instead of the
platform dependent line separator. Additionally correct the computation
of expected URLs in PushCommandTest.

Change-Id: Idcdc41cd7e535ff88df33ea0a249333ed8fc91b0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
9 years agoAdd missing @since tags and missing javadoc 00/61300/2
Matthias Sohn [Wed, 25 Nov 2015 23:32:37 +0000 (00:32 +0100)]
Add missing @since tags and missing javadoc

Change-Id: I8575797127fc96abea8af56f019ca39f5897486f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
9 years agoFix HookTest when running on Win32_Cygwin 18/60918/3
Christian Halstrick [Fri, 20 Nov 2015 13:38:24 +0000 (14:38 +0100)]
Fix HookTest when running on Win32_Cygwin

This test expected that the test scripts emit a platform-dependent
newline (crlf on windows, lf on linux). But that's not true. Expected
result should always be a trailing "\n" because the test scripts
explicitly echo a "\n" in the end.

Change-Id: I604e08cda8cebe276b5214ba0f618b6112c3441f

9 years agoFix FS.runProcess() to close the InputStream 65/61165/2
Christian Halstrick [Tue, 24 Nov 2015 10:18:59 +0000 (11:18 +0100)]
Fix FS.runProcess() to close the InputStream

When FS.runProcess was called and an InputStream was given the method
tried to pump the whole InputStream to the process. When the method
ended the InputStream was not giving any data anymore. Consequently
close the InputStream inside the method.

Change-Id: I0ed738a775e5c977b21447d195acee1ecf5e2cb9

9 years agorepo: Do not use search path to find refs/remotes/origin/<branch> 53/60853/5
Jonathan Nieder [Thu, 19 Nov 2015 20:47:18 +0000 (12:47 -0800)]
repo: Do not use search path to find refs/remotes/origin/<branch>

When running from a non-bare repository, "jgit repo" checks whether
the rev passed in is a sha1 or branch name and in the latter case will
check out origin/<branch>.

We are expecting refs/remotes/origin/<branch>, but as a side effect of
using getRef we also end up looking for refs/origin/<branch>,
refs/heads/origin/<branch>, and so on.  Avoid that by using exactRef
instead.

Signed-off-by: Jonathan Nieder <jrn@google.com>
Change-Id: I670b2e48a88138a1f2104ea201baa958e9edbddb

9 years agoRepository: Introduce exactRef and findRef, deprecate getRef 74/49574/7
Jonathan Nieder [Fri, 5 Jun 2015 22:20:24 +0000 (15:20 -0700)]
Repository: Introduce exactRef and findRef, deprecate getRef

The Repository class provides only one method to look up a ref by
name, getRef.  If I request refs/heads/master and that ref does not
exist, getRef will look further in the search path:

 ref/refs/heads/master
 refs/heads/refs/heads/master
 refs/remotes/refs/heads/master

This behavior is counterintuitive, needlessly inexpensive, and usually
not what the caller expects.

Allow callers to specify whether to use the search path by providing
two separate methods:

- exactRef, which looks up a ref when its exact name is known
- findRef, which looks for a ref along the search path

For backward compatibility, keep getRef as a deprecated synonym for
findRef.

This change introduces findRef and exactRef but does not update
callers outside tests to use them yet.

Change-Id: I35375d942baeb3ded15520388f8ebb9c0cc86f8c
Signed-off-by: Jonathan Nieder <jrn@google.com>
9 years agoNull-annotated RefDatabase class 90/61290/1
Andrey Loskutov [Wed, 25 Nov 2015 20:19:05 +0000 (21:19 +0100)]
Null-annotated RefDatabase class

No other code changes except adding nullness annotations.

Change-Id: If2606fb208f6690bd4fd7ad953e709a3ebd6398c
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
9 years agoNull-annotated Repository class and fixed related compiler errors 42/60442/7
Andrey Loskutov [Sun, 15 Nov 2015 22:59:41 +0000 (23:59 +0100)]
Null-annotated Repository class and fixed related compiler errors

org.eclipse.jgit.lib.Repository class is an example of the API which
should be written with Java 8 java.util.Optional<T> type. Unfortunately
this API is already released and widely used. The good clients are
currently doing their best with checking return values for null and bad
clients do not know how bad their code is.

I've tried not to change any logic and to be as less intrusive as
possible. Most of the JGit code was well prepared to this, only few
classes needed some smaller fixes.

This change fixes all compiler errors in JGit and replaces possible
NPE's with either appropriate exceptions, avoiding multiple "Nullable
return" method calls or early returning from the method.

Because annotating getDirectory() and getFS() as Nullable would cause
lot of additional changes in JGit and EGit they are postponed.

Change-Id: Ie8369d2c9c5fac5ce83b3b1b9bc217d7b55502a3
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
9 years agoRaise error if FileNotFoundException is caught for an existing file 39/60939/5
Matthias Sohn [Fri, 20 Nov 2015 13:40:41 +0000 (14:40 +0100)]
Raise error if FileNotFoundException is caught for an existing file

File, FileInputStream and friends may throw FileNotFoundException even
if the file is existing e.g. when file permissions don't allow to access
the file content. In most cases this is a severe error we should not
suppress hence rethrow the FileNotFoundException in this case.

This may also fix bug 451508.

Bug: 451508
Change-Id: If4a94217fb5b7cfd4c04d881902f3e86193c7008
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
9 years agoMerge "RefDirectory.getRef: Treat fake missing symrefs like real ones"
Jonathan Nieder [Tue, 24 Nov 2015 20:43:05 +0000 (15:43 -0500)]
Merge "RefDirectory.getRef: Treat fake missing symrefs like real ones"

9 years agoLet FS_Win32_Cygwin detect symlink support by creating temporary symlink 17/60917/2
Christian Halstrick [Fri, 20 Nov 2015 13:33:15 +0000 (14:33 +0100)]
Let FS_Win32_Cygwin detect symlink support by creating temporary symlink

The class FS_Win32 was always trying out to create a temporary symlink
in order to find out whether symlinks are supported. FS_Win32_Cygwin was
overwriting this method and always returned true. But when the user
running JGit does not have administrative rights then the creation of
symlinks is forbidden even if he is running on FS_Win32_Cygwin. A lot of
tests failed only on the Windows platform because of this. It was
correctly detected that FS_Win32_Cygwin is the filesystem abstraction to
be used but creation of symlinks always failed because of lacking
privileges of the user running the tests.

This fix teaches FS_Win32_Cygwin to behave like FS_Win32 and to test
whether symlinks can be created in order to find out whether symlinks
are supported.

Change-Id: Ie2394631ffc4c489bd37c3ec142ed44bbfcac726
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
9 years agoFix classpath of test launch configurations 62/60762/3
Matthias Sohn [Wed, 18 Nov 2015 23:47:05 +0000 (00:47 +0100)]
Fix classpath of test launch configurations

Remove references to the bundle org.eclipse.jgit.java7 which was removed
in 4.0.

Change-Id: I85527eb2a34bb94979fdab1311043ae77a2b5ecd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
9 years agoAvoid UnknownHostException in WalkEncryptionTest 87/60187/4
Matthias Sohn [Thu, 12 Nov 2015 10:28:01 +0000 (11:28 +0100)]
Avoid UnknownHostException in WalkEncryptionTest

Prevent that WalkEncryptionTest fails when it can't determine the public
IP address using http://checkip.amazonws.com. Also set timeouts when
determining IP address in order to prevent long wait times during tests.

Change-Id: I1d2fe09f99df2a5f75f8077811a72fb2271cdddb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
9 years agoRemove no longer needed outdated API warning filter 57/60957/2
Matthias Sohn [Fri, 20 Nov 2015 23:18:14 +0000 (00:18 +0100)]
Remove no longer needed outdated API warning filter

This fixes a warning saying this filter isn't needed anymore.

Change-Id: If77056378befe86c1773950dbe48a82c833fd532
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
9 years agoRefDirectory.getRef: Treat fake missing symrefs like real ones 07/60107/3
Jonathan Nieder [Wed, 11 Nov 2015 00:34:00 +0000 (16:34 -0800)]
RefDirectory.getRef: Treat fake missing symrefs like real ones

getRef() loops over its search path to find a ref:

Ref ref = null;
for (String prefix : SEARCH_PATH) {
ref = readRef(prefix + needle, packed);
if (ref != null) {
ref = resolve(ref, 0, null, null, packed);
break;
}
}
fireRefsChanged();
return ref;

If readRef returns null (indicating that the ref does not exist), the
loop continues so we can find the ref later in the search path.  And
resolve should never return null, so if we return null it should mean
we exhausted the entire search path and didn't find the ref.

... except that resolve can return null: it does so when it has
followed too many symrefs and concluded that there is a symref loop:

if (MAX_SYMBOLIC_REF_DEPTH <= depth)
return null; // claim it doesn't exist

Continue the loop instead of returning null immediately.  This makes
the behavior more consistent.

Arguably getRef should throw an exception when a symref loop is
detected.  That would be a more invasive change, so if it's a good
idea it will have to wait for another patch.

Change-Id: Icb1c7fafd4f1e34c9b43538e27ab5bbc17ad9eef
Signed-off-by: Jonathan Nieder <jrn@google.com>
9 years agoMerge "git rev-parse: Add --verify option"
Jonathan Nieder [Thu, 19 Nov 2015 22:49:17 +0000 (17:49 -0500)]
Merge "git rev-parse: Add --verify option"

9 years agogit rev-parse: Add --verify option 36/60836/4
Thomas Meyer [Thu, 19 Nov 2015 22:14:03 +0000 (23:14 +0100)]
git rev-parse: Add --verify option

Add the --verify option to be more compatible with git

Change-Id: I225a36ecc4711fd2eb9af67ca8fb79681d94c587
Signed-off-by: Thomas Meyer <thomas.mey@web.de>
9 years agoThrow IndexReadException if existing index can't be read 99/60799/2
Christian Halstrick [Thu, 19 Nov 2015 16:21:46 +0000 (17:21 +0100)]
Throw IndexReadException if existing index can't be read

If the index file exists but can't be read for example because of wrong
filesystem permissions we should throw a specific exception. This allows
EGit to handle this error situation.

Bug: 482607
Change-Id: I50bfcb719c45caac3cb5550a8b16307c2ea9def4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
9 years agoFix pre-push hook to not set null remoteName as first argument 32/60632/3
Matthias Sohn [Tue, 17 Nov 2015 16:26:53 +0000 (17:26 +0100)]
Fix pre-push hook to not set null remoteName as first argument

According to [1] the pre-push hook expects two parameters which provide
the name and location of the destination remote, if a named remote is
not being used both values should be the same.

We did set the first parameter to null in that case which caused
ProcessBuilder to throw a NullPointerException since its start() method
doesn't accept null arguments.

[1] https://git-scm.com/docs/githooks#_pre_push

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