pfx

Got questions or doubts? Ping me on Discord

Scenes diff like code

A .pitofx in git reads as TOML.

What the diff shows

A .pitofx is compressed, so git sees it as binary and git diff says only Binary files differ. pfx gives git a text view of it instead: git diff, git log -p and git show print the document as TOML, so a scene change reads like a code change. The file in the repository stays the .pitofx.

  • One value, one line

    Change one value and the diff shows that line, with the recipe's new hash in the metadata. The TOML entries print whole: the scene's metadata, the recipe, each scene file, each .toml file the document holds and the builder's overrides.

  • No churn

    Entries print in an order set by what the document holds, never by where its chunks sit, so an edit in place, a compact and a save that writes the chunks in another order print the same text.

  • Packed files, one line

    Each other entry prints one line, its size and its CRC-32: packed meshes, images and other files, the build's entries and the thumbnail. Nothing is decompressed to list it, so the diff of a document holding gigabytes of meshes costs what its TOML costs.

  • Merges stay binary

    When two branches change the same document, git keeps the current branch's copy and reports a conflict. Carry the other side's edits over with pfx scene print and pfx scene write, or in the editor.

Measured

Setup, per clone
1 command
docs/git.md
A packed file in the diff
1 line
docs/git.md
Decompressed to list it
0 bytes
docs/git.md

How to use it

  1. Run it once, from inside the repository:

    pfx git setup
  2. Each clone runs it once. pfx new does it for you when it scaffolds a game inside a git repository.

  3. Run again, pfx git setup changes nothing and says already there. Outside a git repository it refuses in one line and exits 1. With --json it prints one object: the repository, the attributes line and each config key, each with whether it changed. Git and pfx must both be on PATH, since git runs the driver by name.

What it writes

Two things and nothing else.

  • .gitattributes

    At the repository's top, appended when no line for *.pitofx names diff=pitofx yet. Commit it, so every clone tags its .pitofx files the same way.

    *.pitofx diff=pitofx
  • Local git config

    In .git/config, never the global one. Git keeps local config out of commits, so each clone runs pfx git setup once; without it, git falls back to Binary files differ.

    diff.pitofx.textconv = pfx scene print --all
    diff.pitofx.binary = false
  • By hand

    The same two steps without pfx git setup:

    echo '*.pitofx diff=pitofx' >> .gitattributes
    git config diff.pitofx.textconv 'pfx scene print --all'

Build on pfx

pfx is open source under the AGPL-3.0: free for open-source projects, learning and hobby work. Read it, fork it, and send issues and pull requests on GitHub. Closed products and services built on pfx take a licence: free under $200k of yearly revenue plus funding, Indie and Pro above it.

© Catalin Ilinca, AGPL-3.0-only, with licences for closed products; releases up to 3.1.1 remain MIT. The PITO MD name, the pfx name and its logo are © Catalin Ilinca, all rights reserved.

Every picture and clip on this page is pfx's own, rendered or captured from its neutral scenes and licensed with its code (pfx's NOTICE.md); the pfx gui and game-editor clips were recorded by pfx from its v3.0.1 tag, the terminal clips with prec, the loops encoded with pito-codecs and the charts drawn with pito-compare from the numbers pfx v3.1.2 measures. Type: Exo 2 by NDISCOVER ( SIL Open Font License 1.1 ) and JetBrains Mono by JetBrains ( SIL Open Font License 1.1 ), from pfx's theme.