Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ stash.button=Create Stash
stash.error.can.not.stash.changes.now=Cannot Stash Changes Now
stash.keep.index.tooltip=If this checkbox is selected, all changes already added to the index are left intact
stash.keep.index=Keep &index
stash.include.untracked.tooltip=If this checkbox is selected, all untracked files are also stashed
stash.include.untracked=Include &untracked
stash.message.tooltip=Enter stash message here
stash.message=&Message:
stash.progress.indicator.title=Stashing changes from ''{0}''\u2026
Expand Down
9 changes: 5 additions & 4 deletions plugins/git4idea/src/git4idea/GitStashUsageCollector.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ import com.intellij.openapi.project.Project
object GitStashUsageCollector : CounterUsagesCollector() {
override fun getGroup(): EventLogGroup = GROUP

private val GROUP: EventLogGroup = EventLogGroup("stash.interactions", 4)
private val GROUP: EventLogGroup = EventLogGroup("stash.interactions", 5)

private val STASH_PUSH = GROUP.registerIdeActivity("stash.push")

private val STASH_POP = GROUP.registerIdeActivity("stash.pop")

private val STASH_PUSH_DIALOG = GROUP.registerEvent("stash.push.dialog",
EventFields.Boolean("message_entered"),
EventFields.Boolean("keep_index"))
EventFields.Boolean("keep_index"),
EventFields.Boolean("include_untracked"))
private val STASH_POP_DIALOG = GROUP.registerEvent("stash.pop.dialog",
EventFields.Boolean("create_branch"),
EventFields.Boolean("reinstate_index"),
Expand All @@ -35,8 +36,8 @@ object GitStashUsageCollector : CounterUsagesCollector() {
}

@JvmStatic
fun logStashPushDialog(messageEntered: Boolean, keepIndex: Boolean) {
STASH_PUSH_DIALOG.log(messageEntered, keepIndex)
fun logStashPushDialog(messageEntered: Boolean, keepIndex: Boolean, includeUntracked: Boolean) {
STASH_PUSH_DIALOG.log(messageEntered, keepIndex, includeUntracked)
}

@JvmStatic
Expand Down
3 changes: 2 additions & 1 deletion plugins/git4idea/src/git4idea/actions/GitStash.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ protected void perform(@NotNull Project project, @NotNull List<VirtualFile> gitR
VirtualFile selectedRoot = dialog.getSelectedRoot();
String message = dialog.getMessage();
boolean keepIndex = dialog.getKeepIndex();
boolean includeUntracked = dialog.getIncludeUntracked();

GitStashOperations.runStashInBackground(project, Collections.singleton(selectedRoot), root -> {
return GitStashUtils.createStashHandler(project, root, keepIndex, message);
return GitStashUtils.createStashHandler(project, root, keepIndex, includeUntracked, message);
});
}

Expand Down
4 changes: 3 additions & 1 deletion plugins/git4idea/src/git4idea/stash/GitStashUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,11 @@ private fun createUnstashHandler(
return h
}

fun createStashHandler(project: Project, root: VirtualFile, keepIndex: Boolean = false, message: String = ""): GitLineHandler {
fun createStashHandler(project: Project, root: VirtualFile, keepIndex: Boolean = false, includeUntracked: Boolean = false,
message: String = ""): GitLineHandler {
return createStashHandler(project, root, emptyList(), buildList {
if (keepIndex) add("--keep-index")
if (includeUntracked) add("--include-untracked")
val msg = message.trim()
if (msg.isNotEmpty()) {
add("--message")
Expand Down
9 changes: 7 additions & 2 deletions plugins/git4idea/src/git4idea/stash/ui/GitStashDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ internal class GitStashDialog(private val project: Project, roots: List<VirtualF
Disposer.register(disposable, it)
}
private val keepIndexCheckBox = JBCheckBox(GitBundle.message("stash.keep.index")).also { it.toolTipText = GitBundle.message("stash.keep.index.tooltip") }
private val includeUntrackedCheckBox = JBCheckBox(GitBundle.message("stash.include.untracked")).also { it.toolTipText = GitBundle.message("stash.include.untracked.tooltip") }

val selectedRoot: VirtualFile get() = rootComboBox.item
val message: String get() = stashMessageEditor.text
val keepIndex: Boolean get() = keepIndexCheckBox.isSelected
val includeUntracked: Boolean get() = includeUntrackedCheckBox.isSelected

init {
title = GitBundle.message("stash.title")
Expand All @@ -44,14 +46,17 @@ internal class GitStashDialog(private val project: Project, roots: List<VirtualF
row(GitBundle.message("common.git.root")) { cell(rootComboBox) }
row(GitBundle.message("common.current.branch")) { cell(currentBranchLabel) }
commitMessageWithLabelAndToolbar(stashMessageEditor, GitBundle.message("stash.message"))
row { cell(keepIndexCheckBox) }
row {
cell(keepIndexCheckBox)
cell(includeUntrackedCheckBox)
}
}
}

override fun doOKAction() {
super.doOKAction()

GitStashUsageCollector.logStashPushDialog(message.isNotEmpty(), keepIndex)
GitStashUsageCollector.logStashPushDialog(message.isNotEmpty(), keepIndex, includeUntracked)
}

override fun dispose() {
Expand Down