<h1 class="page-title">Git configuration</h1>
<p class="text-muted mb-3">Project: <a href="{{ summary_url }}">{{ project_esc | safe }}</a></p>
<div id="project-git-config" class="card" data-set-url="{{ set_config_url }}">
  <div class="card-body">
    <p class="text-secondary small mb-4">Changes are saved to this repository&rsquo;s local config. Select &ldquo;unset&rdquo; to remove a value.</p>
    <div class="gitconfig-sections">
      {% for sec in sections %}
      <section class="gitconfig-config-section collapsed" data-gitconfig-section>
        <div class="gitconfig-section-header">
          <h2 class="gitconfig-section-title m-0 h3 mb-0">[{{ sec.section | e }}]</h2>
          <button type="button" class="gitconfig-section-toggle" aria-expanded="false" aria-label="Toggle section">
            <span class="gitconfig-toggle-icon">+</span>
          </button>
        </div>
        <div class="gitconfig-section-content">
          {% for sub in sec.subsections %}
          {% if sub.subsection %}
          <h3 class="gitconfig-subsection-header">[{{ sec.section | e }} "{{ sub.subsection | e }}"]</h3>
          {% endif %}
          {% for f in sub.fields %}
          <div class="gitconfig-form-group project-git-config-field">
            <label class="gitconfig-form-label form-label mb-0" for="cfg-{{ f.git_key | replace('.', '-') }}" title="{{ f.git_key | e }}">{{ f.display_name | e }}</label>
            <div class="gitconfig-form-control">
              {% if f.control_kind == "select" %}
              <select class="form-select" id="cfg-{{ f.git_key | replace('.', '-') }}" data-config-key="{{ f.git_key | e }}">
                <option value="" {% if not f.current %}selected{% endif %}>(unset)</option>
                {% for o in f.options %}
                <option value="{{ o | e }}" {% if f.current == o %}selected{% endif %}>{{ o | e }}</option>
                {% endfor %}
              </select>
              {% else %}
              <input type="text" class="form-control" id="cfg-{{ f.git_key | replace('.', '-') }}" data-config-key="{{ f.git_key | e }}" value="{{ f.current | e }}" autocomplete="off" spellcheck="false">
              {% endif %}
            </div>
            {% if f.description %}
            <div class="gitconfig-form-description">{{ f.description | e }}</div>
            {% endif %}
          </div>
          {% endfor %}
          {% endfor %}
        </div>
      </section>
      {% endfor %}
    </div>
  </div>
</div>
<script src="/static/project_config.js"></script>