Files
Brad Fitzpatrick 25877455e7 misc/git_hook/githook: don't flag large blobs already on the remote
The pre-push large-blob check diffed the pushed tree only against the
remote's old tree for the same ref. After rebasing a stale branch past
an unrelated large-file change on the default branch, that diff shows
the large file as changed even though the exact blob is already on the
remote via main, rejecting the push with a false positive.

Diff against every available base tree instead: the remote's old
commit for the ref plus the merge base with the remote's default
branch. Only flag a file that is a large addition relative to all
bases, so blobs the remote already has are not reported, while
genuinely new large files on the branch are still rejected.

Updates tailscale/corp#9863

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Change-Id: Ia0c98fc1f5ab67a2913f948aeff605c72641ada7
2026-08-10 12:00:07 +02:00
..

git_hook

Tailscale's git hooks.

The shared logic lives in the githook/ package and is also imported by tailscale/corp.

Install

From the repo root:

./tool/go run ./misc/add-git-hooks.go

The script auto-updates in the future.

Large file check

The pre-push hook rejects pushes that add or change any blob over 1.5 MB, using the same tree diff logic as the check-file-size CI workflow. To push a large file intentionally, set an environment variable:

TS_SKIP_LARGE_FILE_CHECK=1 git push ...

Adding your own hooks

Create an executable .git/hooks/<hook-name>.local to chain a custom script after a built-in hook. For example, put a custom check in .git/hooks/pre-commit.local and chmod +x it. The local hook runs only if the built-in hook succeeds; failure aborts the git operation.

Version bumps

The launcher rebuilds when the installed binary's version differs from the concatenation of two files:

  • githook/HOOK_VERSION (shared): bump when changing anything under githook/ or git-hook.go. Downstream repos pick it up after bumping their tailscale.com dependency.
  • misc/git_hook/HOOK_VERSION (repo-local, optional): bump to force a rebuild for repo-specific config changes without touching the shared version. This repo does not use one.