Skip to content
suit Artifact [b44f762e57]
Login

Artifact [b44f762e57]

Artifact b44f762e57c412df394a67423da06129a071197fefb910bc08267c7678850202:


#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;

// 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);

// Check in every local change as the current user. Exit 0, and no check-in,
// when there are none.
int store_commit(const char *name, const char *message);

// 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);

// 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