Revert "git stash: avoid data loss when "git stash save" kills a directory"
This reverts commit a73653130edd6a8977106d45a8092c09040f9132, as it has been reported that "ls-files --killed" is too time-consuming in a deep directory with too many untracked crufts (e.g. $HOME/.git tracking only a few files). We'd need to revisit it later but "ls-files --killed" needs to be optimized before it happens.
Junio C Hamano committed
Aug 14, 2013 at 09:53 UTC
c1ebd90c832e28ff27654c21f9985aebe986352d
3 files changed
+2
-40
Documentation/git-stash.txt
+2
-10
@@ -14,8 +14,7 @@ SYNOPSIS
14
'git stash' ( pop | apply ) [--index] [-q|--quiet] [<stash>]
15
'git stash' branch <branchname> [<stash>]
16
'git stash' [save [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]
17
- [-u|--include-untracked] [-a|--all] [-f|--force]
18
- [<message>]]
17
+ [-u|--include-untracked] [-a|--all] [<message>]]
18
'git stash' clear
19
'git stash' create [<message>]
20
'git stash' store [-m|--message <message>] [-q|--quiet] <commit>
@@ -45,7 +44,7 @@ is also possible).
44
OPTIONS
45
-------
46
48
-save [-p|--patch] [--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [-f|--force] [<message>]::
47
+save [-p|--patch] [--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [<message>]::
48
49
Save your local modifications to a new 'stash', and run `git reset
50
--hard` to revert them. The <message> part is optional and gives
@@ -72,13 +71,6 @@ linkgit:git-add[1] to learn how to operate the `--patch` mode.
71
+
72
The `--patch` option implies `--keep-index`. You can use
73
`--no-keep-index` to override this.
75
-+
76
-In some cases, saving a stash could mean irretrievably removing some
77
-data - if a directory with untracked files replaces a tracked file of
78
-the same name, the new untracked files are not saved (except in case
79
-of `--include-untracked`) but the original tracked file shall be restored.
80
-By default, `stash save` will abort in such a case; `--force` will allow
81
-it to remove the untracked files.
74
75
list [<options>]::
76
git-stash.sh
-12
@@ -195,7 +195,6 @@ save_stash () {
195
keep_index=
196
patch_mode=
197
untracked=
198
- force=
198
while test $# != 0
199
do
200
case "$1" in
@@ -216,9 +215,6 @@ save_stash () {
215
-u|--include-untracked)
216
untracked=untracked
217
;;
219
- -f|--force)
220
- force=t
221
- ;;
218
-a|--all)
219
untracked=all
220
;;
@@ -262,14 +258,6 @@ save_stash () {
258
say "$(gettext "No local changes to save")"
259
exit 0
260
fi
265
- if test -z "$untracked$force" &&
266
- test -n "$(git ls-files --killed | head -n 1)"
267
- then
268
- say "$(gettext "The following untracked files would NOT be saved but need to be removed by stash save:")"
269
- test -n "$GIT_QUIET" || git ls-files --killed | sed 's/^/\t/'
270
- say "$(gettext "Aborting. Consider using either the --force or --include-untracked option.")" >&2
271
- exit 1
272
- fi
261
test -f "$GIT_DIR/logs/$ref_stash" ||
262
clear_stash || die "$(gettext "Cannot initialize stash")"
263
t/t3903-stash.sh
-18
@@ -673,22 +673,4 @@ test_expect_success 'store updates stash ref and reflog' '
673
grep quux bazzy
674
'
675
676
-test_expect_success 'stash a change to turn a non-directory to a directory' '
677
- git reset --hard &&
678
- >testfile &&
679
- git add testfile &&
680
- git commit -m "add testfile as a regular file" &&
681
- rm testfile &&
682
- mkdir testfile &&
683
- >testfile/file &&
684
- test_must_fail git stash save "recover regular file" &&
685
- test -f testfile/file
686
-'
687
-
688
-test_expect_success 'stash a change to turn a non-directory to a directory (forced)' '
689
- git stash save --force "recover regular file (forced)" &&
690
- ! test -f testfile/file &&
691
- test -f testfile
692
-'
693
-
676
test_done