diff --git a/plugins/git4idea/shared/resources/messages/GitBundle.properties b/plugins/git4idea/shared/resources/messages/GitBundle.properties index 014c62ecf5b43..feee9509ef4c0 100644 --- a/plugins/git4idea/shared/resources/messages/GitBundle.properties +++ b/plugins/git4idea/shared/resources/messages/GitBundle.properties @@ -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 diff --git a/plugins/git4idea/src/git4idea/GitStashUsageCollector.kt b/plugins/git4idea/src/git4idea/GitStashUsageCollector.kt index e261b5ec71bec..0cecf4af429bd 100644 --- a/plugins/git4idea/src/git4idea/GitStashUsageCollector.kt +++ b/plugins/git4idea/src/git4idea/GitStashUsageCollector.kt @@ -10,7 +10,7 @@ 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") @@ -18,7 +18,8 @@ object GitStashUsageCollector : CounterUsagesCollector() { 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"), @@ -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 diff --git a/plugins/git4idea/src/git4idea/actions/GitStash.java b/plugins/git4idea/src/git4idea/actions/GitStash.java index 01f57027c48b0..c49305ef8d189 100644 --- a/plugins/git4idea/src/git4idea/actions/GitStash.java +++ b/plugins/git4idea/src/git4idea/actions/GitStash.java @@ -26,9 +26,10 @@ protected void perform(@NotNull Project project, @NotNull List 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); }); } diff --git a/plugins/git4idea/src/git4idea/stash/GitStashUtils.kt b/plugins/git4idea/src/git4idea/stash/GitStashUtils.kt index 94a2b570a95df..3d5cbe4607f1c 100644 --- a/plugins/git4idea/src/git4idea/stash/GitStashUtils.kt +++ b/plugins/git4idea/src/git4idea/stash/GitStashUtils.kt @@ -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") diff --git a/plugins/git4idea/src/git4idea/stash/ui/GitStashDialog.kt b/plugins/git4idea/src/git4idea/stash/ui/GitStashDialog.kt index 02f9b35de20c5..11686b28df362 100644 --- a/plugins/git4idea/src/git4idea/stash/ui/GitStashDialog.kt +++ b/plugins/git4idea/src/git4idea/stash/ui/GitStashDialog.kt @@ -27,10 +27,12 @@ internal class GitStashDialog(private val project: Project, roots: List