DEV Community

Cover image for My Fifty-Two-Day-Old Repo Gave Me the Wrong Answer
Mustafa ERBAY
Mustafa ERBAY

Posted on Originally published at mustafaerbay.com.tr

My Fifty-Two-Day-Old Repo Gave Me the Wrong Answer

I don't pick the order of articles on this blog. A measurement does. There are four categories — technology, tutorials, career, life — and whichever has gone longest without an article gets the next slot. I wrote that rule myself, because I don't trust my own reflexes: left alone, I would write about kernel tunables every single day, and the blog would become an instrument playing one note.

The rule itself is open to argument, of course: an earlier run today made the same measurement, saw career as the target, then moved to the next category because "that frame is saturated." So a measurement picks, but a measurement doesn't always get the last word.

This morning I ran the measurement. The answer was life.

It was wrong. The right answer was career — the category of the article you're reading. The measurement wasn't broken, the command was right, the arithmetic was right. The only wrong thing was which file it read from: a working tree 345 commits behind, frozen for fifty-two days.

This is the story of those fifty-two days. About how auditing a measurement isn't enough, and you also have to ask how old its input is.

Same command, two answers

The script that picks the category is simple: it sorts the generated entries in the calendar file by date, finds where each category last appeared, and returns the one furthest back. The file is scripts/content-calendar.json.

Read from the copy on disk (I added a total line to the script's two lines of output):

HEDEF KATEGORI: life
en son uretim sirasi: {'technology': 483, 'tutorials': 482, 'career': 484, 'life': 481}
toplam generated: 485
Enter fullscreen mode Exit fullscreen mode

The same script, run against the same file as it exists on origin/main:

HEDEF KATEGORI: career
en son uretim sirasi: {'technology': 620, 'tutorials': 622, 'career': 618, 'life': 621}
toplam generated: 623
Enter fullscreen mode Exit fullscreen mode

485 versus 623. 138 records sit in between, and none of them are in the file on disk. Both answers are internally flawless; one of them is just describing a world that ended in late September.

So I compared the file by its digest, because that is the shortest answer to "is this file current":

disk sha  : b138688a067e
main sha  : b138688a067e
origin sha: 2c0cf86f42d5
Enter fullscreen mode Exit fullscreen mode

The file on disk is byte-for-byte identical to the one the local main branch points at. Not to the version on origin/main. The last time the local branch moved is still sitting in the reflog: main@{2026-09-28}. Fifty-two days since then, 345 commits arrived, and the branch stayed put.

I fetched, and not a single file changed

The real trap here is that I started with the right step. The first line of my production recipe is git fetch origin main, and I ran it obediently. The output was reassuring too: new commits arrived, the range printed as d3a6bf46..5248dd35. You see that and you think, "good, I'm current."

I should also have looked at the size of that range: git rev-list --count d3a6bf46..5248dd35 → 1. That fetch brought a single commit. The gap of 345 was already in the object store, accumulated over weeks of earlier fetches. So the movement on my screen said nothing at all about the size of the gap being closed.

I shouldn't have, because git fetch states plainly what it does: "Remote-tracking branches are updated." The rest of that sentence only points at refspecs; it mentions nothing about your working tree, your local branch, or the files on your disk. Trusting the documentation's silence wouldn't have been right either, so I checked: the file's digest matches main's, not origin/main's. fetch puts new objects and a new origin/main pointer into the repository, then steps back. Your files stay where they were.

So fetch didn't make me current. It made me feel current. The command was honest; I was the one reading it wrong.

Diagram

What I dislike about that diagram is this: both arrows are legitimate. Go down the left branch and you get the wrong answer, but no command errors out, nothing flashes red. The wrong answer arrives in complete sentences, impeccably formatted.

Git told me, and I had shortened it

This is the part that stings. Git tried to warn me. I had switched the warning off with my own hand.

When I check whether a working area is clean, my habit is git status --short. Short, narrow, suited to automation. Here's what came back:

$ git status --short
[no output — 0 lines]
Enter fullscreen mode Exit fullscreen mode

Zero lines. Clean. Carry on.

Run the long form in the same repository:

$ git status
On branch main
Your branch is behind 'origin/main' by 345 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)
Enter fullscreen mode Exit fullscreen mode

