# Gitconfig format

`gitconfig-format` · version 1.0.0 · Structured formats · free, no key needed

Format git config sections as canonical text with escapes and subsections.

**Use when you need to: format git config sections as text · serialize a gitconfig document · write canonical git config entries.**

## Decide before calling

Read the [versioned contract](/v1/tools/gitconfig-format/versions/1.0.0) and the supported scope below. Reuse `gitconfig-format@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `gitconfig-format@1.0.0` for format git config sections as text. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- format git config sections as text
- serialize a gitconfig document
- write canonical git config entries
- render gitconfig escapes and subsections
- emit ordered git config multivars
- git config text from structured sections
- כתיבת קובץ הגדרות גיט מתוך המקטעים

## Not supported

- emit include or includeIf as files to read
- emit deprecated dotted subsection headers
- canonicalize boolean integer or path values
- preserve comments and insignificant whitespace

## Behavior

- Whitespace is only SP and HT. CRLF is one line break. A lone CR, NUL, DEL, or any other C0 control except HT, LF, and BS is invalid_input. A leading U+FEFF is not skipped.
- Section and variable names are ASCII case-folded. A variable must start with a letter. A subsection is case-sensitive and is not folded. A dot in the unquoted section token is unsupported_input reason dotted_section_name.
- Value escapes, inside or outside quotes, are only \" \\ \n \t and \b. A backslash before LF continues the value. Quotes are delimiters, so adjacent quotes concatenate. # and ; comment only outside quotes. A bare name is implicit_bool true with a null value. Explicit values stay strings: yes, no, true, false, integers, paths, and the empty string are not canonicalized.
- include and includeIf headers are unsupported_input reason include_not_supported. A truncated header is invalid_input even when the partial name looks like include.
- Duplicate sections are not merged. Repeated variables stay in file order.
- Canonical text is LF only, with no BOM and no blank line. Each header is at column 0. Each variable has one leading tab. An explicit value uses one space on each side of =. A value is bare only when it is non-empty and every code point is ASCII 0x21-0x7E except quote, hash, semicolon, and backslash; otherwise it is double-quoted with \\ \" \n \t \b. Subsection quotes escape only \\ and \". Tab and BS may appear raw inside a subsection. LF, CR, NUL, DEL, and other C0 controls in a subsection or value are invalid_input. Output bytes are the UTF-8 size of the text field. The whole input is walked for depth, nodes, and string bytes before shape checks. Parser line fields are rejected.

## Input

- `sections` (array of object, required): max items 128

## Output

- `text` (string, required): max length 65536

## Limits

- max input bytes: 131072
- max output bytes: 65536
- max sections: 128
- max entries: 512
- max value bytes: 8192
- max subsection bytes: 1024
- max depth: 8
- max nodes: 8192

## Example

Request input:

```json
{
  "sections": [
    {
      "name": "core",
      "subsection": null,
      "entries": [
        {
          "key": "filemode",
          "value": "false",
          "implicit_bool": false
        }
      ]
    }
  ]
}
```

Response:

```json
{
  "result": {
    "text": "[core]\n\tfilemode = false\n"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "gitconfig-format",
  "version": "1.0.0",
  "input": {
    "sections": [
      {
        "name": "core",
        "subsection": null,
        "entries": [
          {
            "key": "filemode",
            "value": "false",
            "implicit_bool": false
          }
        ]
      }
    ]
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/gitconfig-format/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"sections":[{"name":"core","subsection":null,"entries":[{"key":"filemode","value":"false","implicit_bool":false}]}]}'
```

The machine-readable contract is at [/v1/tools/gitconfig-format/versions/1.0.0](/v1/tools/gitconfig-format/versions/1.0.0).

### CLI

```sh
node cli.mjs run gitconfig-format 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Gitconfig parse](/tools/gitconfig-parse): Parse git config text into ordered sections, subsections, and multivar entries.
- [Systemd .env format](/tools/systemd-env-format): Format assignments into canonical systemd EnvironmentFile text, one quoting mode per value.
- [Gitconfig key list](/tools/gitconfig-key-list): List git config keys in file order with qualified names and occurrences.
- [XML exc c14n subtree](/tools/xml-exc-c14n-subtree): Exclusive XML Canonicalization 1.0 of one selected element and its descendants.
- [XML exc c14n canonicalize](/tools/xml-exc-c14n-canonicalize): Exclusive XML Canonicalization 1.0 of a whole document, with an optional inclusive prefix list.
- [Xpath10 boolean](/tools/xpath10-boolean): Evaluate an XPath 1.0 boolean expression: comparisons, and, or, not, starts-with, contains, and boolean conversion.
