From c65936fba8bf334d6712735d4135a837acbeaee5 Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Sun, 2 Aug 2026 05:34:51 +0200 Subject: [PATCH] Makefile: fix docker-check/docker-indent from a git worktree citus_indent calls `git ls-files` to find the files it should check. When run from a git worktree, the worktree's own .git is only a pointer file ("gitdir: /.git/worktrees/") to a path outside the mounted volume, so that call failed with "not a git repository" / "could not list files under source control" inside the container. Resolve the real common git dir on the host (git rev-parse --git-common-dir) and bind-mount it into the container at the identical absolute path, so the worktree's pointer still resolves. This is a no-op for a plain (non-worktree) checkout, where the common dir already lives under the mounted source tree. Also document the make docker-check/docker-indent shortcut in CONTRIBUTING.md, which previously only described installing citus_indent locally. --- CONTRIBUTING.md | 10 ++++++++++ Makefile | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bb358ab42..3ddca4a5a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,6 +24,16 @@ We format all our code using the coding conventions in the tool. This tool uses uncrustify under the hood. To format the python test files we use [black](https://github.com/psf/black). +If you have Docker available, the simplest way to check or fix formatting +locally, without installing anything, is: + +```bash +make docker-check # check only -- matches CI's citus_indent --check exactly +make docker-indent # auto-fix +``` + +Otherwise, install citus_indent locally: + ```bash # Uncrustify changes the way it formats code every release a bit. To make sure # everyone formats consistently we use version 0.68.1: diff --git a/Makefile b/Makefile index cbffa92a1..e4e00c2cc 100644 --- a/Makefile +++ b/Makefile @@ -85,8 +85,20 @@ test ci-test run-test run-test-prebuilt: # To check or auto-fix locally without installing citus_indent: # make docker-check # check only # make docker-indent # auto-fix +# +# citus_indent calls `git ls-files` to find the files it should look at, so +# the container needs a working .git. In a plain checkout that's already +# true (.git lives under $(CURDIR), which is mounted at /workdir). In a git +# worktree, $(CURDIR)/.git is only a pointer file ("gitdir: /.git/ +# worktrees/") to a path outside $(CURDIR) -- GIT_COMMON_DIR resolves +# that pointer on the host and the extra -v mounts it into the container at +# the identical absolute path, so it still resolves there too. This is a +# harmless no-op for a plain checkout (it just mounts $(CURDIR)/.git over +# itself). +GIT_COMMON_DIR := $(shell cd "$(CURDIR)" && cd "$$(git rev-parse --git-common-dir 2>/dev/null)" 2>/dev/null && pwd) CITUS_INDENT_DOCKER = docker run --rm \ -v "$(CURDIR):/workdir" \ + $(if $(GIT_COMMON_DIR),-v "$(GIT_COMMON_DIR):$(GIT_COMMON_DIR)") \ -w /workdir \ citus/stylechecker:no-py \ citus_indent