The information was there from the start. Git even writes out the fix: it can be fast-forwarded, git pull is enough. Why does the short form swallow that line? Because it was designed to. In the git status documentation, the definition of -b / --branch is a single sentence: "Show the branch and tracking info even in short-format." That even — "even in short format" — is the admission that short format doesn't show it by default.

Add one letter and the warning comes back:

$ git status --short -b
## main...origin/main [behind 345]
Enter fullscreen mode Exit fullscreen mode

For anyone writing scripts, the machine format is sturdier; --porcelain=v2 --branch prints header lines with the number ready to parse:

# branch.oid a7b7bb600e505e66e6ea8565ff56d21d56d23a09
# branch.head main
# branch.upstream origin/main
# branch.ab +0 -345
Enter fullscreen mode Exit fullscreen mode

branch.ab +0 -345: zero ahead, 345 behind. The documentation also spells out the condition for that line — headers are printed only if --branch is given. Which means my missing -b isn't a lapse peculiar to one command; it's the same default repeating itself across two separate output formats.

I learned the lesson from the painful side: when you shorten output in automation, you need to know which line you are losing. I picked --short for speed and paid for it with the only meaningful warning on offer.

How big the blind spot is

A wrong category is a small accident — worst case, one extra life article. What bothers me is that the same stale tree also feeds the duplicate gate. Before starting a new topic, I grep src/content/blog/ to see whether the blog has already covered it. Grep looks at the files on disk.

How many Turkish articles are in the tree on disk, versus on origin/main:

Category On disk origin/main Invisible
technology 457 492 35
tutorials 380 416 36
career 257 290 33
life 199 234 35
Total 1293 1432 139

139 articles. And these aren't a random 139; they're the newest 139. So the slice where my duplicate scan goes blind is exactly the slice where duplication risk peaks: the topics that caught my interest in the last fifty-two days. Of the 345 commits, 306 touched src/content/blog — nearly the whole gap sits precisely where grep reads.

To test the theory, I picked seven keywords from October and November articles and searched both trees:

nagle          local=0   origin=1
minshall       local=0   origin=1
100-continue   local=0   origin=1
stdbuf         local=0   origin=2
ugrep          local=0   origin=1
unshare        local=3   origin=6
pax            local=8   origin=11
Enter fullscreen mode Exit fullscreen mode

Five of the seven searches return zero hits in the stale tree.

I was going to stop there and say the gate would have walked me into a duplicate. To be honest I re-read the gate's definition first, and couldn't stop: the gate has two legs. The first greps the files on disk; the second scans the titles in the live feed.json. The second one can't go stale, because it goes over the network and pulls the published list. So I searched the seven words against the live feed's 1,432 titles as well:

nagle 1 · minshall 1 · 100-continue 1 · stdbuf 1 · ugrep 1 · unshare 1 · pax 1
Enter fullscreen mode Exit fullscreen mode

All seven are there. The gate would not have told me "you've never covered it"; its first leg would come back blind and its second leg would catch them. In fact all 139 invisible articles are in the feed — at title level the blind spot is zero.

That's a less dramatic sentence than the one I first wanted, and a truer one. But it doesn't remove the blind spot, it relocates it: the second leg only looks at titles. If a topic is discussed at length inside an article's body and never reaches the title, the second leg can't see it — and if that article is from the last fifty-two days, neither can the first. Where the two blindnesses overlap, the gate stands wide open.

So I put a number on that residual risk as well. Across the bodies of the 139 invisible articles there are 1,094 distinct backticked mechanism names (sha-like strings excluded). 963 of them — 88% — appear in no feed title at all: alloc_pipe_info, allow_discards, analysis_limit, and so on. That's where the gate is genuinely blind, and it's a far narrower, far sneakier place than the "it would miss everything" I first wrote.

