Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "JGit/User Guide"

(Incompatible JGit API Changes)
(Version 0.9)
Line 6: Line 6:
  
 
''RepositoryConfig removed'':  Use Config or FileBasedConfig instead.  To replace getCore(), getTransfer() and getUserConfig() methods, use config.get(CoreConfig.KEY), config.get(TransferConfig.KEY), and config.get(UserConfig.KEY).  To replace getAuthorName() and friends, use the UserConfig object returned by config.get(UserConfig.KEY).
 
''RepositoryConfig removed'':  Use Config or FileBasedConfig instead.  To replace getCore(), getTransfer() and getUserConfig() methods, use config.get(CoreConfig.KEY), config.get(TransferConfig.KEY), and config.get(UserConfig.KEY).  To replace getAuthorName() and friends, use the UserConfig object returned by config.get(UserConfig.KEY).
 +
 +
''Repository class is abstract'':  Use a RepositoryBuilder.
  
 
''Repository constructors removed'':  To create a Repository instance, use a RepositoryBuilder.  If you know it must be a classical local file system based Repository (as opposed to other types that JGit will support in the future), you can use the FileRepositoryBuilder instead to ensure its a FileRepository that is returned.
 
''Repository constructors removed'':  To create a Repository instance, use a RepositoryBuilder.  If you know it must be a classical local file system based Repository (as opposed to other types that JGit will support in the future), you can use the FileRepositoryBuilder instead to ensure its a FileRepository that is returned.
Line 12: Line 14:
  
 
''Repository.openObject(), openBlob(), etc. removed'':  To read an object, use Repository.open() or repository.newObjectReader() to get a reader and use the reader's open() method.  An ObjectReader is preferred if the application will access several objects in a short time span (e.g. in response to the current UI event, or the current network connection).
 
''Repository.openObject(), openBlob(), etc. removed'':  To read an object, use Repository.open() or repository.newObjectReader() to get a reader and use the reader's open() method.  An ObjectReader is preferred if the application will access several objects in a short time span (e.g. in response to the current UI event, or the current network connection).
 +
 +
''RepositoryState value BARE added'':  To correctly denote a bare repository whose work tree state is undefined, the enum RepositoryState returned by repository.getRepositoryState() returns BARE when isBare() is true or getDirectory() returns null.
  
 
''WindowCursor removed'':  Instead use repository.newObjectReader(), and examine objects through the methods on the returned ObjectReader.  Please note that an ObjectReader must be released with its release() method after it is no longer useful to the application.
 
''WindowCursor removed'':  Instead use repository.newObjectReader(), and examine objects through the methods on the returned ObjectReader.  Please note that an ObjectReader must be released with its release() method after it is no longer useful to the application.

Revision as of 14:00, 30 June 2010

Incompatible JGit API Changes

JGit is still in beta hence we sometimes do incompatible API changes to reach a better stable API.
These are listed here as a reference for other projects depending on the JGit API.

Version 0.9

RepositoryConfig removed: Use Config or FileBasedConfig instead. To replace getCore(), getTransfer() and getUserConfig() methods, use config.get(CoreConfig.KEY), config.get(TransferConfig.KEY), and config.get(UserConfig.KEY). To replace getAuthorName() and friends, use the UserConfig object returned by config.get(UserConfig.KEY).

Repository class is abstract: Use a RepositoryBuilder.

Repository constructors removed: To create a Repository instance, use a RepositoryBuilder. If you know it must be a classical local file system based Repository (as opposed to other types that JGit will support in the future), you can use the FileRepositoryBuilder instead to ensure its a FileRepository that is returned.

Repository.getDirectory() can return null: It is no longer a requirement that every Repository instance has a java.io.File associated with it. In the future some types of Git repositories that are not on the local filesystem will be supported, and those types will return null.

Repository.openObject(), openBlob(), etc. removed: To read an object, use Repository.open() or repository.newObjectReader() to get a reader and use the reader's open() method. An ObjectReader is preferred if the application will access several objects in a short time span (e.g. in response to the current UI event, or the current network connection).

RepositoryState value BARE added: To correctly denote a bare repository whose work tree state is undefined, the enum RepositoryState returned by repository.getRepositoryState() returns BARE when isBare() is true or getDirectory() returns null.

WindowCursor removed: Instead use repository.newObjectReader(), and examine objects through the methods on the returned ObjectReader. Please note that an ObjectReader must be released with its release() method after it is no longer useful to the application.

RevWalk requires release: RevWalk now embeds an ObjectReader, and therefore must be released through its release() method when it is no longer required by the application that created it. Optionally the caller can now specify the ObjectReader the walker should use, allowing the caller to more explicitly manage the release.

TreeWalk requires release: TreeWalk now embeds an ObjectReader, and therefore must be released through its release() method when it is no longer required by the application that created it. Optionally the caller can now specify the ObjectReader the walker should use, allowing the caller to more explicitly manage the release.

ObjectWriter deprecated: ObjectWriter will be removed in a future version of JGit. Applications are strongly encouraged to switch to the ObjectInserter API, which can be obtained from repository.newObjectInserter(). Like the ObjectReader, and ObjectInserter must be released through its release() method after use.

NoWorkTreeException thrown: A bare repository (one without a working directory) will throw NoWorkTreeException if its getIndexFile(), getIndex(), getWorkTree(), readCommitMessage(), or readMergeMessage() is called on it, or if its corresponding DirCache is read or locked. This is a RuntimeException so applications need to be careful about knowing what the return value of repository.isBare() is for any given repository they operate on.

Back to the top