Artifact 5e1e48eac621eaefaf8d3ede1e82d0e949b587b6b3c1fe00503e71b0d7bd085f:
- File
cli/repo_timeline.go
— part of check-in
[9564ccad55]
at
2026-07-19 15:25:18
on branch trunk
— fix: tolerate NULL event.user/comment in manifest.Log (#47)
Fossil's check-in manifests require only the D and Z cards; the U-card (user) and C-card (comment) are optional, and canonical fossil binds a missing U-card as SQL NULL on the event row. manifest.Log scanned both columns into plain strings, so any repository containing such a check-in failed the entire walk with "converting NULL to string is unsupported" and returned zero rows.
Scan event.user and event.comment through sql.NullString and use its zero-value String field, so a NULL column becomes "" without changing LogEntry's public shape - no nullable type leaks out, and no caller has to know NULL was ever possible. Non-NULL columns are unaffected.
repo timeline now renders an empty user as "?", matching canonical fossil's coalesce(euser,user,'?') TTY output; the substitution stays in the CLI's presentation layer, not the library.
Fixes #44 (user: [email protected], size: 1123) [annotate] [blame] [check-ins using]
package cli import ( "fmt" libfossil "github.com/danmestas/libfossil" ) // RepoTimelineCmd shows repository timeline/history. type RepoTimelineCmd struct { Limit int `short:"n" default:"20" help:"Number of entries"` } func (c *RepoTimelineCmd) Run(g *Globals) error { r, err := g.OpenRepo() if err != nil { return err } defer r.Close() tipRid, err := resolveRID(r, "") if err != nil { return err } entries, err := r.Timeline(libfossil.LogOpts{Start: tipRid, Limit: c.Limit}) if err != nil { return err } for _, e := range entries { uuid := e.UUID if len(uuid) > 10 { uuid = uuid[:10] } // A check-in with no recorded user (event.user IS NULL) comes back // from the library as "" — LogEntry.User never leaks a nullable type. // Canonical fossil renders that case as "?" on the TTY // (coalesce(euser,user,'?') in timeline_query_for_tty()); match it // here at the presentation boundary rather than in the library. user := e.User if user == "" { user = "?" } fmt.Printf("%s %s %s %s\n", uuid, e.Time.Format("2006-01-02 15:04"), user, e.Comment) } return nil }