My worry about duplicates isn't idle, either: my own notes say that in October a stale tree once cost me a finished article, thrown away (16 October). There's no trace of it in the repository — the discarded piece was never committed, so that note is all there is, and I'll name my evidence for what it is. In the piece where I counted seventy accumulated branches I wrote about counting the same repository four different ways and getting four different answers. Back then the problem was the counting method. This time the method is right and the source is stale — and the second is sneakier, because auditing your method becomes a habit while asking the age of your input never does.

The stale copy did look sick, and I didn't look

For a while this morning I defended myself like this: "if the numbers were off, surely I'd notice it in the data." To test that, I checked whether category rotation was healthy in both copies — the category distribution of the last thirty generated entries:

Window technology tutorials career life
origin/main, last 30 (19 Oct – 19 Nov) 7 8 7 8
Copy on disk, last 30 (19–28 Sept) 17 4 5 4

My defence collapsed, but not where I expected. The stale copy did look sick: seventeen of thirty entries, 57%, in a single category. That is not something that escapes anyone who opens the table and looks.

The trouble is that the table leads you to the wrong diagnosis. You say "rotation is broken, the rule isn't working," and you sit down to repair the rule. The rule is working fine — the file you're reading is old. The data doesn't tell you it's stale; it impersonates a different fault. That's more dangerous than a wrong answer: notice a wrong answer and you correct it, but a wrong diagnosis sends you off to break a mechanism that was working.

Where that 57% comes from is no mystery. The window on disk falls on 19–28 September, and those days are the reason the rotation rule exists: in the piece about forty-four articles in a row from a single category I went through that stretch in detail. Of the 52 entries generated between 7 and 23 September, 51 are technology. The rule was put in place so that table never recurs, and today it's doing its job — 7/8/7/8 in the origin/main window.

So the stale copy was telling me two lies at once: the next category is life (wrong), and the rotation itself is broken (wrong). Both have a single antidote, and it isn't inside the file: the commit the file came from.

How many doors open onto the same trap

One measurement returning a wrong answer is an accident. Knowing how many separate doors the same trap stands open behind turns the accident into a structure. So I searched the repository with that question: how many scripts read content files from disk, and how many name the revision they're reading? (Scope: .mjs/.ts/.sh files at the root of scripts/; the data file and scripts/tests/ excluded.)

  • Scripts that read under src/content/blog: 22
  • Of those, scripts that mention origin/main: 1

One. Twenty-one of twenty-two doors don't say which day's content they're looking at. None of them is broken — each was written on the assumption of "the files in the directory you're standing in," which is correct while the working tree is current. The problem is that the assumption is written down nowhere, and an unwritten assumption goes unaudited.

I also looked into why that one is protected, fully prepared to congratulate myself for having got something right somewhere. The congratulation didn't survive. measure-defab-coverage.mjs is one of the two history-analysis scripts, and both contain the same line:

const REV = opt('rev', 'origin/main');
Enter fullscreen mode Exit fullscreen mode

So origin/main there isn't a safeguard against staleness — it's the default value of a parameter. That script exists to answer "what did things look like at revision X"; the revision is written out because it's part of the question. The protection falls out of the shape of the problem, not out of a decision.

The detail that stings most sits in the file next to it. measure-article-promises.mjs is measure- prefixed too, and it also produces a measurement that goes to press — a count of the promises I've made to readers — but it takes the content directory from disk, with no revision named anywhere. So being a "measurement script" buys no protection; protection arrives only when the question already contains a revision.

That's a more uncomfortable finding than I hoped for. If one door were safe I'd want to find a design decision behind it; seeing it as a by-product reveals that the other twenty-one were never considered at all. Being protected against a class of fault and never having noticed that class of fault look identical from the outside.

Why this particular copy goes stale

Today there are sixteen working trees in the repository (a daily cleanup job deletes old ones, so the number moves). Most are copies opened for a single job and abandoned when it finished. Here is every one's distance from origin/main:

717   makale-prova-llm-router
428   nervous-elion-e2729f
345   mustafaerbay          <-- canonical checkout
213   makale-20261014-1333
...
2     tutorials-20261119-1340
0     career-20261119-1634  <-- this article
Enter fullscreen mode Exit fullscreen mode

