Commit Graph

981 Commits

Author SHA1 Message Date
Shawn O. Pearce f3b511568b SimilarityIndex: Correct comment explaining the logic
This comment was wrong, due to a copy-and-paste error.  Here the
code is looking at records of dst that do not exist in src, and
are skipping past them to find another match.

Change-Id: I07c1fba7dee093a1eeffcf7e0c7ec85446777ffb
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-11-12 11:56:57 -08:00
Shawn Pearce e8315ce19d Merge "Fix null ref exception in DirCacheCheckout" 2010-11-12 11:29:32 -05:00
Robin Rosenberg 8c706ab464 Use capital L for long constants
Change-Id: Ib7b8c5f982dc72c68cf3d81e45a536c464837f7d
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2010-11-12 10:28:13 +01:00
Shawn O. Pearce 5a2cbd4aa7 Remember non-note tree entries when reading
In order to safely edit a notes tree, NoteMap needs to retain any
non-note tree entries it read from the source tree and put them
back out into the modified tree when it commits a new version of
the note branch.

Remember any tree entries that didn't look like a note during
the parsing of the tree, so they can be put into a TreeFormatter
later when the tree writes to the repository.

Change-Id: Ia284af7e7866da35db35374c6c5869f00c857944
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-11-11 10:57:16 -08:00
Shawn O. Pearce b81b97fbdd Lazy load note subtrees from fanout levels
Instead of reading a note tree recursively up front when the NoteMap
is loaded, read only the root tree and load subtrees on demand when
they are accessed by the application.  This gives a lower latency
to read a note for the recent commits on a branch, as only the paths
that are needed get read.

Given a 2/38 style fanout, the tree will fully load when 256 objects
have been accessed by the application.  But unlike the prior version
of NoteMap, the NoteMap will load faster and answer lookups sooner,
as the loading time for all 256 levels is spread out across each of
the get() requests.

Given a 2/2/36 style fanout, the tree won't need to fully load until
about 65,536 objects are accessed.

To simplify the implementation we only support the flat layout (all
notes in the top level tree), or a 2/38, 2/2/36, 2/2/2/34, through
2/.../2 style fanout.  Unlike C Git we don't support reading the old
experimental 4/36 fanout.  This is sufficient because C Git won't
create the 4/36 style fanout when creating or updating a notes tree,
and there really aren't any in the wild today.

Change-Id: I6099b35916a8404762f31e9c11f632e43e0c1bfd
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-11-11 10:23:38 -06:00
Shawn O. Pearce 936820988f Define NoteMap, a simple note tree reader
The NoteMap makes it easy to read a small notes tree as created by
the `git notes` command in C Git.  To make the initial implementation
simple a notes tree is read recursively into a map in memory.
This is reasonable if the application will need to access all notes,
or if there are less than 256 notes in the tree, but doesn't behave
well when the number of notes exceeds 256 and the application
doesn't need to access all of them.

We can later add support for lazily loading different subpaths,
thus fixing the large note tree problem described above.

Currently the implementation only supports reading.  Writing notes
is more complex because trees need to be expanded or collapsed at
the exact 256 entry cut-off in order to retain the same tree SHA-1
that C Git would use for the same content.  It also needs to retain
non-note tree entries such as ".gitignore" or ".gitattribute" files
that might randomly appear within a notes tree.  We can also add
writing support later.

Change-Id: I93704bd84ebf650d51de34da3f1577ef0f7a9144
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-11-11 10:06:43 -06:00
Chris Aniszczyk 6043d4638c Merge "Add MutableObjectId setByte to modify a mutable id" 2010-11-11 10:52:37 -05:00
Chris Aniszczyk ea76489db1 Merge "Implement command line support for CredentialsProvider" 2010-11-11 10:28:56 -05:00
Chris Aniszczyk 573666403d Merge "Support CredentialsProvider for SSH connections" 2010-11-11 10:27:52 -05:00
Stefan Lay 33c419fdfe Merge "Define a default CredentialsProvider" 2010-11-11 09:36:34 -05:00
Stefan Lay dcac1fe4bf Merge "Enable providing credentials for HTTP authentication" 2010-11-11 09:35:43 -05:00
Shawn O. Pearce 17d9c68636 Implement command line support for CredentialsProvider
Instead of configuring the JSch session factory, configure a more
generic CredentialsProvider, which will work for other transport
types such as http, in addition to the existing ssh.

