Skip to content

Commit 2ffc1b7

Browse files
committed
enhance: manually stage all changes instead of using --all parameter in git commit
1 parent 3bcea2a commit 2ffc1b7

File tree

10 files changed

+16
-21
lines changed

10 files changed

+16
-21
lines changed

src/Commands/Commit.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace SourceGit.Commands
44
{
55
public class Commit : Command
66
{
7-
public Commit(string repo, string message, bool autoStage, bool amend, bool allowEmpty = false)
7+
public Commit(string repo, string message, bool amend, bool allowEmpty = false)
88
{
99
var file = Path.GetTempFileName();
1010
File.WriteAllText(file, message);
@@ -13,8 +13,6 @@ public Commit(string repo, string message, bool autoStage, bool amend, bool allo
1313
Context = repo;
1414
TraitErrorAsOutput = true;
1515
Args = $"commit --file=\"{file}\"";
16-
if (autoStage)
17-
Args += " --all";
1816
if (amend)
1917
Args += " --amend --no-edit";
2018
if (allowEmpty)

src/Resources/Locales/de_DE.axaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,6 @@
588588
<x:String x:Key="Text.WorkingCopy.AddToGitIgnore.SingleFile" xml:space="preserve">Ignoriere nur diese Datei</x:String>
589589
<x:String x:Key="Text.WorkingCopy.Amend" xml:space="preserve">Amend</x:String>
590590
<x:String x:Key="Text.WorkingCopy.AutoStage" xml:space="preserve">Auto-Stage</x:String>
591-
<x:String x:Key="Text.WorkingCopy.AutoStage.Tip" xml:space="preserve">Weise den Befehl an automatisch Dateien zu stagen die verändert und modifiziert wurden, aber für Git unbekannte Dateien sind davon unberührt.</x:String>
592591
<x:String x:Key="Text.WorkingCopy.CanStageTip" xml:space="preserve">Du kannst diese Datei jetzt stagen.</x:String>
593592
<x:String x:Key="Text.WorkingCopy.Commit" xml:space="preserve">COMMIT</x:String>
594593
<x:String x:Key="Text.WorkingCopy.CommitAndPush" xml:space="preserve">COMMIT &amp; PUSH</x:String>

src/Resources/Locales/en_US.axaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,6 @@
588588
<x:String x:Key="Text.WorkingCopy.AddToGitIgnore.SingleFile" xml:space="preserve">Ignore this file only</x:String>
589589
<x:String x:Key="Text.WorkingCopy.Amend" xml:space="preserve">Amend</x:String>
590590
<x:String x:Key="Text.WorkingCopy.AutoStage" xml:space="preserve">Auto-Stage</x:String>
591-
<x:String x:Key="Text.WorkingCopy.AutoStage.Tip" xml:space="preserve">Tell the command to automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected.</x:String>
592591
<x:String x:Key="Text.WorkingCopy.CanStageTip" xml:space="preserve">You can stage this file now.</x:String>
593592
<x:String x:Key="Text.WorkingCopy.Commit" xml:space="preserve">COMMIT</x:String>
594593
<x:String x:Key="Text.WorkingCopy.CommitAndPush" xml:space="preserve">COMMIT &amp; PUSH</x:String>

src/Resources/Locales/pt_BR.axaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,6 @@
574574
<x:String x:Key="Text.WorkingCopy.AddToGitIgnore.SingleFile" xml:space="preserve">Ignorar apenas este arquivo</x:String>
575575
<x:String x:Key="Text.WorkingCopy.Amend" xml:space="preserve">Corrigir</x:String>
576576
<x:String x:Key="Text.WorkingCopy.AutoStage" xml:space="preserve">Auto-Stage</x:String>
577-
<x:String x:Key="Text.WorkingCopy.AutoStage.Tip" xml:space="preserve">Informe ao comando para automaticamente stagear arquivos que foram modificados e excluídos, mas novos arquivos que você não informou ao Git não serão afetados.</x:String>
578577
<x:String x:Key="Text.WorkingCopy.CanStageTip" xml:space="preserve">Você pode stagear este arquivo agora.</x:String>
579578
<x:String x:Key="Text.WorkingCopy.Commit" xml:space="preserve">COMMIT</x:String>
580579
<x:String x:Key="Text.WorkingCopy.CommitAndPush" xml:space="preserve">COMMIT &amp; PUSH</x:String>

src/Resources/Locales/zh_CN.axaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,7 @@
589589
<x:String x:Key="Text.WorkingCopy.AddToGitIgnore.InSameFolder" xml:space="preserve">忽略同目录下所有文件</x:String>
590590
<x:String x:Key="Text.WorkingCopy.AddToGitIgnore.SingleFile" xml:space="preserve">忽略本文件</x:String>
591591
<x:String x:Key="Text.WorkingCopy.Amend" xml:space="preserve">修补(--amend)</x:String>
592-
<x:String x:Key="Text.WorkingCopy.AutoStage" xml:space="preserve">自动暂存(--all)</x:String>
593-
<x:String x:Key="Text.WorkingCopy.AutoStage.Tip" xml:space="preserve">提交前自动将修改过和删除的文件加入暂存区,但新增文件需要手动添加。</x:String>
592+
<x:String x:Key="Text.WorkingCopy.AutoStage" xml:space="preserve">自动暂存</x:String>
594593
<x:String x:Key="Text.WorkingCopy.CanStageTip" xml:space="preserve">现在您已可将其加入暂存区中</x:String>
595594
<x:String x:Key="Text.WorkingCopy.Commit" xml:space="preserve">提交</x:String>
596595
<x:String x:Key="Text.WorkingCopy.CommitAndPush" xml:space="preserve">提交并推送</x:String>

src/Resources/Locales/zh_TW.axaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,7 @@
589589
<x:String x:Key="Text.WorkingCopy.AddToGitIgnore.InSameFolder" xml:space="preserve">忽略同路徑下所有檔案</x:String>
590590
<x:String x:Key="Text.WorkingCopy.AddToGitIgnore.SingleFile" xml:space="preserve">忽略本檔案</x:String>
591591
<x:String x:Key="Text.WorkingCopy.Amend" xml:space="preserve">修補(--amend)</x:String>
592-
<x:String x:Key="Text.WorkingCopy.AutoStage" xml:space="preserve">自動暫存(--all)</x:String>
593-
<x:String x:Key="Text.WorkingCopy.AutoStage.Tip" xml:space="preserve">提交前自動將修改過和刪除的檔案加入暫存區,但新增檔案需要手動添加。</x:String>
592+
<x:String x:Key="Text.WorkingCopy.AutoStage" xml:space="preserve">自動暫存</x:String>
594593
<x:String x:Key="Text.WorkingCopy.CanStageTip" xml:space="preserve">現在您已可將其加入暫存區中</x:String>
595594
<x:String x:Key="Text.WorkingCopy.Commit" xml:space="preserve">提交</x:String>
596595
<x:String x:Key="Text.WorkingCopy.CommitAndPush" xml:space="preserve">提交併推送</x:String>

src/ViewModels/Reword.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public override Task<bool> Sure()
3939

4040
return Task.Run(() =>
4141
{
42-
var succ = new Commands.Commit(_repo.FullPath, _message, false, true, true).Exec();
42+
var succ = new Commands.Commit(_repo.FullPath, _message, true, true).Exec();
4343
CallUIThread(() => _repo.SetWatcherEnabled(true));
4444
return succ;
4545
});

src/ViewModels/Squash.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public override Task<bool> Sure()
4343
{
4444
var succ = new Commands.Reset(_repo.FullPath, Parent.SHA, "--soft").Exec();
4545
if (succ)
46-
succ = new Commands.Commit(_repo.FullPath, _message, false, true).Exec();
46+
succ = new Commands.Commit(_repo.FullPath, _message, true).Exec();
4747
CallUIThread(() => _repo.SetWatcherEnabled(true));
4848
return succ;
4949
});

src/ViewModels/WorkingCopy.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,9 +1282,10 @@ private void DoCommit(bool autoPush)
12821282
return;
12831283
}
12841284

1285+
var autoStage = AutoStageBeforeCommit;
12851286
if (!_useAmend)
12861287
{
1287-
if (AutoStageBeforeCommit)
1288+
if (autoStage)
12881289
{
12891290
if (_count == 0)
12901291
{
@@ -1306,26 +1307,28 @@ private void DoCommit(bool autoPush)
13061307
_repo.Settings.PushCommitMessage(_commitMessage);
13071308
_repo.SetWatcherEnabled(false);
13081309

1309-
var autoStage = AutoStageBeforeCommit;
13101310
Task.Run(() =>
13111311
{
1312-
var succ = new Commands.Commit(_repo.FullPath, _commitMessage, autoStage, _useAmend).Exec();
1312+
var succ = true;
1313+
if (autoStage && _unstaged.Count > 0)
1314+
succ = new Commands.Add(_repo.FullPath).Exec();
1315+
1316+
if (succ)
1317+
succ = new Commands.Commit(_repo.FullPath, _commitMessage, _useAmend).Exec();
1318+
13131319
Dispatcher.UIThread.Post(() =>
13141320
{
13151321
if (succ)
13161322
{
1317-
SelectedStaged = [];
13181323
CommitMessage = string.Empty;
13191324
UseAmend = false;
13201325

13211326
if (autoPush)
1322-
{
13231327
PopupHost.ShowAndStartPopup(new Push(_repo, null));
1324-
}
13251328
}
1329+
13261330
_repo.MarkWorkingCopyDirtyManually();
13271331
_repo.SetWatcherEnabled(true);
1328-
13291332
IsCommitting = false;
13301333
});
13311334
});

src/Views/WorkingCopy.axaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@
189189
Margin="12,0,0,0"
190190
HorizontalAlignment="Left"
191191
IsChecked="{Binding AutoStageBeforeCommit, Mode=TwoWay}"
192-
Content="{DynamicResource Text.WorkingCopy.AutoStage}"
193-
ToolTip.Tip="{DynamicResource Text.WorkingCopy.AutoStage.Tip}"/>
192+
Content="{DynamicResource Text.WorkingCopy.AutoStage}"/>
194193

195194
<CheckBox Grid.Column="2"
196195
Height="24"

0 commit comments

Comments
 (0)