Fifteen of sixteen trees are behind. At first glance the table reads like "the same disease everywhere." It isn't. Transient trees being behind is not a problem — they were born as a photograph of a particular commit, the job is done, they'll be deleted. A photograph growing old isn't a defect.

Exactly one line in that list is different: the third. mustafaerbay, the copy I return to. It's where my fingers go when I open a terminal. It's the directory the scheduled job starts in each morning. It's the default for every new session. And that copy — the one everybody passes through — is the one nobody updates, because the real work always happens in some other tree, commits go straight to origin/main, and bringing the canonical checkout current requires someone to remember a git pull that is nobody's job.

Corporate life has a name for the same thing: the final_FINAL_v2 file on the shared drive. Nobody owns it, everybody reads it.

My recipe even has a gate for this. In the first draft I was going to blame that gate for asking the wrong question; then I opened the rule and read it in full:

git fetch origin main. If the working area is dirty, open a worktree; always work from a current origin/main base.

Nothing is missing from the rule. It forbids staleness by name, in the very same sentence. What I did was read the first half as a gate and the second half as a statement of intent. And the difference between those is exactly this article's problem: the first half has a measuring command behind it (git status, dirty or not), while the second half's measurement is written down nowhere. I obeyed the half that could be measured and waved past the half that couldn't with "I do that anyway."

The tree wasn't dirty — it was spotless. The danger wasn't dirt, it was staleness. The zero lines from git status --short give the two the same appearance: a clean tree and a tree frozen fifty-two days ago look exactly alike on screen, which is to say they look like nothing at all. Had the rule's second half carried a measurement too, those zero lines would have turned into a warning.

There are two numbers, and I never asked about one

Note the two signs in that branch.ab +0 -345 line: plus is ahead, minus is behind. Today my trouble is the minus side — the side that poisons reads. But the plus side staying quiet is also news, and today it's good news: zero. There is not one commit on my local branch that's missing from origin/main.

The risk of the two numbers isn't symmetric. Being behind corrupts what you read: the wrong category, a blind duplicate gate, correct-looking numbers computed from an old file. Being ahead corrupts what you write: something you left half-finished in your own tree rides along on the next push. The first makes you decide wrongly, the second makes you publish wrongly; and the second costs more to undo, because taking something back out of a published history means writing a new commit, and the record stays.

My own history carries the mark of the second kind, and reading that mark I collided with this article's thesis a second time. A draft article and its fix landed on main, then two Revert commits took both back out. Ask "when?" and git hands you two different dates:

5b505d95  AUTH=2026-09-21 12:02:15  COMM=2026-09-22 09:18:46  feat: new article — ispmanager...
6003feb2  AUTH=2026-09-21 12:39:10  COMM=2026-09-22 09:18:46  fix(ispmanager): final audit...
fd17e0ff  AUTH=2026-09-22 09:20:13  COMM=2026-09-22 09:20:13  Revert "fix(ispmanager)..."
58e78af2  AUTH=2026-09-22 09:20:13  COMM=2026-09-22 09:20:13  Revert "feat: new article..."
Enter fullscreen mode Exit fullscreen mode

Written on 21 September, landed on main on 22 September at 09:18:46 — the gap between the two is a rebase's fingerprint. The reverts come at 09:20:13. So those two commits lived on main for 87 seconds, not a day. The first version of this paragraph said "the next day"; I had read the author date and never asked for the committer date. Not knowing which date you're reading is the very subject of this article — and I made that exact mistake while writing it.

The article was published on 2 October, when it was ready, at a different address. So the outcome was fine — but there are four lines in the history: two landings, two reverts. A revert isn't a quiet correction; it's a new commit written to main, permanent.

The lesson in between: being behind gives you a wrong answer, being ahead says a sentence on your behalf. Noticing the first takes a measurement; noticing the second usually takes somebody telling you.

What I changed

What saved today wasn't a fast-forward, it was naming the source. Trusting the file on disk not at all, I ran the measurement against origin/main:

git show origin/main:scripts/content-calendar.json > /tmp/cal.json
Enter fullscreen mode Exit fullscreen mode

And the actual work went into a new tree that takes origin/main as its base, explicitly:

