Artifact 5d3dcb51a55443dd40c9b41293f511e7591a5a91394608283b4d51cda112debe:
- File
src/store.h
— part of check-in
[fe29cebc6a]
at
2026-11-13 20:38:51
on branch trunk
— Phase 7b-1: a wardrobe syncs with a remote, over file:// and http://
suit remote sets, shows or clears a wardrobe's remote address. An address that carries a user name or password is refused. suit login reads a secret from standard input into a credentials file of mode 0600, and suit refuses to use that file if anyone else can read it. The secret is never printed, never put in an error message or another file, and is wiped from memory after each use.
suit sync pulls, brings the working copy forward with the safe update, and pushes. When both sides have new check-ins it tries a merge as a dry run. A clean merge is checked in and pushed. A conflicting one changes no file, is pushed as a fork so nothing is lost, and is written to the attention file. No conflict marker is ever written to a live file. With local changes in the working copy the pull is kept and nothing else happens.
suit tend now continues into a sync after its check-in.
Three limits of libfossil, each handled here: its merge drops a file the other side deleted, so suit finds those itself and treats a delete against an edit as a conflict; a merge that changes no file cannot be checked in, so the files are put back and the fork stays open; and a file:// remote is reached through the stock fossil program, which must be on the path. http:// uses libfossil's own socket code and starts no other program.
An https:// address is accepted and stored, and syncing it says this build cannot use https yet. There is no clone command yet.
Also: LICENSE (BSD 2-Clause, the same as libfossil), a license section and current status in the README, and a state table in docs/phases.md.
1204 unit checks, 227 shell cases, 555 store cases, 612 placement cases and 378 project cases, under clang, under gcc 16, with no user name set, and under a strict umask. 100% coverage in all 22 source files. Seven fuzz targets. No suite has fewer cases than at the last check-in. (user: dmestas, size: 3761) [annotate] [blame] [check-ins using]
#ifndef SUIT_STORE_H #define SUIT_STORE_H constexpr int EXIT_LOCAL_CHANGES = 12; constexpr int EXIT_CONFLICT = 13; constexpr int EXIT_NOTHING_TO_UNDO = 14; constexpr int EXIT_NEEDS_REPAIR = 15; constexpr int EXIT_SYMLINK = 16; constexpr int EXIT_NETWORK = 17; constexpr int EXIT_NO_TLS = 18; constexpr int EXIT_REFUSED = 19; constexpr int EXIT_LINT = 3; constexpr int EXIT_HELD = 4; // The store of wardrobe NAME: a working copy in $SUIT_HOME/store/NAME of the // repository $SUIT_HOME/wardrobes/NAME.fossil. Each command returns an exit // code and reports on stderr (errors) or stdout (what changed). // While an update is in progress, or was interrupted, $SUIT_HOME/NAME.journal // names the version it is leaving and the version it is going to. Every // command but repair refuses with EXIT_NEEDS_REPAIR while it exists. // // Symlinks are not supported: libfossil's checkout writes them as regular // files. open and update refuse a version that holds one and commit refuses to // check one in, each with EXIT_SYMLINK and a message naming the path. // Open the wardrobe and create the working copy at trunk's tip if there is // none. Idempotent. int store_open(const char *name); // One line per local change: "edited PATH", "added PATH" or "deleted PATH". // Nothing when clean. Changes nothing. int store_status(const char *name); // Run the lint (docs/store.md, "The lint") on the local changes: nothing when // clean, else one "PATH:LINE: what" per problem on stderr and EXIT_LINT. It // changes no file. int store_lint(const char *name); // Check in every local change as the current user. Exit 0, and no check-in, // when there are none. EXIT_LINT, with the report and nothing checked in, when // the lint finds a problem. EXIT_HELD when the changes delete many files, // unless CONFIRM_DELETIONS. int store_commit(const char *name, const char *message, bool confirm_deletions); // What a timer calls: check in the local changes with a message saying how // many files, or leave what needs the user in $SUIT_HOME/attention // (docs/store.md, "suit tend"). EXIT_LINT or EXIT_HELD then. int store_tend(const char *name); // Pull from the wardrobe's remote, bring the working copy forward, merge a // fork if it merges cleanly, and push (docs/store.md, "suit sync"). Exit 0 // with nothing done when no remote is set. EXIT_LOCAL_CHANGES after the pull // when the working copy has changes; EXIT_CONFLICT when a fork would conflict // (nothing in the working copy changes; the local check-ins are still pushed); // EXIT_NETWORK when the remote cannot be reached or fails; EXIT_NO_TLS for an // https remote; EXIT_REFUSED when the remote refuses the login. int store_sync(const char *name); // Bring the working copy to trunk's tip. EXIT_LOCAL_CHANGES, listing the // files, if tracked files have changes. EXIT_CONFLICT, listing "conflict // PATH", if the update would conflict; nothing is changed then. int store_update(const char *name); // Bring every managed file back to the checked-in content of the version the // working copy records, using suit's file writer. EXIT_LOCAL_CHANGES, listing // them, if that would destroy local edits, unless an interrupted update left // a journal: then the files it partly replaced go back to the version it was // leaving. Clears the journal. Nothing to do is not an error. int store_repair(const char *name); // Say which version the working copy is at: "store NAME at UUID12". int store_show_version(const char *name); // EXIT_NEEDS_REPAIR, with a message, if an update of NAME did not finish; else 0. int store_check_journal(const char *name); // Undo the last update. EXIT_NOTHING_TO_UNDO if there is nothing to undo or // the store has moved on since. int store_back(const char *name); #endif