Subject: [PATCH v5 0/2] setup.c: v5 reroll

From: Tian Yuchen <[email-masked]>
Date: Wed, 18 Feb 2026 13:18:48 +0800

Hi Karthik, Junio,

Here is the v5 patch.

Bases on the feedback, I have split the changed into two separate
patches to isolate the refactoring from the logic change.

Patch 1/2: Refactors read_gitfile_* functions to correctly distinguish
ENOENT from other stat() failures.

Patch 2/2: Switches lstat() to stat() to support symlinks, while adding
checks for benign and fatal cases. Also includes the new test script
t0009-git-dir-validation.sh (name has been changed as suggested by
Karthik).

Changes since v4:

1. Split into 2 commits.
2. read_gitfile_error_die() now handles happy/fatal cases internally.
3. Renamed the test script.
4. Updates t/meson.build.

If there are any further issues, please feel free to bring them to my
attention. Thanks for guiding me towards this cleaner structure!

Regards,

Yuchen

---

Tian Yuchen (2):
  setup: distingush ENOENT from other stat errors
  setup: allow cwd/.git to be a symlink to a directory

 setup.c                       | 35 ++++++++++-------
 setup.h                       |  2 +
 t/meson.build                 |  1 +
 t/t0009-git-dir-validation.sh | 72 +++++++++++++++++++++++++++++++++++
 4 files changed, 96 insertions(+), 14 deletions(-)
 create mode 100755 t/t0009-git-dir-validation.sh

-- 
2.43.0