* [PATCH 0/2] git-stash last-minute fixes
@ 2007-07-28 6:59 Junio C Hamano
2007-07-28 7:02 ` [PATCH 1/2] Fix git-stash apply --index Junio C Hamano
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Junio C Hamano @ 2007-07-28 6:59 UTC (permalink / raw)
To: git
Cc: しらいしななこ,
Johannes Schindelin
Here are a small patch series to git-stash.
[1/2] Fix git-stash apply --index
This fixes two rather embarrasing bugs in "apply --index".
[2/2] git-stash apply --index: optimize postprocessing
This builds on top of the previous one to avoid unnecessary
index manipulations that is later wiped by a read-tree.
There also is a bugfix I received privately from Nana for the
breakage I introduced with 7ab3cc70. I've already queued it for
'master'.
-- >8 --
From: しらいしななこ <nanako3@bluebottle.com>
Date: Sat, 28 Jul 2007 10:44:48 +0900
Subject: [PATCH] git-stash: Make sure reflog is created for refs/stash
Earlier commit 7ab3cc70 fixed "stash clear" but broke save_stash,
because it forgot to make sure the reflog file exists before saving.
Signed-off-by: Nanako Shiraishi <nanako3@bluebottle.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff --git a/git-stash.sh b/git-stash.sh
index f90dffd..0073e9d 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -36,6 +36,9 @@ save_stash () {
test -f "$GIT_DIR/logs/$ref_stash" ||
clear_stash || die "Cannot initialize stash"
+ # Make sure the reflog for stash is kept.
+ : >>"$GIT_DIR/logs/$ref_stash"
+
# state of the base commit
if b_commit=$(git rev-parse --verify HEAD)
then
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 1/2] Fix git-stash apply --index
2007-07-28 6:59 [PATCH 0/2] git-stash last-minute fixes Junio C Hamano
@ 2007-07-28 7:02 ` Junio C Hamano
2007-07-28 7:02 ` [PATCH 2/2] git-stash apply --index: optimize postprocessing Junio C Hamano
2007-07-28 9:06 ` [PATCH 0/2] git-stash last-minute fixes しらいしななこ
2 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2007-07-28 7:02 UTC (permalink / raw)
To: git
Cc: しらいしななこ,
Johannes Schindelin
Two bugs that made the command practically unusable were fixed
with this.
- A stash created with a clean index does not have any
difference between the base tree and the index tree.
Trying to apply the diff between them to the index would
error out with "No changes". Even when the user asked to
unstash with --index, do not bother with --index action if
the base tree and the index tree match.
- After successfully performing the working tree merge, the
index was reloaded from an earlier state of unstashed index
with "read-tree"; this left all the paths cache dirty. By
moving the call to git-status after this read-tree, match the
cached stat information in the index.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
git-stash.sh | 23 +++++++++++++++++------
1 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/git-stash.sh b/git-stash.sh
index 0073e9d..873e7be 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -128,19 +128,24 @@ apply_stash () {
c_tree=$(git write-tree) ||
die 'Cannot apply a stash in the middle of a merge'
+ # stash records the work tree, and is a merge between the
+ # base commit (first parent) and the index tree (second parent).
s=$(git rev-parse --revs-only --no-flags --default $ref_stash "$@") &&
w_tree=$(git rev-parse --verify "$s:") &&
- b_tree=$(git rev-parse --verify "$s^:") ||
+ b_tree=$(git rev-parse --verify "$s^1:") &&
+ i_tree=$(git rev-parse --verify "$s^2:") ||
die "$*: no valid stashed state found"
- test -z "$unstash_index" || {
+ unstashed_index_tree=
+ if test -n "$unstash_index" && test "$b_tree" != "$i_tree"
+ then
git diff --binary $s^2^..$s^2 | git apply --cached
test $? -ne 0 &&
die 'Conflicts in index. Try without --index.'
unstashed_index_tree=$(git-write-tree) ||
die 'Could not save index tree'
git reset
- }
+ fi
eval "
GITHEAD_$w_tree='Stashed changes' &&
@@ -157,13 +162,19 @@ apply_stash () {
git read-tree --reset $c_tree &&
git update-index --add --stdin <"$a" ||
die "Cannot unstage modified files"
- git-status
rm -f "$a"
- test -z "$unstash_index" || git read-tree $unstashed_index_tree
+ if test -n "$unstashed_index_tree"
+ then
+ git read-tree "$unstashed_index_tree"
+ fi
+ git status || :
else
# Merge conflict; keep the exit status from merge-recursive
status=$?
- test -z "$unstash_index" || echo 'Index was not unstashed.' >&2
+ if test -n "$unstash_index"
+ then
+ echo >&2 'Index was not unstashed.'
+ fi
exit $status
fi
}
--
1.5.3.rc3.16.g9f04-dirty
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/2] git-stash apply --index: optimize postprocessing
2007-07-28 6:59 [PATCH 0/2] git-stash last-minute fixes Junio C Hamano
2007-07-28 7:02 ` [PATCH 1/2] Fix git-stash apply --index Junio C Hamano
@ 2007-07-28 7:02 ` Junio C Hamano
2007-07-28 9:06 ` [PATCH 0/2] git-stash last-minute fixes しらいしななこ
2 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2007-07-28 7:02 UTC (permalink / raw)
To: git
Cc: しらいしななこ,
Johannes Schindelin
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>
---
git-stash.sh | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/git-stash.sh b/git-stash.sh
index 873e7be..30425ce 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -157,15 +157,16 @@ apply_stash () {
if git-merge-recursive $b_tree -- $c_tree $w_tree
then
# No conflict
- a="$TMP-added" &&
- git diff --cached --name-only --diff-filter=A $c_tree >"$a" &&
- git read-tree --reset $c_tree &&
- git update-index --add --stdin <"$a" ||
- die "Cannot unstage modified files"
- rm -f "$a"
if test -n "$unstashed_index_tree"
then
git read-tree "$unstashed_index_tree"
+ else
+ a="$TMP-added" &&
+ git diff --cached --name-only --diff-filter=A $c_tree >"$a" &&
+ git read-tree --reset $c_tree &&
+ git update-index --add --stdin <"$a" ||
+ die "Cannot unstage modified files"
+ rm -f "$a"
fi
git status || :
else
--
1.5.3.rc3.16.g9f04-dirty
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 0/2] git-stash last-minute fixes
2007-07-28 6:59 [PATCH 0/2] git-stash last-minute fixes Junio C Hamano
2007-07-28 7:02 ` [PATCH 1/2] Fix git-stash apply --index Junio C Hamano
2007-07-28 7:02 ` [PATCH 2/2] git-stash apply --index: optimize postprocessing Junio C Hamano
@ 2007-07-28 9:06 ` しらいしななこ
2 siblings, 0 replies; 4+ messages in thread
From: しらいしななこ @ 2007-07-28 9:06 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Johannes Schindelin, git
Quoting Junio C Hamano <gitster@pobox.com> writes:
> Here are a small patch series to git-stash.
>
> [1/2] Fix git-stash apply --index
>
> This fixes two rather embarrasing bugs in "apply --index".
>
> [2/2] git-stash apply --index: optimize postprocessing
>
> This builds on top of the previous one to avoid unnecessary
> index manipulations that is later wiped by a read-tree.
Thank you for the patch. I have not used the --index things
myself and did not notice these breakages.
--
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/
----------------------------------------------------------------------
Get a free email address with REAL anti-spam protection.
http://www.bluebottle.com/tag/1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-07-28 9:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-28 6:59 [PATCH 0/2] git-stash last-minute fixes Junio C Hamano
2007-07-28 7:02 ` [PATCH 1/2] Fix git-stash apply --index Junio C Hamano
2007-07-28 7:02 ` [PATCH 2/2] git-stash apply --index: optimize postprocessing Junio C Hamano
2007-07-28 9:06 ` [PATCH 0/2] git-stash last-minute fixes しらいしななこ
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox