Skip to content

Commit e82f6da

Browse files
committed
fix(discover): use cbm_fopen for worktree gitlink + commondir reads
Follow-up to DeusData#683 (@Naam). The worktree info/exclude fix read the `.git` gitlink file and its `commondir` with raw fopen(); on Windows raw fopen uses the ANSI code page and fails to open non-ASCII (e.g. CJK) repo paths, so a worktree indexed under such a path would silently not honor info/exclude / core.excludesFile. Switch both reads to cbm_fopen() (the UTF-8 -> _wfopen wrapper), matching the rest of discover.c (e.g. read_core_excludes_file at 248). No behavior change on POSIX (raw fopen already opens UTF-8 byte paths there); this is a Windows-only correctness/consistency fix, verified by the full test suite staying green and cross-platform CI. discover.c now has no raw fopen. Refs DeusData#682, DeusData#683 Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 46c11ff commit e82f6da

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎src/discover/discover.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -778,8 +778,9 @@ static bool resolve_git_common_dir(const char *repo_path, char *common_dir, size
778778
return false;
779779
}
780780

781-
/* Linked worktree: parse "gitdir: <path>" from the gitlink file. */
782-
FILE *f = fopen(dot_git, "r");
781+
/* Linked worktree: parse "gitdir: <path>" from the gitlink file.
782+
* cbm_fopen (not raw fopen) so non-ASCII repo paths open on Windows. */
783+
FILE *f = cbm_fopen(dot_git, "r");
783784
if (!f) {
784785
return false;
785786
}
@@ -811,7 +812,7 @@ static bool resolve_git_common_dir(const char *repo_path, char *common_dir, size
811812
* (typically a relative path like "../.."). Absent in single-worktree gitdirs. */
812813
char commondir_path[CBM_SZ_4K];
813814
path_join(commondir_path, sizeof(commondir_path), git_dir, "commondir");
814-
FILE *cf = fopen(commondir_path, "r");
815+
FILE *cf = cbm_fopen(commondir_path, "r");
815816
if (cf) {
816817
char cbuf[CBM_SZ_4K];
817818
bool resolved = false;

0 commit comments

Comments
 (0)