]> source.dussan.org Git - jgit.git/log
jgit.git
8 years agobuck: Make :jgit_src target work in cross-cell environment 43/63443/2
David Ostrovsky [Sun, 3 Jan 2016 23:44:07 +0000 (00:44 +0100)]
buck: Make :jgit_src target work in cross-cell environment

This artifact is used from unzip utility in Gerrit Code Review
build toolchain and thus the file must exist on the file system.
Moreover, trying to use java_binary() didn't work either, as the
zip layout was wrong: all files contained 'org.eclipse.jgit/src/'
prefix.

Change-Id: I00e3269a7a1a6c6d1fe7e60d1bf1c69b8e57d79d
Signed-off-by: David Ostrovsky <david@ostrovsky.org>
8 years agoMerge changes I487a30fb,I82a01b5f
Shawn Pearce [Sun, 3 Jan 2016 23:24:33 +0000 (18:24 -0500)]
Merge changes I487a30fb,I82a01b5f

* changes:
  Ensure all http tests are run and fix broken tests
  buck: run http tests

8 years agoMerge "buck: set Bundle-Version for :jgit_bin"
Shawn Pearce [Sun, 3 Jan 2016 18:22:57 +0000 (13:22 -0500)]
Merge "buck: set Bundle-Version for :jgit_bin"

8 years agobuck: set Bundle-Version for :jgit_bin 32/63432/1
Shawn Pearce [Sun, 3 Jan 2016 17:30:16 +0000 (09:30 -0800)]
buck: set Bundle-Version for :jgit_bin

Run git describe during the build to determine the lineage of this
working directory and stamp this information into the binary.

Change-Id: I0ad24125c31e4280ccf900bac4065924087b05aa

8 years agoMerge changes Idaed9310,I62bd7c0b
Matthias Sohn [Sun, 3 Jan 2016 15:27:36 +0000 (10:27 -0500)]
Merge changes Idaed9310,I62bd7c0b

* changes:
  ObjectChecker: honor some git-core fsck.* options
  ObjectChecker: allow some objects to skip errors

8 years agobranch command: provide convenient and meaningful options help 32/63332/6
Andrey Loskutov [Mon, 28 Dec 2015 14:47:36 +0000 (15:47 +0100)]
branch command: provide convenient and meaningful options help

Added tests for all options, fixed multi-valued options parsing.

Bug: 484951
Change-Id: I5558589049544ea6c84932bc01f1f9df09e1f682
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years agoSimplify pgm tests: allow varargs and trim output for toString() 15/63415/1
Andrey Loskutov [Sat, 2 Jan 2016 12:24:02 +0000 (13:24 +0100)]
Simplify pgm tests: allow varargs and trim output for toString()

Change-Id: Ia5bcd9e560b90cf872fef75c2800c889ef1cc85a
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years agoFixed few locale dependent pgm tests 14/63414/1
Andrey Loskutov [Sat, 2 Jan 2016 16:32:11 +0000 (17:32 +0100)]
Fixed few locale dependent pgm tests

See https://dev.eclipse.org/mhonarc/lists/jgit-dev/msg03040.html

Change-Id: If51f3c750684d82cb6443f1578636c9f5ca56e2b
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years agoEnsure all http tests are run and fix broken tests 09/63409/1
Matthias Sohn [Sat, 2 Jan 2016 01:09:16 +0000 (02:09 +0100)]
Ensure all http tests are run and fix broken tests

HttpClientTests were broken. This wasn't discovered since
maven-surefire-plugin's by default only executes test classes
matching **/*Test.java. Fix this by also including **/*.Tests.java
and fix the failing tests.

Change-Id: I487a30fb333de993a9f8d8fff491d3b0e7fb02cc
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agobuck: run http tests 08/63408/1
Matthias Sohn [Fri, 1 Jan 2016 22:54:15 +0000 (23:54 +0100)]
buck: run http tests

Running tests using buck reveals that HttpClientTests are broken
and weren't executed by Maven since these test classes don't match the
maven-surefire-plugin's default for test classes **/*Test.java.
Will be fixed in a follow-up change.

Change-Id: I82a01b5fd3f0a930bec2423a29a256601dadc248
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agobuck: set vm_args for tests 07/63407/1
Shawn Pearce [Fri, 1 Jan 2016 19:04:11 +0000 (11:04 -0800)]
buck: set vm_args for tests

Maven pom files force the local encoding to UTF-8 to ensure there are
no differences between machines.  They also set the JVM max heap to
256m. Match both in Buck so that results are consistent.

