{% for group_key, group in groups.items() %} {% if group.count > 0 %} {% set should_show = (group_key == 'unstaged' and unstaged) or (group_key == 'untracked' and untracked) or (group_key == 'staged') or (group_key == 'changes') %}
{% set hide_header = (group_key == 'staged' and not unstaged and not untracked) or (group_key == 'changes' and not untracked) %} {% if not hide_header %}
{#- "changes" is staged and unstaged merged together, which only happens when comparing against another ref. Saying so avoids reading as a third category alongside Staged and Unstaged. -#}

{%- if group_key == 'changes' -%} Changes vs {{ current_base_ref }} {%- else -%} {{ group_key|title }} {%- endif -%}

{{ group.count }} files
{% endif %}
{% for file in group.files %} {% set group_name = group_key %} {% include "diff_file.html" with context %} {% endfor %}
{% endif %} {% endfor %}