Change-Id: I22b13303c17e654ba6720edf4be2ef15fe29537a
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-11-10 15:12:47 -08:00
Chris Aniszczyk 9e28cf2fa3 Merge "Add ObjectId getByte for random access" 2010-11-10 18:00:36 -05:00
Shawn O. Pearce d279bc83b0 Support CredentialsProvider for SSH connections
When setting up an SSH connection, use the caller supplied
CredentialsProvider, if one has been given to the Transport
or was defined as the default.

The CredentialsProvider is re-wrapped as a JSch UserInfo,
allowing the connection to use this for user interactive
prompts.  This give a unified API for authentication on
any transport type.

Change-Id: Id3b4cf5bfd27a23207cdfb188bae3b78e71e02c0
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-11-10 15:00:13 -08:00
Shawn O. Pearce ce99b48384 Define a default CredentialsProvider
This permits applications to set their preferred credentials UI
implementation once, rather than needing to define it on every
single Transport instance they open.

Change-Id: I010550de1a6becab27f7aa5a9901df5a1c7e74bd
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-11-10 14:58:45 -08:00
Shawn O. Pearce 308e074f65 Enable providing credentials for HTTP authentication
This change is based on http://egit.eclipse.org/r/#change,1652
by David Green. The change adds the concept of a CredentialsProvider
which can be registered for git transports and which is
responsible to return credential-related data like passwords and
usernames. Whenenver the transports detects that an authentication
with certain credentials has to be done it will ask the
CredentialsProvider for this data. Foreseen implementations for
such a Provider may be a EGitCredentialsProvider (caching
credential data entered e.g. in the Clone-Wizzard) or a NetRcProvider
(gathering data out of ~/.netrc file).

