Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(worktree): support adding ignored files with --force#1690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
MaestroLockedIn wants to merge4 commits intogo-git:main
base:main
Choose a base branch
Loading
fromMaestroLockedIn:feat/addwithoptions-optimize

Conversation

@MaestroLockedIn
Copy link

Issue: Add() should not add ignored files by default#1679

This PR adds support for force-adding ignored files using the --force option, mirroring standard Git’s behavior (git add -f).

Changes

Updated AddWithOptions():

Supports Force: true to bypass .gitignore patterns.

Modified doAdd() and doAddDirectory() to correctly include ignored files when forced.

Added comprehensive tests:

TestAddWithForceIgnoredFile

Minor cleanup and improved .gitignore pattern handling.

johndoe12312and others added4 commitsOctober 7, 2025 22:14
This adds support for  (force add) to include ignored filesin the worktree index. Also improves AddWithOptions and related teststo cover ignored file handling and force scenarios.
Copy link
Contributor

@onee-onlyonee-only left a comment

Choose a reason for hiding this comment

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

Hello@MaestroLockedIn! I'm not the maintainer of the project, but I was also interested in the issue. I've left some suggestions. Please have a look and share your thoughts.

func (w*Worktree)Add(pathstring) (plumbing.Hash,error) {
// TODO(mcuadros): deprecate in favor of AddWithOption in v6.
returnw.doAdd(path,make([]gitignore.Pattern,0),false)
// TODO(mcuadros): deprecate in favor of AddWithOption in v7.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we don't have to delay this to v7. Currently v6 isn't released and API changes can be made. See#910.

Copy link
Member

Choose a reason for hiding this comment

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

I think we don't have to delay this to v7.

I'd concur with this, ideally we would tackle it as part of v6. I'm planning to raise an RFC on the subject of API consolidation which would affect this (and the general "WithOption" funcs), just haven't got around to it yet. In the mean time, we could leave the comment unchanged:

Suggested change
// TODO(mcuadros): deprecate in favor of AddWithOption inv7.
// TODO(mcuadros): deprecate in favor of AddWithOption inv6.

dirPatterns,_:=gitignore.ReadPatterns(w.Filesystem,nil)
patterns=append(patterns,dirPatterns...)
}else {
dirPatterns,_:=gitignore.ReadPatterns(w.Filesystem, []string{dir})
Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I know,gitignore.ReadPatterns reads the directories recursively starting from the specified directory. So I think the case below won't work as expected:

  1. root directory contains.gitignore with content:foo.
  2. user addsfoo/bar.txt

In this case, since it isn't aware of the root's.gitignore, it will addfoo/bar.txt.
Could you please test the code against this case?

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

Reviewers

@pjbgfpjbgfpjbgf left review comments

+1 more reviewer

@onee-onlyonee-onlyonee-only left review comments

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@MaestroLockedIn@pjbgf@onee-only@johndoe12312

[8]ページ先頭

©2009-2025 Movatter.jp