Artifact 0fcdea4cc4d32490fbf31c671ac5986fcf0d2acf24ec35cb251afd60e0c4bb5b:
- File
src/attention.h
— part of check-in
[db386ba414]
at
2026-11-16 14:13:46
on branch trunk
— An upstream's attention item survives tend and goes when it is settled
Two faults in how upstream items were kept.
suit tend removes a wardrobe's items without naming a kind, and that matched the item of an upstream with the same name, so a pending update was forgotten until someone ran suit upstreams. A remove with no kind now leaves upstream items alone. The item's text is unchanged and files written before this read as before.
A machine that had taken an upstream kept its item after the update was accepted on another machine and synced here. After the working copy is updated, every upstream whose tip the tracked file upstreams/NAME records as accepted has its item removed; one still waiting keeps its item. With no upstream branch this costs one query.
26 new store cases: a wardrobe and an upstream of one name through take, tend and accept; a file in the old form; two machines; and the read, open and rename failures.
1473 unit checks, 620 shell cases, 994 store cases (was 968), 846 placement cases and 378 project cases, under clang, under gcc 16, with no user name set, and under a strict umask, in one run of make gate (43 minutes). 100% coverage in all 26 source files. No existing case was changed. (user: dmestas, size: 2604) [annotate] [blame] [check-ins using]
#ifndef SUIT_ATTENTION_H #define SUIT_ATTENTION_H #include <stdbool.h> #include <stddef.h> // $SUIT_HOME/attention: what needs the user. An item is a line, "KIND NAME" // or "KIND NAME: what", and the lines indented by two spaces after it, which // belong to it. The file is written beside, synced and renamed, and is removed // when it would be empty. Each returns 0, or 1 after saying what failed. constexpr size_t ATTENTION_FILE_MAX = 131072; // The kind of an upstream's item, "upstream NAME: ...". NAME is the upstream's, // not a wardrobe's, so a call with no kind (a wardrobe's items) never matches // one, whatever the names. constexpr char ATTENTION_UPSTREAM[] = "upstream"; // Take out the items of NAME, of kind KIND (every kind but ATTENTION_UPSTREAM // if null). Writes nothing when there is none. int attention_remove(const char *path, const char *kind, const char *name); // Replace the item KIND NAME with HEADER and DETAILS: lines, each ending in a // newline, kept under it indented (null for none). Writes nothing when the // file would not change. int attention_add(const char *path, const char *kind, const char *name, const char *header, const char *details); // Make the items of kind KIND be exactly the N given: HEADERS[i] (a line with // no newline) under NAMES[i]. An item already there with its header as given // stays where it is; one that is not wanted, or whose header differs, is // taken out; one missing is added at the end. Items of other kinds are not // touched. Writes nothing when the file would not change, and removes it when // it would be empty. N is at most ATTENTION_SYNC_MAX. constexpr size_t ATTENTION_SYNC_MAX = 256; int attention_sync(const char *path, const char *kind, size_t n, const char *const *names, const char *const *headers); // Print "needs you:" and the file's lines, or nothing when there are none. int attention_print(const char *path); // How many items the file holds: its lines that are not indented. 0 in *COUNT // when it is not there. Returns 0, or 1 after saying what failed. int attention_count(const char *path, unsigned *count); // Whether the item KIND NAME is in the file: false in *HAS when it is not // there. Returns 0, or 1 after saying what failed. int attention_has(const char *path, const char *kind, const char *name, bool *has); // The header line of the item KIND NAME, copied to HEADER (CAP bytes, cut if // longer): empty when there is no such item. Returns 0, or 1 after saying // what failed. int attention_header(const char *path, const char *kind, const char *name, char *header, size_t cap); #endif