Build system modifies tracked src/gitversion.h.in #139

Closed
opened 2026-06-23 11:56:06 +00:00 by jabber.developer · 0 comments

Motivation

src/gitversion.h.in is a git-tracked file that the build system (make)
modifies in-place on every build. This causes uncommitted changes to appear
in the working tree after running make, which:

  1. Blocks clean branch switchesgit checkout to another branch shows
    src/gitversion.h.in as modified; switching requires git checkout -- src/gitversion.h.in
    or git restore src/gitversion.h.in to clear the changes first.
  2. Creates merge conflicts — if a branch that touched .gitversion.h.in
    is merged while the file has local modifications, conflicts arise.
  3. Confuses git status — every build after a clean checkout shows dirty
    working tree, making it hard to track actual source changes.
  4. Wastes time — developers need to manually reset this file repeatedly
    when switching branches or after running make.

Root cause

The Makefile has a rule that deletes and recreates src/gitversion.h.in
from scratch on every build:

$(git_include).in: .git/HEAD .git/index
	rm -f $@
	echo "#ifndef PROF_GIT_BRANCH" >> $@
	echo "#define PROF_GIT_BRANCH \"$(shell git rev-parse --symbolic-full-name --abbrev-ref HEAD)\"" >> $@
	...

This rule writes concrete values (e.g. "feat/autoping-warning", "b5bbad8d")
directly into the tracked .in file, instead of using it as a static template
with @VAR@ placeholders.

The file is listed in .gitignore (line 45) but remains tracked because
.gitignore only affects untracked files — already-tracked files are not
ignored.

Acceptance Criteria

  • AC-1: make invocation does not cause git-tracked change in src/gitversion.h.in
## Motivation `src/gitversion.h.in` is a git-tracked file that the build system (`make`) modifies in-place on every build. This causes uncommitted changes to appear in the working tree after running `make`, which: 1. **Blocks clean branch switches** — `git checkout` to another branch shows `src/gitversion.h.in` as modified; switching requires `git checkout -- src/gitversion.h.in` or `git restore src/gitversion.h.in` to clear the changes first. 2. **Creates merge conflicts** — if a branch that touched `.gitversion.h.in` is merged while the file has local modifications, conflicts arise. 3. **Confuses `git status`** — every build after a clean checkout shows dirty working tree, making it hard to track actual source changes. 4. **Wastes time** — developers need to manually reset this file repeatedly when switching branches or after running `make`. ## Root cause The Makefile has a rule that **deletes and recreates** `src/gitversion.h.in` from scratch on every build: ```make $(git_include).in: .git/HEAD .git/index rm -f $@ echo "#ifndef PROF_GIT_BRANCH" >> $@ echo "#define PROF_GIT_BRANCH \"$(shell git rev-parse --symbolic-full-name --abbrev-ref HEAD)\"" >> $@ ... ``` This rule writes concrete values (e.g. `"feat/autoping-warning"`, `"b5bbad8d"`) directly into the tracked `.in` file, instead of using it as a static template with `@VAR@` placeholders. The file is listed in `.gitignore` (line 45) but remains tracked because `.gitignore` only affects untracked files — already-tracked files are not ignored. ## Acceptance Criteria - [ ] AC-1: `make` invocation does not cause git-tracked change in `src/gitversion.h.in`
jabber.developer added the
Kind/Bug
Reviewed
Confirmed
1
Priority
Medium
3
labels 2026-06-23 11:56:06 +00:00
jabber.developer2 was assigned by jabber.developer 2026-06-23 11:56:06 +00:00
jabber.developer added this to the Plans (2025-2026) project 2026-06-23 12:29:34 +00:00
jabber.developer moved this to In Progress in Plans (2025-2026) on 2026-06-23 12:29:59 +00:00
jabber.developer moved this to Verification in Plans (2025-2026) on 2026-06-23 12:30:04 +00:00
jabber.developer moved this to Done in Plans (2025-2026) on 2026-06-24 07:31:43 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: devs/cproof#139
No description provided.