#ifndef SUIT_EXCLUDE_H
#define SUIT_EXCLUDE_H
#include <stddef.h>
#include <stdint.h>
// The block suit keeps in a git repository's local exclude file, so the links it
// places in a project stay out of that project's version control (docs/projects.md):
//
// # suit begin
// /.claude/skills/tdd
// # suit end
//
// Everything outside the block is left as it is. A file with no trailing newline
// gets one before the block and the block's last line has none, so taking the
// block out gives back the very bytes that were there.
constexpr size_t EXCLUDE_FILE_MAX = 1048576;
constexpr size_t EXCLUDE_PATH_MAX = 4096; // including the terminating NUL
constexpr size_t EXCLUDE_LINE_MAX = 16384; // twice the longest path below a project, and more
// The exclude file of the repository the git project at PROJECT belongs to: its
// own .git folder's, or for a linked worktree the main repository's, found
// through "gitdir:" and "commondir". Returns 0 or 1 after saying why.
[[nodiscard]] int exclude_path(const char *project, char *out, size_t cap);
// The line that hides REL, a path from a project's top with no leading "/":
// "/REL" with a backslash before each of \ * ? [ that would otherwise be a pattern.
// False if it does not fit.
[[nodiscard]] bool exclude_line(const char *rel, char *out, size_t cap);
// Make the block in PATH hold exactly the N LINES; with N 0, take the block out.
// CREATED says suit made the file: taking the block out of it then removes the
// file if nothing else is in it. With DRY nothing is written. CHANGED is set to
// whether the file's bytes differ, EXISTS to whether the file was there.
// Returns 0 or 1 after saying why.
[[nodiscard]] int exclude_edit(const char *path, const char *const *lines, uint32_t n, bool created,
bool dry, bool *changed, bool *exists);
#endif