![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
Corrected against 3391f4c22e on 2026-09-29. The audit before that found 9 claims in this file wrong of the tree and 5 stale. This file is a post-mortem of a split that happened, so most of its numbers are of the tree at the split (49284929dc) and are correct as history — they are marked where the current figure differs. Two claims were genuinely overtaken: the exiv2 lock has since been deleted outright, and src/history now exists. Re-measure before acting on a claim older than the code you are changing, and re-date this line when you do.
Done. common/exif.cc (4775 lines) is now metadata/exif.cc (2226) and common/xmp_sidecar.cc (2687), with metadata/exif_internal.h (89) holding what genuinely spans both — measured at the split, 49284929dc. Today they are 2455, 2691 and 114: both halves have been worked on since, so use those figures as the split's, not the tree's.
Measured by brace-matched function parsing plus transitive reference closure (tools/include_graph.py has no notion of intra-file structure, so this was done ad hoc; the scripts are in the PR discussion).
exif.cc handled two unrelated things that meet only in the XMP document:
| half | fns | own lines |
|---|---|---|
| EXIF/IPTC tags — what the photograph says about itself | 27 | 1673 |
| XMP sidecar carrying the development | 36 | 2442 |
| seam — wanted by both | 8 | 429 |
| unreachable from either | 2 | 37 |
The five history-side roots are the whole XMP sidecar API plus one blob writer:
dt_exif_xmp_read reads history, masks, module order back dt_exif_read_blob dt_imageio_dng_write_tiff_header dt_exif_xmp_attach_export dt_exif_xmp_write_with_imgpath dt_exif_xmp_read_string
They reach nine dt_ioppr_* symbols (deserialize_text_iop_order_list, get_iop_order_link, get_iop_order_list, get_iop_order_list_version, get_iop_order_version, has_multiple_instances, insert_missing_modules, serialize_text_iop_order_list, and one more), dt_develop_blend_params_t and dt_masks_form_group_t — i.e. develop/ (layer 5). dt_imageio_dng_write_tiff_header does not belong on that list: its only occurrence in the sidecar is inside a comment (xmp_sidecar.cc:465, "we don't write the orientation here for dng as it is set in `dt_imageio_dng_write_tiff_header`"), and it is a static inline in imageio/. The imageio/imageio_core.h include at :126 is real; that symbol is not what asks for it. The tag half reaches nothing above layer 1, which is what made the cut worth making: metadata/exif.cc sits in the module and the gate still reads zero.
Worth not re-deriving, because each one silently moved functions into the wrong half:
Two functions are reachable from no root at all and are simply dead: print_history_entry (already __attribute__((unused))) and _get_max_multi_priority. Both went with the sidecar; neither is called.
Also verified: dt_exif_read is NOT history-tainted. An earlier classification said otherwise; it is reachable from a history root without being one, which is a different thing.
src/metadata/exif_internal.h — at the split: class Lock, read_metadata_threadsafe, and three functions: dt_remove_exif_keys, dt_exif_read_exif_tag, dt_exif_decode_xmp_data. Private to those two .cc files by convention; a third includer is the signal to promote something into exif.h deliberately instead.
The lock has since been deleted outright (db6eacb8dd, 2026-08-27). exif_internal.h:80-88 now carries the reasoning in place of the macro: exiv2 0.27.7's Exif and IPTC code is reentrant and its XMP path serialises itself, so the only entry points that are not thread-safe are XmpParser::initialize() and XmpProperties::registerNs(), which Ansel calls exclusively from dt_exif_init() before any thread exists (doc/lock-audit.md). The macro went with the lock rather than being left as a no-op, on the stated grounds that a wrapper called "threadsafe" which does nothing is worse than no wrapper, because it reads like a guarantee. Call image->readMetadata() directly.
#include "darktable.h" is gone from both halves. Its only real use was darktable.exiv2_threadsafe inside class Lock, which went through the dt_exiv2_threadsafe_mutex() accessor in common/global_mutexes.h — both are gone now; that header declares only dt_pipeline_threadsafe_mutex(). Every other darktable. in the file is an XMP key string (Xmp.darktable.history).
Five deliberate edits beyond pure code motion, and nothing else:
A forward token search across this file has already destroyed 117 lines once (see [[scripted-region-replacement]] in the project notes): the failure mode is silent, and only -Werror=unused-but-set-variable in the Debug build caught it. So the cut was done by assigning every byte of the original to exactly one destination and asserting, before writing anything:
One trap the assertions surfaced: a segment boundary falls where the previous statement ended, which is mid-line whenever that line carries a trailing comment (static const guint dt_xmp_keys_n = ...; // the number of keys). The comment then lands in the other file. Every boundary is snapped forward to the next line start, and any boundary with real code after it is reported rather than moved.
Export A/B against the pre-split build on _DSC9410.NEF with --export_masks 1 — a 57-node brush, so the XMP history and masks_history read paths both run, and the mask is written out as a second TIFF page. Zero differing pixels, on both pages (6016x4016x3, uint8), max abs diff 0.
Compare decoded pixel arrays, not file bytes. cmp -l on the two TIFFs reports ~19.2 million differing bytes of 19.4 million — because the exported file embeds the build's version string and two timestamps, and when those change length every byte after them shifts. Two runs of the same binary differ that way; the files came out 19396008, 19396010 and 19396012 bytes across three runs. A byte comparison here answers a different question than the one being asked, and answers it wrongly. This is the trap CLAUDE.md records for PNG exports, and it applies to TIFF for the same reason:
ok, pages = cv2.imreadmulti(path, flags=cv2.IMREAD_UNCHANGED) # both pages d = np.abs(a.astype(np.int64) - b.astype(np.int64)) # per page
The sidecar belongs in src/history: it serialises the development, not the photograph. It stayed in common/ only until that module existed — and the module now does (src/history/: history, history_snapshot, notify, presets; it landed 32 minutes after this split). common/xmp_sidecar.cc has not moved and is the one file this plan named that is still waiting. It already includes history/history.h (:115) alongside its three develop/ includes (:123-125) and imageio/imageio_core.h (:126), so the move is blocked on the same thing doc/history-split.md names: the sidecar reaches 26 dt_dev/dt_iop/dt_ioppr/ dt_masks/dt_develop_blend sites, which is layer-5 work, and src/history is layer 1. It moves when those reaches are inverted or when it is accepted at layer 5 — not before. Its five entry points keep their dt_exif_* names so this cut stays reviewable; renaming them is that move's business.
Moving 2687 lines into a new file made every line of it "new" to SonarCloud, so the split drew nine code-scanning alerts on common/xmp_sidecar.cc. They are not all the same thing, and the triage is the useful part:
Re-verified the same way, on decoded pixel arrays: zero differing pixels against the pre-split reference, both pages, max abs diff 0.