import org.eclipse.jgit.events.ListenerHandle;
import org.eclipse.jgit.events.ListenerList;
import org.eclipse.jgit.internal.JGitText;
+import org.eclipse.jgit.transport.RefSpec;
import org.eclipse.jgit.util.IO;
import org.eclipse.jgit.util.RawParseUtils;
defaultValue, wantUnit);
}
+ /**
+ * Parse a list of {@link RefSpec}s from the configuration.
+ *
+ * @param section
+ * section the key is in.
+ * @param subsection
+ * subsection the key is in, or null if not in a subsection.
+ * @param name
+ * the key name.
+ * @return a possibly empty list of {@link RefSpec}s
+ * @since 4.9
+ */
+ public List<RefSpec> getRefSpecs(String section, String subsection,
+ String name) {
+ return typedGetter.getRefSpecs(this, section, subsection, name);
+ }
+
/**
* @param section
* section to search for.
package org.eclipse.jgit.lib;
import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.eclipse.jgit.annotations.NonNull;
import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.lib.Config.ConfigEnum;
+import org.eclipse.jgit.transport.RefSpec;
import org.eclipse.jgit.util.StringUtils;
/**
MessageFormat.format(JGitText.get().invalidTimeUnitValue2,
section, name, valueString));
}
+
+ @Override
+ public @NonNull List<RefSpec> getRefSpecs(Config config, String section,
+ String subsection, String name) {
+ String[] values = config.getStringList(section, subsection, name);
+ List<RefSpec> result = new ArrayList<>(values.length);
+ for (String spec : values) {
+ result.add(new RefSpec(spec));
+ }
+ return result;
+ }
}
package org.eclipse.jgit.lib;
+import java.util.List;
import java.util.concurrent.TimeUnit;
+import org.eclipse.jgit.annotations.NonNull;
+import org.eclipse.jgit.transport.RefSpec;
+
/**
* Something that knows how to convert plain strings from a git {@link Config}
* to typed values.
long getTimeUnit(Config config, String section, String subsection,
String name, long defaultValue, TimeUnit wantUnit);
+
+ /**
+ * Parse a list of {@link RefSpec}s from a git {@link Config}.
+ *
+ * @param config
+ * to get the list from
+ * @param section
+ * section the key is in.
+ * @param subsection
+ * subsection the key is in, or null if not in a subsection.
+ * @param name
+ * the key name.
+ * @return a possibly empty list of {@link RefSpec}s
+ */
+ @NonNull
+ List<RefSpec> getRefSpecs(Config config, String section, String subsection,
+ String name);
}
}
}
}
- vlst = rc.getStringList(SECTION, name, KEY_FETCH);
- fetch = new ArrayList<>(vlst.length);
- for (final String s : vlst)
- fetch.add(new RefSpec(s));
-
- vlst = rc.getStringList(SECTION, name, KEY_PUSH);
- push = new ArrayList<>(vlst.length);
- for (final String s : vlst)
- push.add(new RefSpec(s));
-
+ fetch = rc.getRefSpecs(SECTION, name, KEY_FETCH);
+ push = rc.getRefSpecs(SECTION, name, KEY_PUSH);
val = rc.getString(SECTION, name, KEY_UPLOADPACK);
- if (val == null)
+ if (val == null) {
val = DEFAULT_UPLOAD_PACK;
+ }
uploadpack = val;
val = rc.getString(SECTION, name, KEY_RECEIVEPACK);
- if (val == null)
+ if (val == null) {
val = DEFAULT_RECEIVE_PACK;
+ }
receivepack = val;
val = rc.getString(SECTION, name, KEY_TAGOPT);