Skip to content

Conversation

gadfly3173
Copy link
Contributor

@gadfly3173 gadfly3173 commented Mar 17, 2025

run git rev-parse --git-dir --git-common-dir can get both paths, but I don't have good idea to read these

@love-linger love-linger merged commit cea8a90 into sourcegit-scm:develop Mar 17, 2025
13 checks passed
@love-linger
Copy link
Collaborator

我仔细阅读了一下您的代码。我的看法是:由于 --git-common-dir 仅用于 SourceGit.Models.Watcher(对于其他需求,我们仍然需要使用 --git-dir),那并不需要在对象存储这一属性。

我将合并该需求,并进行一些修改。

@love-linger love-linger self-assigned this Mar 17, 2025
@love-linger love-linger added the enhancement New feature or request label Mar 17, 2025
@gadfly3173 gadfly3173 deleted the fix/rev-parse branch March 17, 2025 08:12
love-linger added a commit that referenced this pull request Mar 17, 2025
Since we only use `$GIT_COMMON_DIR` in filesystem watcher, it is unnecessary to store this value in `Repository`, and we can query the `$GIT_COMMON_DIR` only when it looks like a worktree

Signed-off-by: leo <longshuang@msn.cn>
@love-linger
Copy link
Collaborator

Done.

@gadfly3173
Copy link
Contributor Author

我想去掉 .git/worktrees/ 的字符串查找的原因是我注意到 vscode 的 git 日志中是通过 git rev-parse --git-dir --git-common-dir来查找目录的,并且理论上你可以通过在仓库目录下新建一个.git文件,在其中将gitdir指定为一个不叫.git的文件夹(虽然正常情况下没有人会这么干)

@love-linger
Copy link
Collaborator

我想去掉 .git/worktrees/ 的字符串查找的原因是我注意到 vscode 的 git 日志中是通过 git rev-parse --git-dir --git-common-dir来查找目录的,并且理论上你可以通过在仓库目录下新建一个.git文件,在其中将gitdir指定为一个不叫.git的文件夹(虽然正常情况下没有人会这么干)

那可以直接检测 /worktrees/ 是否匹配到(所有的worktree必须满足这一条件)

https://github.com/git/git/blob/683c54c999c301c2cd6f715c411407c413b1d84e/worktree.c#L385-L398

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants