Skip to content

Conversation

navad
Copy link

@navad navad commented Oct 19, 2024

Current version of SourceGit contains an optimization to perform a git add <repo path> operation when the number of files being staged equals the number of changes. While this optimization makes perfect sense, it fails to accommodate for untracked files, if those are marked hidden in the UI ("Include Untracked Files" is disabled)

Before staging:
image

After staging:
image

This PR includes a fix to check and make sure there are no untracked files present in the repo before performing this operation in order to avoid adding those unwanted files.

love-linger added a commit that referenced this pull request Oct 20, 2024
@love-linger
Copy link
Collaborator

love-linger commented Oct 20, 2024

I've pushed my implementation of this feature. It just uses -u option of git add command to ignore untracked files.

@navad
Copy link
Author

navad commented Oct 21, 2024

Thanks for applying a fix!
git add -u ... will indeed filter out untracked files but might implicitly stage other files, that's why I preferred a more explicit approach in the PR when there are any filtered-out files in the UI

@love-linger
Copy link
Collaborator

Current version of SourceGit contains an optimization to perform a git add operation when the number of files being staged equals the number of changes

Why I perfer to use git add [-u] . instead of git add -- <pathspec> ...? Here is the reason:

The --pathspec-from-file=<file> parameter of git add command is added since 2.25.0, which is not the minimal version of git supported by SourceGit. So, we can only use -- <pathspec> ... format. When there are many of file to stage, the argument list can be too long, and may fail on some platform.

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