Skip to content

Conversation

@kayoch1n
Copy link

@kayoch1n kayoch1n commented Nov 1, 2025

On Windows, if the core.autocrlf was not set, Worktree.Status will display unchanged files as modified. The Worktree.Status function currently takes config from local file only, and even if core.autocrlf is set globally, the core.autocrlf won't take effect.

package main

import "github.com/go-git/go-git/v6"

func main() {
	repo, err := git.PlainOpen(".")
	if err != nil {
		panic(err)
	}
	wt, err := repo.Worktree()
	if err != nil {
		panic(err)
	}
	status, err := wt.Status()
	if err != nil {
		panic(err)
	}
	println(status.String())
}
屏幕截图 2025-11-01 094916

In order to make Worktree.Status take global config and work like git status, we should use ConfigScoped(config.SystemScope)

屏幕截图 2025-11-01 094812

@kayoch1n kayoch1n changed the title worktree.status takes config from local, global and system git: worktree, Status() takes config from local, global and system Nov 3, 2025
}

cfg, err := w.r.Config()
cfg, err := w.r.ConfigScoped(config.SystemScope)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kayoch1n similar to the other PR, this could cause regression - if this PR is rebased the tests for wasip1 are likely to fail for example.

What are your thoughts on leaning on changing StatusWithOptions instead, potentially adding a new option to StatusOptions?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants