Skip to content

Commit 5f454dd

Browse files
alex-plosceacclaude
andcommitted
fix(artifact): put binary macro before merge=ours in generated .gitattributes
gitattributes apply left to right and the binary macro expands to -diff -merge -text, so the generated line graph.db.zst merge=ours binary leaves the merge attribute UNSET (git check-attr merge reports "unset"), and concurrent artifact refreshes produce a binary merge conflict instead of auto-resolving -- the exact failure this file is generated to prevent. Reordering to graph.db.zst binary merge=ours makes check-attr report merge: ours while keeping -diff/-text intact. Verified on a real repository: before the reorder git check-attr merge -- .codebase-memory/graph.db.zst printed "unset"; after, "ours". Extends artifact_gitattributes_created to pin the ordering so the regression cannot return. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Alex <plosceac.alexandre@gmail.com>
1 parent f092d92 commit 5f454dd

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

‎src/pipeline/artifact.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,13 @@ static void ensure_gitattributes(const char *repo_path) {
382382
} else {
383383
FILE *fp = fdopen(fd, "w");
384384
if (fp) {
385+
/* Order matters: attributes apply left to right and the `binary`
386+
* macro expands to `-diff -merge -text`, so a trailing `binary`
387+
* unsets `merge=ours` and the conflict prevention this file
388+
* exists for never engages. The macro must come first. */
385389
(void)fputs("# Auto-generated by codebase-memory-mcp\n"
386390
"# Prevent merge conflicts on compressed artifact\n" CBM_ARTIFACT_FILENAME
387-
" merge=ours binary\n",
391+
" binary merge=ours\n",
388392
fp);
389393
(void)fclose(fp);
390394
} else {

‎tests/test_artifact.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,20 @@ TEST(artifact_gitattributes_created) {
242242
struct stat st;
243243
ASSERT_EQ(stat(ga, &st), 0);
244244

245+
/* Attribute ORDER is load-bearing: gitattributes apply left to right and
246+
* the `binary` macro expands to `-diff -merge -text`, so a trailing
247+
* `binary` unsets a preceding `merge=ours` (git check-attr merge reports
248+
* "unset" and concurrent artifact refreshes produce binary conflicts
249+
* instead of auto-resolving). The driver must come after the macro. */
250+
FILE *gaf = fopen(ga, "r");
251+
ASSERT_NOT_NULL(gaf);
252+
char content[512] = {0};
253+
size_t rd = fread(content, 1, sizeof(content) - 1, gaf);
254+
(void)fclose(gaf);
255+
ASSERT_TRUE(rd > 0);
256+
ASSERT_NOT_NULL(strstr(content, CBM_ARTIFACT_FILENAME " binary merge=ours"));
257+
ASSERT_TRUE(strstr(content, "merge=ours binary") == NULL);
258+
245259
cleanup_dir(g_tmpdir);
246260
PASS();
247261
}

0 commit comments

Comments
 (0)