mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-25 12:24:59 +00:00
Fix untracked files being staged when hidden
This commit is contained in:
parent
efc14fed36
commit
dead9d2527
2 changed files with 36 additions and 1 deletions
24
src/Commands/QueryHasUntrackedFiles.cs
Normal file
24
src/Commands/QueryHasUntrackedFiles.cs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
namespace SourceGit.Commands
|
||||||
|
{
|
||||||
|
public partial class QueryHasUntrackedFiles : Command
|
||||||
|
{
|
||||||
|
private bool _hasUntracked = false;
|
||||||
|
|
||||||
|
public QueryHasUntrackedFiles(string repo) {
|
||||||
|
WorkingDirectory = repo;
|
||||||
|
Context = repo;
|
||||||
|
Args = "ls-files --others --exclude-standard";
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Result()
|
||||||
|
{
|
||||||
|
Exec();
|
||||||
|
return _hasUntracked;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnReadline(string line)
|
||||||
|
{
|
||||||
|
_hasUntracked = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -343,7 +343,18 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
IsStaging = true;
|
IsStaging = true;
|
||||||
_repo.SetWatcherEnabled(false);
|
_repo.SetWatcherEnabled(false);
|
||||||
if (changes.Count == _unstaged.Count)
|
|
||||||
|
var canAddAll = changes.Count == _unstaged.Count;
|
||||||
|
if (canAddAll && !IncludeUntracked) {
|
||||||
|
// If the user chose to hide untracked files, we have to make sure to not
|
||||||
|
// add those by mistake when performing `git add <repo path>`, otherwise those
|
||||||
|
// untracked files will be added as well
|
||||||
|
var hasUntracked = new Commands.QueryHasUntrackedFiles(_repo.FullPath).Exec();
|
||||||
|
|
||||||
|
canAddAll = !hasUntracked;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canAddAll)
|
||||||
{
|
{
|
||||||
await Task.Run(() => new Commands.Add(_repo.FullPath).Exec());
|
await Task.Run(() => new Commands.Add(_repo.FullPath).Exec());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue