summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorMathias Kinzler <mathias.kinzler@sap.com>2010-09-01 09:13:19 +0200
committerMathias Kinzler <mathias.kinzler@sap.com>2010-09-01 09:13:19 +0200
commit2941d23e7ebaa524e7d9efbaf69565a57042d048 (patch)
tree1f2cbaa839f6fb49abc38a2bc2b1418449f9f92e /org.eclipse.jgit
parent6a05904e53bb60f96c344db33016b66f170cb9f0 (diff)
downloadjgit-2941d23e7ebaa524e7d9efbaf69565a57042d048.tar.gz
jgit-2941d23e7ebaa524e7d9efbaf69565a57042d048.zip
Avoid double quotes in Git Config
Currently, if a branch is created that has special chars ('#' in the bug), Config will surround the subsection name with double quotes during it's toText method which will result in an invalid file after saving the Config. Bug: 318249 Change-Id: I0a642f52def42d936869e4aaaeb6999567901001 Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
index 335cada7a3..884f49845c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
@@ -834,9 +834,15 @@ public class Config {
out.append(e.section);
if (e.subsection != null) {
out.append(' ');
- out.append('"');
- out.append(escapeValue(e.subsection));
- out.append('"');
+ String escaped = escapeValue(e.subsection);
+ // make sure to avoid double quotes here
+ boolean quoted = escaped.startsWith("\"")
+ && escaped.endsWith("\"");
+ if (!quoted)
+ out.append('"');
+ out.append(escaped);
+ if (!quoted)
+ out.append('"');
}
out.append(']');
} else if (e.section != null && e.name != null) {