mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-03-29 22:07:13 +02:00
Merge pull request #1930 from mark2185/feature/discard-staged-only
This commit is contained in:
commit
f31dcd3091
pkg
test/integration/discardStagedFiles
expected/repo
.git_keep
COMMIT_EDITMSGFETCH_HEADHEADORIG_HEADconfigdescriptionindex
file0file1file2file3info
logs
objects
02
18
1e
22
38
5c
5e
66
9d
9e
a5
c7
d0
e3
refs/heads
@ -25,6 +25,10 @@ func NewStashCommands(
|
||||
}
|
||||
}
|
||||
|
||||
func (self *StashCommands) DropNewest() error {
|
||||
return self.cmd.New("git stash drop").Run()
|
||||
}
|
||||
|
||||
func (self *StashCommands) Drop(index int) error {
|
||||
return self.cmd.New(fmt.Sprintf("git stash drop stash@{%d}", index)).Run()
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
func (self *FilesController) createResetMenu() error {
|
||||
red := style.FgRed
|
||||
|
||||
nukeStr := "reset --hard HEAD && git clean -fd"
|
||||
nukeStr := "git reset --hard HEAD && git clean -fd"
|
||||
if len(self.model.Submodules) > 0 {
|
||||
nukeStr = fmt.Sprintf("%s (%s)", nukeStr, self.c.Tr.LcAndResetSubmodules)
|
||||
}
|
||||
@ -64,6 +64,28 @@ func (self *FilesController) createResetMenu() error {
|
||||
},
|
||||
Key: 'c',
|
||||
},
|
||||
{
|
||||
LabelColumns: []string{
|
||||
self.c.Tr.LcDiscardStagedChanges,
|
||||
red.Sprint("stash staged and drop stash"),
|
||||
},
|
||||
Tooltip: self.c.Tr.DiscardStagedChangesDescription,
|
||||
OnPress: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.RemoveStagedFiles)
|
||||
if !self.helpers.WorkingTree.IsWorkingTreeDirty() {
|
||||
return self.c.ErrorMsg(self.c.Tr.NoTrackedStagedFilesStash)
|
||||
}
|
||||
if err := self.git.Stash.SaveStagedChanges("[lazygit] tmp stash"); err != nil {
|
||||
return self.c.Error(err)
|
||||
}
|
||||
if err := self.git.Stash.DropNewest(); err != nil {
|
||||
return self.c.Error(err)
|
||||
}
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}})
|
||||
},
|
||||
Key: 'S',
|
||||
},
|
||||
{
|
||||
LabelColumns: []string{
|
||||
self.c.Tr.LcSoftReset,
|
||||
|
@ -265,6 +265,7 @@ type TranslationSet struct {
|
||||
LcDiscardAllChangesToAllFiles string
|
||||
LcDiscardAnyUnstagedChanges string
|
||||
LcDiscardUntrackedFiles string
|
||||
LcDiscardStagedChanges string
|
||||
LcHardReset string
|
||||
LcViewResetOptions string
|
||||
LcCreateFixupCommit string
|
||||
@ -491,6 +492,7 @@ type TranslationSet struct {
|
||||
HardResetAutostashPrompt string
|
||||
UpstreamGone string
|
||||
NukeDescription string
|
||||
DiscardStagedChangesDescription string
|
||||
Actions Actions
|
||||
Bisect Bisect
|
||||
}
|
||||
@ -594,6 +596,7 @@ type Actions struct {
|
||||
NukeWorkingTree string
|
||||
DiscardUnstagedFileChanges string
|
||||
RemoveUntrackedFiles string
|
||||
RemoveStagedFiles string
|
||||
SoftReset string
|
||||
MixedReset string
|
||||
HardReset string
|
||||
@ -883,6 +886,7 @@ func EnglishTranslationSet() TranslationSet {
|
||||
LcDiscardAllChangesToAllFiles: "nuke working tree",
|
||||
LcDiscardAnyUnstagedChanges: "discard unstaged changes",
|
||||
LcDiscardUntrackedFiles: "discard untracked files",
|
||||
LcDiscardStagedChanges: "discard staged changes",
|
||||
LcHardReset: "hard reset",
|
||||
LcViewResetOptions: `view reset options`,
|
||||
LcCreateFixupCommit: `create fixup commit for this commit`,
|
||||
@ -1109,6 +1113,7 @@ func EnglishTranslationSet() TranslationSet {
|
||||
CheckoutPrompt: "Are you sure you want to checkout '%s'?",
|
||||
UpstreamGone: "(upstream gone)",
|
||||
NukeDescription: "If you want to make all the changes in the worktree go away, this is the way to do it. If there are dirty submodule changes this will stash those changes in the submodule(s).",
|
||||
DiscardStagedChangesDescription: "This will create a new stash entry containing only staged files and then drop it, so that the working tree is left with only unstaged changes",
|
||||
Actions: Actions{
|
||||
// TODO: combine this with the original keybinding descriptions (those are all in lowercase atm)
|
||||
CheckoutCommit: "Checkout commit",
|
||||
@ -1193,6 +1198,7 @@ func EnglishTranslationSet() TranslationSet {
|
||||
NukeWorkingTree: "Nuke working tree",
|
||||
DiscardUnstagedFileChanges: "Discard unstaged file changes",
|
||||
RemoveUntrackedFiles: "Remove untracked files",
|
||||
RemoveStagedFiles: "Remove staged files",
|
||||
SoftReset: "Soft reset",
|
||||
MixedReset: "Mixed reset",
|
||||
HardReset: "Hard reset",
|
||||
|
@ -0,0 +1 @@
|
||||
file2
|
@ -0,0 +1 @@
|
||||
ref: refs/heads/master
|
@ -0,0 +1 @@
|
||||
02f629e46dbaa03b58196cced3df07b02c0daf22
|
@ -0,0 +1,8 @@
|
||||
[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = true
|
||||
bare = false
|
||||
logallrefupdates = true
|
||||
[user]
|
||||
email = CI@example.com
|
||||
name = CI
|
@ -0,0 +1 @@
|
||||
Unnamed repository; edit this file 'description' to name the repository.
|
Binary file not shown.
@ -0,0 +1,6 @@
|
||||
# git ls-files --others --exclude-from=.git/info/exclude
|
||||
# Lines that start with '#' are comments.
|
||||
# For a project mostly in C, the following would be a good set of
|
||||
# exclude patterns (uncomment them if you want to use them):
|
||||
# *.[oa]
|
||||
# *~
|
@ -0,0 +1,5 @@
|
||||
0000000000000000000000000000000000000000 22f24c5fcc97c1ff826ecb66b60bdc01937f6052 CI <CI@example.com> 1652009263 +0200 commit (initial): file0
|
||||
22f24c5fcc97c1ff826ecb66b60bdc01937f6052 9e7ff93a5c67a0ef098e9e436961746f333edf98 CI <CI@example.com> 1652009263 +0200 commit: file1
|
||||
9e7ff93a5c67a0ef098e9e436961746f333edf98 02f629e46dbaa03b58196cced3df07b02c0daf22 CI <CI@example.com> 1652009263 +0200 commit: file2
|
||||
02f629e46dbaa03b58196cced3df07b02c0daf22 02f629e46dbaa03b58196cced3df07b02c0daf22 CI <CI@example.com> 1652009266 +0200 reset: moving to HEAD
|
||||
02f629e46dbaa03b58196cced3df07b02c0daf22 02f629e46dbaa03b58196cced3df07b02c0daf22 CI <CI@example.com> 1652009266 +0200 reset: moving to HEAD
|
@ -0,0 +1,3 @@
|
||||
0000000000000000000000000000000000000000 22f24c5fcc97c1ff826ecb66b60bdc01937f6052 CI <CI@example.com> 1652009263 +0200 commit (initial): file0
|
||||
22f24c5fcc97c1ff826ecb66b60bdc01937f6052 9e7ff93a5c67a0ef098e9e436961746f333edf98 CI <CI@example.com> 1652009263 +0200 commit: file1
|
||||
9e7ff93a5c67a0ef098e9e436961746f333edf98 02f629e46dbaa03b58196cced3df07b02c0daf22 CI <CI@example.com> 1652009263 +0200 commit: file2
|
BIN
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/02/f629e46dbaa03b58196cced3df07b02c0daf22
Normal file
BIN
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/02/f629e46dbaa03b58196cced3df07b02c0daf22
Normal file
Binary file not shown.
BIN
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/18/0cf8328022becee9aaa2577a8f84ea2b9f3827
Normal file
BIN
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/18/0cf8328022becee9aaa2577a8f84ea2b9f3827
Normal file
Binary file not shown.
BIN
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/1e/3e67b999db1576ad1ee08bf4f02bdf29e49442
Normal file
BIN
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/1e/3e67b999db1576ad1ee08bf4f02bdf29e49442
Normal file
Binary file not shown.
3
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/22/f24c5fcc97c1ff826ecb66b60bdc01937f6052
Normal file
3
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/22/f24c5fcc97c1ff826ecb66b60bdc01937f6052
Normal file
@ -0,0 +1,3 @@
|
||||
x��Á
|
||||
Â0=ç+ö.È&ݦ.ˆ=õ3’æ
)%‚Ÿo>ÁÛ0ÌZKÙY‘K;²à§¨ª)Úqò!Y€ï1KfSv
|
||||
Qg§½ëIóB�yyáʱã¶Öò$ëGǬÎtåN¦Û>iø37yÛÁæÙ2+à
|
BIN
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/38/143ad4a0fe2ab6ee53c2ef89a5d9e2bd9535da
Normal file
BIN
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/38/143ad4a0fe2ab6ee53c2ef89a5d9e2bd9535da
Normal file
Binary file not shown.
BIN
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/5c/ef9afea6a37d89f925e24ebf71adecb63d1f07
Normal file
BIN
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/5c/ef9afea6a37d89f925e24ebf71adecb63d1f07
Normal file
Binary file not shown.
BIN
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/5e/2f5743436bdc7602aa3486d5ff294940603c3d
Normal file
BIN
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/5e/2f5743436bdc7602aa3486d5ff294940603c3d
Normal file
Binary file not shown.
3
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/66/bbc809cdafd867cf9320bfb7484bb8fa898448
Normal file
3
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/66/bbc809cdafd867cf9320bfb7484bb8fa898448
Normal file
@ -0,0 +1,3 @@
|
||||
x+)JMU°΄d040031QHΛΜI5`°±Ί²ΰ�Φ¶wΑ‡ήw.½ωhοTΣ[H
|
||||
�Ώe“ς"Η¨ΰSς,αΚgu"��YH
|
||||
�$x~5(ν;χrΥΆπ�ώ–WΪσ-ΤΠ–+^
|
2
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/9d/b161bba78fbd20e7e4ae004be28e40d747726a
Normal file
2
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/9d/b161bba78fbd20e7e4ae004be28e40d747726a
Normal file
@ -0,0 +1,2 @@
|
||||
x�ŽÁ
|
||||
Â0D=ç+ö.Èv›n<õ3²É¦-5‚Ÿo.Þ½
üáŵ”¹uã¡îªÀ,ú˜BNŽÇ˜}O(YF묈ËÁyg3[Øu©€”™¼ZNö2¸ÎsŒšú”q¤ˆí‰È„w}¬;Ü'¸Ü§›~BÙžzŠk¹BÇ!zb†#¶dZÛ¤ªþ97ó’ôë%¼uþYAžŸJæ BP
|
2
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/9e/7ff93a5c67a0ef098e9e436961746f333edf98
Normal file
2
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/9e/7ff93a5c67a0ef098e9e436961746f333edf98
Normal file
@ -0,0 +1,2 @@
|
||||
x�ŽA
|
||||
Â0E]çÙ2™$"BW=F2™Á‚µ¥Dðøæî>�÷àó¶®K·.ã©"¶A"æ̹p)Ø<iåTrÔæ=PÈ�‚3{9äÝ-¢bਣIìT¯H•¨ÔÆà²OJÑ”On‡�f{›æ‡|˺¿äÂÛz·Ž"d$oÏ0–tœêò§nty‰3?ÄÇ9Ø
|
BIN
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/9e/88a70dc8d82dd2afbfd50176ef78e18823bc2c
Normal file
BIN
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/9e/88a70dc8d82dd2afbfd50176ef78e18823bc2c
Normal file
Binary file not shown.
BIN
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5
Normal file
BIN
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5
Normal file
Binary file not shown.
BIN
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/c7/c7da3c64e86c3270f2639a1379e67e14891b6a
Normal file
BIN
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/c7/c7da3c64e86c3270f2639a1379e67e14891b6a
Normal file
Binary file not shown.
2
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/d0/76cc9cc09acaa2d36fbc7a95fd3e2306494641
Normal file
2
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/d0/76cc9cc09acaa2d36fbc7a95fd3e2306494641
Normal file
@ -0,0 +1,2 @@
|
||||
x+)JMU03c040031QHヒフI5`ーアコイ燹ヨカwチ�w.ス��モ[H
|
||||
矢y�5�来ミ(桍ァ^-ンW(x9
|
BIN
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/e3/18207cf3da045ce47e2632a5326b61030a2c8e
Normal file
BIN
test/integration/discardStagedFiles/expected/repo/.git_keep/objects/e3/18207cf3da045ce47e2632a5326b61030a2c8e
Normal file
Binary file not shown.
@ -0,0 +1 @@
|
||||
02f629e46dbaa03b58196cced3df07b02c0daf22
|
1
test/integration/discardStagedFiles/expected/repo/file0
Normal file
1
test/integration/discardStagedFiles/expected/repo/file0
Normal file
@ -0,0 +1 @@
|
||||
test0
|
1
test/integration/discardStagedFiles/expected/repo/file1
Normal file
1
test/integration/discardStagedFiles/expected/repo/file1
Normal file
@ -0,0 +1 @@
|
||||
test1
|
1
test/integration/discardStagedFiles/expected/repo/file2
Normal file
1
test/integration/discardStagedFiles/expected/repo/file2
Normal file
@ -0,0 +1 @@
|
||||
hello there
|
1
test/integration/discardStagedFiles/expected/repo/file3
Normal file
1
test/integration/discardStagedFiles/expected/repo/file3
Normal file
@ -0,0 +1 @@
|
||||
hello there
|
1
test/integration/discardStagedFiles/recording.json
Normal file
1
test/integration/discardStagedFiles/recording.json
Normal file
@ -0,0 +1 @@
|
||||
{"KeyEvents":[{"Timestamp":1175,"Mod":0,"Key":256,"Ch":32},{"Timestamp":1991,"Mod":0,"Key":256,"Ch":68},{"Timestamp":2923,"Mod":0,"Key":256,"Ch":83},{"Timestamp":4453,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":213,"Height":56}]}
|
26
test/integration/discardStagedFiles/setup.sh
Normal file
26
test/integration/discardStagedFiles/setup.sh
Normal file
@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $1
|
||||
|
||||
git init
|
||||
|
||||
git config user.email "CI@example.com"
|
||||
git config user.name "CI"
|
||||
|
||||
echo test0 > file0
|
||||
git add .
|
||||
git commit -am file0
|
||||
|
||||
echo test1 > file1
|
||||
git add .
|
||||
git commit -am file1
|
||||
|
||||
echo test2 > file2
|
||||
git add .
|
||||
git commit -am file2
|
||||
|
||||
echo "hello there" > file1
|
||||
echo "hello there" > file2
|
||||
echo "hello there" > file3
|
1
test/integration/discardStagedFiles/test.json
Normal file
1
test/integration/discardStagedFiles/test.json
Normal file
@ -0,0 +1 @@
|
||||
{ "description": "Discarding staged changes", "speed": 5 }
|
Loading…
x
Reference in New Issue
Block a user