Bug: 296201
Change-Id: Ibe13e546b45eed3e193c09ecb414bbec2971d362
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
CC: David Green <dgreen99@gmail.com>
2010-11-10 14:58:44 -08:00
Chris Aniszczyk 453b620e62 Merge "Refactor tree entry formatting into a common class" 2010-11-10 17:53:35 -05:00
Lluis Sanchez 3b4dcb3c02 Fix null ref exception in DirCacheCheckout
Added missing null check for getDirCacheEntry(). This method may
return null for example if the curernt entry is a subtree.
2010-11-10 10:56:46 +01:00
Stefan Lay 20a5a34444 Fix WWW-Authenticate auth-scheme comparison
The auth-scheme token (like "Basic" or "Digest") is not specified in a
case sensitive way. RFC2617 (http://tools.ietf.org/html/rfc2617) specifies
in section 1.2 the use of a "case-insensitive token to identify the
authentication scheme". Jetty, for example, uses "basic" as token.

Change-Id: I635a94eb0a741abcb3e68195da6913753bdbd889
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2010-11-10 09:42:51 +01:00
Shawn O. Pearce cfa3f365d6 Simplify LockFile write(ObjectId) case
The ObjectId (for a ref) can be easily reformatted into a temporary
byte[] and then passed off to write(byte[]), removing the duplicated
code that existed in both write methods.

Change-Id: I09740658e070d5f22682333a2e0d325fd1c4a6cb
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-11-09 19:13:13 -08:00
Shawn Pearce 17b1003ff2 Merge "Fix broken MergeCommandTest" 2010-11-09 18:58:34 -05:00
Matthias Sohn ab7d08ec96 Merge "Revert "[findBugs] Silence DM_STRING_CTOR on PacketLineIn"" 2010-11-09 18:18:41 -05:00
Matthias Sohn 2cba7b3522 Fix broken MergeCommandTest
Test was broken by commit b087bba3 changing formatting of merge
commit messages.

Change-Id: I98b1b936b9b6cbaa50fbc59d243a43e66a6ee9f9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-11-10 00:11:12 +01:00
Shawn O. Pearce 6af7e4d91a Fix URIish parsing of absolute scp-style URIs
We stopped handling URIs such as "example.com:/some/p ath", because
this was confused with the Windows absolute path syntax of "c:/path".
Support absolute style scp URIs again, but only when the host name
is more than 2 characters long.

Change-Id: I9ab049bc9aad2d8d42a78c7ab34fa317a28efc1a
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-11-09 14:36:01 -08:00
Shawn Pearce b087bba3bd Merge "Format merge commit messages like C Git" 2010-11-09 17:14:11 -05:00
Shawn O. Pearce 08a9682e32 Revert "[findBugs] Silence DM_STRING_CTOR on PacketLineIn"
This reverts commit 1e510ec20e.

Instead work around the warning by defining our constant by
constructing it through a StringBuilder.

Change-Id: If139509e769d649609c62eff359ebaea5dd286b2
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
CC: Matthias Sohn <matthias.sohn@sap.com>
CC: Chris Aniszczyk <caniszczyk@gmail.com>
2010-11-08 15:34:47 -08:00
Shawn Pearce 6ed0501346 Merge "IndexDiff: support state [removed, untracked]" 2010-11-08 18:32:45 -05:00
Jens Baumgart 2dc2dd8b1b IndexDiff: support state [removed, untracked]
IndexDiff was extended to detect files which are both removed from the
index and untracked.  Before this change these files were only added
to the removed collection.

Change-Id: I971d8261d2e8932039fce462b59c12e143f79f90
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-11-08 15:32:03 -08:00
Shawn Pearce 09555c9853 Merge "Make Repository.shortenRefName static" 2010-11-08 17:42:21 -05:00
Christian Halstrick a28f33fa8c Fixed help of Diff and ShowCommands commands
jgit.sh <command> --help was not working for the commands Diff
and ShowCommands because of missing metaVar information. Missing
information is added here.

Change-Id: I0ab7e35006b6aa7d4326a634309dddfcdb78f2a6
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-11-08 13:56:07 -08:00
Chris Aniszczyk 5dc72352f5 Merge "CommitAndLogCommandTests: add a test for LogCommand.addRange()" 2010-11-08 07:50:43 -05:00
Chris Aniszczyk d6fec1988c Merge "[findBugs] Fix NP_LOAD_OF_KNOWN_NULL_VALUE" 2010-11-07 16:09:00 -05:00
Chris Aniszczyk 83019318c6 Merge "[findBugs] Silence DM_STRING_CTOR on PacketLineIn" 2010-11-07 16:07:43 -05:00
Chris Aniszczyk df037eb230 Merge "Implemented the git add commandline command." 2010-11-07 16:05:24 -05:00
Sasa Zivkov 1a7c918b66 Implemented the git add commandline command.
Implementation delegates all work to the AddCommand class and,
therefore, supports only those options currently supported by the
AddCommand which means: --update and the filepattern... arguments.

Change-Id: I4827d37e08b4c988c2458d9ba60a61b6ad414d10
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
2010-11-07 21:30:56 +01:00
Matthias Sohn 1e510ec20e [findBugs] Silence DM_STRING_CTOR on PacketLineIn
We don't want to pool this String.

Change-Id: I68bb1c57fac2e138eece4503ca5bda8f69261083
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-11-07 21:22:23 +01:00
Matthias Sohn 220cd43482 [findBugs] Fix NP_LOAD_OF_KNOWN_NULL_VALUE
The code analyzer can't know that passing a value known to be null is
not a problem. Hence better pass null explicitly instead of the
parameters being null.

Change-Id: I8db6f8014de6c00dd95974d60f61ecc66191e6d4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-11-07 20:16:15 +01:00
Christian Halstrick 0e815fe8c5 Fixed ResolveMerger regarding handling of deletions
There was a bug in ResolveMerger which is one reason for
bug 328841. If a merge was failing because of conflicts
deletions where not handled correctly. Files which have
to be deleted (because there was a non-conflicting deletion
coming in from THEIRS) are not deleted. In the
non-conflicting case we also forgot to delete the file but
in this case we explicitly checkout in the end these files
get deleted during that checkout.

This is fixed by handling incoming deletions explicitly.

Bug: 328841
Change-Id: I7f4c94ab54138e1b2f3fcdf34fb803d68e209ad0
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-11-07 14:59:01 +01:00
Robin Stocker 6290ca3a63 Format merge commit messages like C Git
The automatically generated commit message of a merge should have the
same structure as in C Git for consistency (as per git fmt-merge-msg).

Before this change:

  merging refs/heads/a into refs/heads/master

After:

  Merge branch 'a'

Plurals, "into" and joining by "," and "and" also work.

Change-Id: I9658ce2817adc90d2df1060e8ac508d7bd0571cb
2010-11-06 13:48:11 +01:00
Robin Stocker 2fb0f5cfc0 Make Repository.shortenRefName static
The method has no reason to be non-static.

Change-Id: I1c09e074395d49cee0e6e53679b499d1f0c351ea
2010-11-06 13:41:06 +01:00
Shawn Pearce d1e8e97316 Merge "Add a test for merging deleted files" 2010-11-05 18:03:19 -04:00
Shawn Pearce 5835ad1a91 Merge changes I8d77cb59,I2beb4db5
* changes:
  Fixed merge algorithm regarding adjacent modifications
  Cleaned up MergeAlgorithmTest
2010-11-05 17:38:44 -04:00
Sasa Zivkov af4f6c5125 Fixed the git init to properly set bare=true
When --git-dir=X is given JGit creates a bare repository in the
directory X. However, when the --bare option is not explicitly
given, this is not properly reflected in the X/config file i.e.
the bare=true is missing.  This change fixes this minor issue.

Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
2010-11-05 16:06:14 +01:00
Mathias Kinzler af31a97c82 CommitAndLogCommandTests: add a test for LogCommand.addRange()
There were also some compiler warning due to empty catch blocks that
were fixed.

Change-Id: I165bcddcdfacd34f020d1b938a41954916eb106e
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
2010-11-05 12:26:56 +01:00
Shawn O. Pearce e488f1cacd Add MutableObjectId setByte to modify a mutable id
This mirrors the getByte() API in ObjectId and allows the caller to
modify a single byte, which is useful when updating it as part of a
loop walking through 0x00..0xff inside of a range of objects.

Change-Id: I57fa8420011fe5ed5fc6bfeb26f87a02b3197dab
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-11-04 19:12:13 -07:00
Shawn O. Pearce b22a4e8488 Add ObjectId getByte for random access
Processing git notes requires random access to part of the raw data
of each ObjectId... which isn't easy because ObjectIds are stored
with an internal representation of 5 ints.  Expose random access
to the individual data bytes through new methods, avoiding the
need to convert first to a byte[20].

Change-Id: I99e64700b27fc0c95aa14ef8ad46a0e8832d4441
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-11-04 19:12:13 -07:00
Shawn O. Pearce c27e1daa55 Refactor tree entry formatting into a common class
Instead of hiding this logic inside of DirCacheTree and the legacy
Tree type, pull it into a common place where we can reuse it by
creating tree records in a buffer that can be passed directly into
the ObjectInserter.  This allows us to avoid some copying, as the
inserter can be given the internal buffer of the formatter.

Because we trust these two callers to feed us records in the proper
order, without '/' in the names, and without duplicate names in the
same tree, we don't do any validation inside of the formatter itself.
To protect themselves from making ordering errors, developers should
continue to use DirCache to process edits to source code trees.

Change-Id: Idf7f10e736d4a44ccdf8afe060535d7b0554a92f
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-11-04 19:12:13 -07:00
Christian Halstrick f5076d8b04 Add a test for merging deleted files
The JGit merge algorithm or the Merge Command may have problems with handling
deletions always correctly. Therefore one additional test is added to check
this.

Change-Id: Id6aa49136996b29047c340994fe7faba68858e8c
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-11-03 13:37:45 +01:00
Christian Halstrick 99771f04bc Fixed merge algorithm regarding adjacent modifications
JGit merge algorithm behaved differently from C Git when
we had adjacent modifications. If line 9 was modified by
OURS and line 10 by theirs then C Git will return a
conflict while JGit was seeing this as independent
modifications. This change is not only there to achieve
compatibility, but there where also some really wrong
merge results produced by JGit in the area of adjacent
modifications.

Change-Id: I8d77cb59e82638214e45b3cf9ce3a1f1e9b35c70
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-11-02 18:29:35 +01:00
Christian Halstrick e8642b538c Cleaned up MergeAlgorithmTest
Introduced similar helper methods than in AbstractDiffTestCase.
Then the test cases are much smaller and better understandable.

Change-Id: I2beb4db5a93bd8c0c1238d5d3039cbd6719eee90
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-11-02 18:29:33 +01:00