git worktree add -b nobetci/career .claude/worktrees/career origin/main
Enter fullscreen mode Exit fullscreen mode

The documentation is clear about what that does: it checks the given commit-ish out into the new directory, sharing everything with the repository except per-worktree files such as HEAD and the index. Because the base is written out, the question "which day's copy is this" is answered inside the command; it no longer depends on remembering.

The checklist I drew up for myself, in order:

  • If a measurement reads a file, you must be able to say which commit that file came from. If you can't, the measurement isn't finished yet.
  • Don't mistake fetch for currency. fetch brings pointers, not files.
  • When checking status, add -b (git status -sb); in scripts, read branch.ab via --porcelain=v2 --branch. If it isn't zero, stop.
  • If you're going to work in a persistent directory, fast-forward first; when git says pull, use --ff-only so it doesn't quietly spawn a merge commit.
  • Sturdiest of all: write the base into the command. worktree add ... origin/main is the one form that leans on no human memory.
  • And the real cure is prevention, not detection: don't touch the persistent directory at all, start every run from a fresh tree off origin/main. The gate is there for the days that habit slips.

For anyone who wants it in a script, I first wrote the gate in three lines:

behind=$(git status --porcelain=v2 --branch | awk '$2=="branch.ab"{print $4}')
[ "${behind#-}" -gt 0 ] && echo "STOP: working tree ${behind#-} commits behind" && exit 1
Enter fullscreen mode Exit fullscreen mode

Then I read the condition in the documentation: the # branch.ab line is printed only "if upstream is set and the commit is present." On a branch with no upstream — or on a detached HEAD — the line never arrives. I tried it in an empty repository: the variable stays empty, the comparison errors, and the script exits zero. So in the case it cannot judge, the gate lets you through; the exact opposite of why it exists. And the person who lands in that state is whoever opens a branch with worktree add -b without an upstream — that is, whoever follows the solution this article recommends.

Closed up:

hdr=$(git status --porcelain=v2 --branch)
grep -q '^# branch.upstream ' <<<"$hdr" || { echo "STOP: no upstream, staleness unmeasurable"; exit 1; }
behind=$(awk '$2=="branch.ab"{print $4}' <<<"$hdr")
[ "${behind#-}" -gt 0 ] && { echo "STOP: ${behind#-} commits behind"; exit 1; }
Enter fullscreen mode Exit fullscreen mode

Writing that, one more thing surfaced: this gate has a hard time in CI. actions/checkout leaves you on a detached HEAD by default, so there the gate would shout "no upstream" on every run. CI already starts from a fresh clone each time; the gate isn't CI's problem, it's the problem of persistent directories. So that's where mine goes: the first step of the scheduled job.

But I wouldn't put that gate everywhere, because being behind isn't always a fault. If you're reproducing an old behaviour, squeezing a bug with bisect, or asking "what was in this file three months ago," being behind is the whole point. The gate isn't there to forbid being behind; it's there to forbid deciding without knowing you're behind. Which is why I want it on the steps that make a choice, not on every command: the steps that pick a topic, search for duplicates, or produce a number that goes to press.

I also noted the figure: fifty-two days. That's not how long the warning failed to arrive — it's how long I had been shortening the warning myself.

Closing

The real lesson turned out to be about automation, not measurement. When I bind a rule into code ("measure, don't assume"), I audit the rule itself: is the command right, is the arithmetic right, were the edge cases considered. The thing I never audited was where the rule is fed from. Today's fault wasn't inside the rule; it was in the file I had placed in the rule's mouth.

A measurement can be no fresher than the copy it reads. And a copy's freshness has nothing to do with its cleanliness — git can wave both past you with the same silence. If there's a default directory where a scheduled job begins, that directory is the place you trust most and look at least; noticing that three scripts still called the old name after I moved the repository came out of a similar lapse of attention.

This article is the product of that audit. The stale copy said "life category"; origin/main said "career." Because I listened to the second one, what you're holding is a career article. Had I not run the measurement from two sources, today I would have published a piece in the wrong category, probably on a topic already covered — and not one command would have reported an error.

Official Sources

Top comments (0)