Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RevisionDiff: Stage/Unstage selected lines #7825

Merged
1 commit merged into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion GitCommands/Git/GitModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2449,7 +2449,7 @@ public IReadOnlyList<GitItemStatus> GetDiffFilesWithSubmodulesStatus(ObjectId fi
/// <param name="secondId">to revision</param>
/// <param name="parentToSecond">The parent for the second revision</param>
/// <remarks>Git revisions are required to determine if <see cref="StagedStatus"/> allows stage/unstage.</remarks>
private static StagedStatus GetStagedStatus([CanBeNull] ObjectId firstId, [CanBeNull] ObjectId secondId, [CanBeNull] ObjectId parentToSecond)
public static StagedStatus GetStagedStatus([CanBeNull] ObjectId firstId, [CanBeNull] ObjectId secondId, [CanBeNull] ObjectId parentToSecond)
{
StagedStatus staged;
if (firstId == ObjectId.IndexId && secondId == ObjectId.WorkTreeId)
Expand Down
4 changes: 2 additions & 2 deletions GitUI/CommandsDialogs/FormCommit.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

306 changes: 72 additions & 234 deletions GitUI/CommandsDialogs/FormCommit.cs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions GitUI/CommandsDialogs/RevisionDiffControl.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion GitUI/CommandsDialogs/RevisionDiffControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public RevisionDiffControl()
_revisionDiffContextMenuController = new FileStatusListContextMenuController();
DiffText.TopScrollReached += FileViewer_TopScrollReached;
DiffText.BottomScrollReached += FileViewer_BottomScrollReached;
DiffText.LinePatchingBlocksUntilReload = true;
}

private void FileViewer_TopScrollReached(object sender, EventArgs e)
Expand Down Expand Up @@ -335,7 +336,7 @@ private ContextMenuSelectionInfo GetSelectionInfo()
bool isAnyTracked = selectedItems.Any(item => item.Item.IsTracked);
bool isAnyIndex = selectedItems.Any(item => item.Item.Staged == StagedStatus.Index);
bool isAnyWorkTree = selectedItems.Any(item => item.Item.Staged == StagedStatus.WorkTree);
bool supportPatches = selectedGitItemCount == 1 && DiffText.HasAnyPatches();
bool supportPatches = selectedGitItemCount == 1 && DiffText.SupportLinePatching;
bool isDeleted = selectedItems.Any(item => item.Item.IsDeleted);
bool isAnySubmodule = selectedItems.Any(item => item.Item.IsSubmodule);
(bool allFilesExist, bool allDirectoriesExist, bool allFilesOrUntrackedDirectoriesExist) = FileOrUntrackedDirExists(selectedItems, _fullPathResolver);
Expand Down Expand Up @@ -479,6 +480,11 @@ private void DiffText_ExtraDiffArgumentsChanged(object sender, EventArgs e)
}).FileAndForget();
}

private void DiffText_PatchApplied(object sender, EventArgs e)
{
RefreshArtificial();
}

private void diffShowInFileTreeToolStripMenuItem_Click(object sender, EventArgs e)
{
// switch to view (and fills the first level of file tree data model if not already done)
Expand Down
1 change: 1 addition & 0 deletions GitUI/CommandsDialogs/RevisionDiffController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public bool ShouldShowMenuCherryPick(ContextMenuSelectionInfo selectionInfo)
&& !selectionInfo.IsBareRepository
&& selectionInfo.AllFilesExist
&& selectionInfo.SupportPatches
&& !(selectionInfo.IsAnyItemWorkTree || selectionInfo.IsAnyItemIndex)
&& !(selectionInfo.SelectedRevision?.IsArtificial ?? false);
}

Expand Down
58 changes: 35 additions & 23 deletions GitUI/Editor/FileViewer.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.