From: Constantine Plotnikov <constantine.plotnikov@gmail.com>
To: git@vger.kernel.org
Cc: Constantine Plotnikov <constantine.plotnikov@gmail.com>
Subject: [JGIT PATCH 2/3] Config.getSubsections(...) now loads the file if it has not been loaded
Date: Wed, 24 Jun 2009 21:48:04 +0400 [thread overview]
Message-ID: <1245865685-1288-3-git-send-email-constantine.plotnikov@gmail.com> (raw)
In-Reply-To: <1245865685-1288-2-git-send-email-constantine.plotnikov@gmail.com>
If method getSubsections() is invoked before any entry in the config
file is accessed via get*(section, subsection, name) methods,
NPE is thrown because file is not yet loaded. This patch fixes the
problem by ensuring that file is loaded before iterating entries
in this method.
Signed-off-by: Constantine Plotnikov <constantine.plotnikov@gmail.com>
---
.../src/org/spearce/jgit/lib/Config.java | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Config.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Config.java
index 62daef3..4220c37 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Config.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Config.java
@@ -367,6 +367,7 @@ public String getString(final String section, String subsection,
*/
public Set<String> getSubsections(final String section) {
final Set<String> result = new HashSet<String>();
+ ensureLoaded();
for (final Entry e : entries) {
if (section.equalsIgnoreCase(e.base) && e.extendedBase != null)
@@ -401,8 +402,7 @@ private String getRawString(final String section, final String subsection,
return null;
}
- private Object getRawEntry(final String section, final String subsection,
- final String name) {
+ private void ensureLoaded() {
if (!readFile) {
try {
load();
@@ -413,6 +413,11 @@ private Object getRawEntry(final String section, final String subsection,
err.printStackTrace();
}
}
+ }
+
+ private Object getRawEntry(final String section, final String subsection,
+ final String name) {
+ ensureLoaded();
String ss;
if (subsection != null)
--
1.6.1.2
next prev parent reply other threads:[~2009-06-24 17:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-24 17:48 [JGIT PATCH 0/3] Support for loading .gitmodules from blobs Constantine Plotnikov
2009-06-24 17:48 ` [JGIT PATCH 1/3] Extracted functionality independent from .git/config from RepositoryConfig Constantine Plotnikov
2009-06-24 17:48 ` Constantine Plotnikov [this message]
2009-06-24 17:48 ` [JGIT PATCH 3/3] Added BlobBasedConfig that allows accessing configuration files stored in the blobs Constantine Plotnikov
2009-06-25 0:26 ` [JGIT PATCH 0/3] Support for loading .gitmodules from blobs Shawn O. Pearce
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1245865685-1288-3-git-send-email-constantine.plotnikov@gmail.com \
--to=constantine.plotnikov@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).