Change-Id: Ice5476dd09352a444a0c97aa0dc28806fddf2ab4

8 years agobuck: pin to stable version 06/63406/1
Shawn Pearce [Fri, 1 Jan 2016 04:07:03 +0000 (20:07 -0800)]
buck: pin to stable version

Like with Gerrit, pin JGit to a single version of Buck that is known
to work with current Buck files and JUnit tests. Notably a more recent
version of Buck used by Gerrit (01a0c54d827) fails WalkEncryptionTest.

Change-Id: I6b94c332e4bde97a1910f48cf12eb8698f97d540

8 years agoMerge changes from topic 'add-df'
Shawn Pearce [Fri, 1 Jan 2016 17:58:34 +0000 (12:58 -0500)]
Merge changes from topic 'add-df'

* changes:
  DirCache: Do not create duplicate tree entries
  DirCacheEditor: Replace file-with-tree and tree-with-file
  AddCommand: Use NameConflictTreeWalk to identify file-dir changes

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 agoObjectChecker: honor some git-core fsck.* options 71/63371/4
Shawn Pearce [Wed, 30 Dec 2015 02:21:19 +0000 (18:21 -0800)]
ObjectChecker: honor some git-core fsck.* options

Accept some of the same section keys that fsck does in git-core,
allowing repositories to skip over specific kinds of acceptable
broken objects, e.g.:

  [fsck]
    duplicateEntries = ignore
    zeroPaddedFilemode = ignore

The zeroPaddedFilemode = ignore is a synonym for the JGit specific
allowLeadingZeroFileMode = true. Only accept the JGit key if git-core
key was not specified.

Change-Id: Idaed9310e2a5ce5511670ead1aaea2b30aac903c

8 years agoObjectChecker: allow some objects to skip errors 63/63363/4
Shawn Pearce [Tue, 29 Dec 2015 23:52:16 +0000 (15:52 -0800)]
ObjectChecker: allow some objects to skip errors

Some ancient objects may be broken, but in a relatively harmless way.
Allow the ObjectChecker caller to whitelist specific objects that are
going to fail checks, but that have been reviewed by a human and decided
the objects are OK enough to permit continued use of.

This avoids needing to rewrite history to scrub the broken objects out.

Honor the git-core fsck.skipList configuration setting when receiving a
push or fetching from a remote repository.

Change-Id: I62bd7c0b0848981f73dd7c752860fd02794233a6

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 agoDirCache: Do not create duplicate tree entries 81/62981/13
Shawn Pearce [Fri, 18 Dec 2015 22:31:20 +0000 (14:31 -0800)]
DirCache: Do not create duplicate tree entries

If a file (e.g.  "A") and a subtree file (e.g. "A/foo.c") both appear
in the DirCache this cache should not be written out as a tree object.
The "A" file and "A" subtree conflict with each other in the same tree
and will fail fsck.

Detect this condition during DirCacheBuilder and DirCacheEditor
finish() so the application can be halted early before it updates a
DirCache that might later write an invalid tree structure.

Change-Id: I95660787e88df336297949b383f4c5fda52e75f5

8 years agoDirCacheEditor: Replace file-with-tree and tree-with-file 29/63329/5
Shawn Pearce [Mon, 28 Dec 2015 19:43:07 +0000 (11:43 -0800)]
DirCacheEditor: Replace file-with-tree and tree-with-file

If a PathEdit tries to store a file where a subtree was, or a subtree
where a file was, replace the entry in the DirCache with the new
name(s).  This supports switching between file and tree entry types
using a DirCacheEditor.

Add new unit tests to cover the conditions where these can happen.

Change-Id: Ie843d9388825f9e3d918a5666aa04e47cd6306e7

8 years agoAddCommand: Use NameConflictTreeWalk to identify file-dir changes 61/63061/4
Shawn Pearce [Thu, 24 Dec 2015 22:27:50 +0000 (14:27 -0800)]
AddCommand: Use NameConflictTreeWalk to identify file-dir changes

Adding a path that already exists but is changing type such as
from symlink to subdirectory requires a NameConflictTreeWalk to
match up the two different entry types that share the same name.

NameConflictTreeWalk needs a bug fix to pop conflicting entries
when PathFilterGroup aborts the walk early so that it does not
allow DirCacheBuilderIterator to copy conflicting entries into
the output cache.

Change-Id: I61b49cbe949ca8b4b98f9eb6dbe7b1f82eabb724

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>