{"thread":{"id":"20279","subject":"[JGIT PATCH 0/5] Some minor bug fixes","startedAt":"2009-07-29T15:50:22Z","lastAt":"2009-07-29T15:50:27Z","messageCount":6,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"119067","messageId":"1248882627-7285-1-git-send-email-spearce@spearce.org","threadId":"20279","inReplyTo":null,"subject":"[JGIT PATCH 0/5] Some minor bug fixes","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-07-29T15:50:22Z","receivedAt":"2009-07-29T15:50:22Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"I'm just throwing this series into the repository as-is.\n\nThe first in the series is needed to fix Gerrit Code Review (busted\ndue to a recent change to ReceivePack).  The rest of the series is\nreally minor public API corrections.\n\nShawn O. Pearce (5):\n  Don't dispose of RevFlag used to advertise objects in ReceivePack\n  Allow RemoteConfig.getAllRemoteConfigs on any Config object\n  Add ConfigInvalidException constructor to take Throwable\n  Add no fallback constructor to FileBasedConfig\n  Include the file path when FileBasedConfig.load throws an exception\n\n .../tst/org/spearce/jgit/lib/MockSystemReader.java |    2 +-\n .../org/spearce/jgit/lib/RepositoryTestCase.java   |    2 +-\n .../jgit/errors/ConfigInvalidException.java        |   12 ++++++++++++\n .../src/org/spearce/jgit/lib/FileBasedConfig.java  |   16 ++++++++++++++++\n .../org/spearce/jgit/transport/ReceivePack.java    |    1 -\n .../org/spearce/jgit/transport/RemoteConfig.java   |    5 ++---\n .../src/org/spearce/jgit/util/SystemReader.java    |    3 +--\n 7 files changed, 33 insertions(+), 8 deletions(-)\n"},{"id":"119070","messageId":"1248882627-7285-2-git-send-email-spearce@spearce.org","threadId":"20279","inReplyTo":"1248882627-7285-1-git-send-email-spearce@spearce.org","subject":"[JGIT PATCH 1/5] Don't dispose of RevFlag used to advertise objects in ReceivePack","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-07-29T15:50:23Z","receivedAt":"2009-07-29T15:50:23Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Back in 3ae30ae64d56113a71a07a3ff12d0af71cf538e2 I refactored how the\nReceivePack and UploadPack programs advertise the set of refs that\nthe server-side currently has.  As part of this change ReceivePack\nallocated a new RevFlag and marked it on all objects it advertised\nto the client, because the common code with UploadPack requires the\nRevFlag to mark objects.  It also uses this RevFlag to avoid sending\n\".have\" lines for objects we have already described.\n\nDisposing of the RevFlag however is problematic for any application\nthat uses the ReceivePack's RevWalk instance within a PreReceiveHook\nor a PostReceiveHook implementation.  By disposing of the RevFlag,\nthe flag bit was not actually unset from the advertised objects,\nit was only marked as being eligible for reallocation in another\nRevFlag.  If the flag bit was reallocated, any advertised objects\nwould automatically have the bit set, which can confuse the new\nuser of the bit.\n\nRevWalk's isMergedInto() really got confused, as it allocates a\ntemporary RevFlag for each input RevCommit in order to compute the\nmerge base.\n\nThe simplest fix is to just never dispose of this RevFlag once\nit has been allocated.  We could dispose of it and also unset it\nfrom all objects we advertised, but that would require us to keep\ntrack of the full advertised set, a potentially expensive thing to\ndo given that most callers will never need to allocate a RevFlag,\nlet alone care about the 1 bit leaked by the protocol.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n .../org/spearce/jgit/transport/ReceivePack.java    |    1 -\n 1 files changed, 0 insertions(+), 1 deletions(-)\n\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java b/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java\nindex ca4a7ec..eb21254 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java\n@@ -547,7 +547,6 @@ private void sendAdvertisedRefs() throws IOException {\n \t\tif (adv.isEmpty())\n \t\t\tadv.advertiseId(ObjectId.zeroId(), \"capabilities^{}\");\n \t\tpckOut.end();\n-\t\twalk.disposeFlag(advertised);\n \t}\n \n \tprivate void recvCommands() throws IOException {\n-- \n1.6.4.rc3.201.gd9d59\n"},{"id":"119068","messageId":"1248882627-7285-3-git-send-email-spearce@spearce.org","threadId":"20279","inReplyTo":"1248882627-7285-2-git-send-email-spearce@spearce.org","subject":"[JGIT PATCH 2/5] Allow RemoteConfig.getAllRemoteConfigs on any Config object","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-07-29T15:50:24Z","receivedAt":"2009-07-29T15:50:24Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Back in 07c8dc6e94729ff4104f0a1c815dd81f3e71c562 I changed the\nRemoteConfig class to accept any Config object, but its static\ngetAllRemoteConfigs() utility method was missed and still used\na RepositoryConfig.  It should take any Config.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n .../org/spearce/jgit/transport/RemoteConfig.java   |    5 ++---\n 1 files changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/RemoteConfig.java b/org.spearce.jgit/src/org/spearce/jgit/transport/RemoteConfig.java\nindex ca84acf..dd7a50c 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/transport/RemoteConfig.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/RemoteConfig.java\n@@ -44,7 +44,6 @@\n import java.util.List;\n \n import org.spearce.jgit.lib.Config;\n-import org.spearce.jgit.lib.RepositoryConfig;\n \n /**\n  * A remembered remote repository, including URLs and RefSpecs.\n@@ -96,8 +95,8 @@\n \t * @throws URISyntaxException\n \t *             one of the URIs within the remote's configuration is invalid.\n \t */\n-\tpublic static List<RemoteConfig> getAllRemoteConfigs(\n-\t\t\tfinal RepositoryConfig rc) throws URISyntaxException {\n+\tpublic static List<RemoteConfig> getAllRemoteConfigs(final Config rc)\n+\t\t\tthrows URISyntaxException {\n \t\tfinal List<String> names = new ArrayList<String>(rc\n \t\t\t\t.getSubsections(SECTION));\n \t\tCollections.sort(names);\n-- \n1.6.4.rc3.201.gd9d59\n"},{"id":"119069","messageId":"1248882627-7285-4-git-send-email-spearce@spearce.org","threadId":"20279","inReplyTo":"1248882627-7285-3-git-send-email-spearce@spearce.org","subject":"[JGIT PATCH 3/5] Add ConfigInvalidException constructor to take Throwable","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-07-29T15:50:25Z","receivedAt":"2009-07-29T15:50:25Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"This permits applications to wrap a ConfigInvalidException with\nmore detail before throwing it to the caller.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n .../jgit/errors/ConfigInvalidException.java        |   12 ++++++++++++\n 1 files changed, 12 insertions(+), 0 deletions(-)\n\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/errors/ConfigInvalidException.java b/org.spearce.jgit/src/org/spearce/jgit/errors/ConfigInvalidException.java\nindex 6e861fd..28c87a5 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/errors/ConfigInvalidException.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/errors/ConfigInvalidException.java\n@@ -50,4 +50,16 @@\n \tpublic ConfigInvalidException(final String message) {\n \t\tsuper(message);\n \t}\n+\n+\t/**\n+\t * Construct an invalid configuration error.\n+\t *\n+\t * @param message\n+\t *            why the configuration is invalid.\n+\t * @param cause\n+\t *            root cause of the error.\n+\t */\n+\tpublic ConfigInvalidException(final String message, final Throwable cause) {\n+\t\tsuper(message, cause);\n+\t}\n }\n-- \n1.6.4.rc3.201.gd9d59\n"},{"id":"119071","messageId":"1248882627-7285-5-git-send-email-spearce@spearce.org","threadId":"20279","inReplyTo":"1248882627-7285-4-git-send-email-spearce@spearce.org","subject":"[JGIT PATCH 4/5] Add no fallback constructor to FileBasedConfig","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-07-29T15:50:26Z","receivedAt":"2009-07-29T15:50:26Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Sometimes when reading a FileBasedConfig the caller does not want any\nfallback lookup.  Instead always passing a null first parameter to the\nconstructor, we can use a 1-arg constructor that takes only the File\npath for this file.  This simplifies a number of cases within the JGit\nlibrary and test cases, as well as some application code.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n .../tst/org/spearce/jgit/lib/MockSystemReader.java |    2 +-\n .../org/spearce/jgit/lib/RepositoryTestCase.java   |    2 +-\n .../src/org/spearce/jgit/lib/FileBasedConfig.java  |   10 ++++++++++\n .../src/org/spearce/jgit/util/SystemReader.java    |    3 +--\n 4 files changed, 13 insertions(+), 4 deletions(-)\n\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/MockSystemReader.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/MockSystemReader.java\nindex 62862d1..7a65f99 100644\n--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/MockSystemReader.java\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/MockSystemReader.java\n@@ -53,7 +53,7 @@\n \t\tinit(Constants.GIT_AUTHOR_EMAIL_KEY);\n \t\tinit(Constants.GIT_COMMITTER_NAME_KEY);\n \t\tinit(Constants.GIT_COMMITTER_EMAIL_KEY);\n-\t\tuserGitConfig = new FileBasedConfig(null, null);\n+\t\tuserGitConfig = new FileBasedConfig(null);\n \t}\n \n \tprivate void init(final String n) {\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java\nindex 24a99ca..6de9afe 100644\n--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java\n@@ -237,7 +237,7 @@ public void run() {\n \t\t}\n \n \t\tfinal MockSystemReader mockSystemReader = new MockSystemReader();\n-\t\tmockSystemReader.userGitConfig = new FileBasedConfig(null, new File(\n+\t\tmockSystemReader.userGitConfig = new FileBasedConfig(new File(\n \t\t\t\ttrash_git, \"usergitconfig\"));\n \t\tSystemReader.setInstance(mockSystemReader);\n \ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/FileBasedConfig.java b/org.spearce.jgit/src/org/spearce/jgit/lib/FileBasedConfig.java\nindex a419e7f..adf85c6 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/FileBasedConfig.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/FileBasedConfig.java\n@@ -55,6 +55,16 @@\n \tprivate final File configFile;\n \n \t/**\n+\t * Create a configuration with no default fallback.\n+\t *\n+\t * @param cfgLocation\n+\t *            the location of the configuration file on the file system\n+\t */\n+\tpublic FileBasedConfig(File cfgLocation) {\n+\t\tthis(null, cfgLocation);\n+\t}\n+\n+\t/**\n \t * The constructor\n \t *\n \t * @param base\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/util/SystemReader.java b/org.spearce.jgit/src/org/spearce/jgit/util/SystemReader.java\nindex a30dfef..51a0d29 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/util/SystemReader.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/util/SystemReader.java\n@@ -42,7 +42,6 @@\n import java.net.UnknownHostException;\n \n import org.spearce.jgit.lib.FileBasedConfig;\n-import org.spearce.jgit.lib.RepositoryConfig;\n \n /**\n  * Interface to read values from the system.\n@@ -66,7 +65,7 @@ public String getProperty(String key) {\n \n \t\tpublic FileBasedConfig openUserConfig() {\n \t\t\tfinal File home = FS.userHome();\n-\t\t\treturn new RepositoryConfig(null, new File(home, \".gitconfig\"));\n+\t\t\treturn new FileBasedConfig(new File(home, \".gitconfig\"));\n \t\t}\n \n \t\tpublic String getHostname() {\n-- \n1.6.4.rc3.201.gd9d59\n"},{"id":"119072","messageId":"1248882627-7285-6-git-send-email-spearce@spearce.org","threadId":"20279","inReplyTo":"1248882627-7285-5-git-send-email-spearce@spearce.org","subject":"[JGIT PATCH 5/5] Include the file path when FileBasedConfig.load throws an exception","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-07-29T15:50:27Z","receivedAt":"2009-07-29T15:50:27Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"This may help an end-user debug the problem, if they know what file\nthe error occurred in.  We have to wrap the exception here because\nthe methods throwing the original error do not have access to the\nfile path, and cannot include it in the message.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n .../src/org/spearce/jgit/lib/FileBasedConfig.java  |    6 ++++++\n 1 files changed, 6 insertions(+), 0 deletions(-)\n\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/FileBasedConfig.java b/org.spearce.jgit/src/org/spearce/jgit/lib/FileBasedConfig.java\nindex adf85c6..518b31d 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/FileBasedConfig.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/FileBasedConfig.java\n@@ -98,6 +98,12 @@ public void load() throws IOException, ConfigInvalidException {\n \t\t\tfromText(RawParseUtils.decode(NB.readFully(getFile())));\n \t\t} catch (FileNotFoundException noFile) {\n \t\t\tclear();\n+\t\t} catch (IOException e) {\n+\t\t\tfinal IOException e2 = new IOException(\"Cannot read \" + getFile());\n+\t\t\te2.initCause(e);\n+\t\t\tthrow e2;\n+\t\t} catch (ConfigInvalidException e) {\n+\t\t\tthrow new ConfigInvalidException(\"Cannot read \" + getFile(), e);\n \t\t}\n \t}\n \n-- \n1.6.4.rc3.201.gd9d59\n"}]}