git-stash apply --index: optimize postprocessing
Originally, "apply --index" codepath was bolted on to the "update working tree files and index, but then revert the changes we make to the index except for added files so that we do not forget about them" codepath, almost as an afterthought. Because "apply --index" first prepares the final index state upfront, "revert except the added paths" postprocessing does not have to be done. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Jul 27, 2007 at 23:51 UTC
83b3df7d582429d9036f34d2c95abfff7bf0ab24
1 file changed
+7
-6
git-stash.sh
+7
-6
@@ -157,15 +157,16 @@ apply_stash () {
157
if git-merge-recursive $b_tree -- $c_tree $w_tree
158
then
159
# No conflict
160
- a="$TMP-added" &&
161
- git diff --cached --name-only --diff-filter=A $c_tree >"$a" &&
162
- git read-tree --reset $c_tree &&
163
- git update-index --add --stdin <"$a" ||
164
- die "Cannot unstage modified files"
165
- rm -f "$a"
160
if test -n "$unstashed_index_tree"
161
then
162
git read-tree "$unstashed_index_tree"
163
+ else
164
+ a="$TMP-added" &&
165
+ git diff --cached --name-only --diff-filter=A $c_tree >"$a" &&
166
+ git read-tree --reset $c_tree &&
167
+ git update-index --add --stdin <"$a" ||
168
+ die "Cannot unstage modified files"
169
+ rm -f "$a"
170
fi
171
git status || :
172
else