{"thread":{"id":"9269","subject":"[PATCH 0/2] git-stash last-minute fixes","startedAt":"2007-07-28T06:59:45Z","lastAt":"2007-07-28T09:06:49Z","messageCount":4,"participants":["Junio C Hamano","しらいしななこ"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"48868","messageId":"7vbqdxui72.fsf@assigned-by-dhcp.cox.net","threadId":"9269","inReplyTo":null,"subject":"[PATCH 0/2] git-stash last-minute fixes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-28T06:59:45Z","receivedAt":"2007-07-28T06:59:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Here are a small patch series to git-stash.\n\n [1/2] Fix git-stash apply --index\n\n This fixes two rather embarrasing bugs in \"apply --index\".\n\n [2/2] git-stash apply --index: optimize postprocessing\n\n This builds on top of the previous one to avoid unnecessary\n index manipulations that is later wiped by a read-tree.\n\nThere also is a bugfix I received privately from Nana for the\nbreakage I introduced with 7ab3cc70.  I've already queued it for\n'master'.\n\n-- >8 --\n\nFrom: しらいしななこ <nanako3@bluebottle.com>\nDate: Sat, 28 Jul 2007 10:44:48 +0900\nSubject: [PATCH] git-stash: Make sure reflog is created for refs/stash\n\nEarlier commit 7ab3cc70 fixed \"stash clear\" but broke save_stash,\nbecause it forgot to make sure the reflog file exists before saving.\n\nSigned-off-by: Nanako Shiraishi <nanako3@bluebottle.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex f90dffd..0073e9d 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -36,6 +36,9 @@ save_stash () {\n \ttest -f \"$GIT_DIR/logs/$ref_stash\" ||\n \t\tclear_stash || die \"Cannot initialize stash\"\n \n+\t# Make sure the reflog for stash is kept.\n+\t: >>\"$GIT_DIR/logs/$ref_stash\"\n+\n \t# state of the base commit\n \tif b_commit=$(git rev-parse --verify HEAD)\n \tthen\n"},{"id":"48870","messageId":"7v3az9ui35.fsf@assigned-by-dhcp.cox.net","threadId":"9269","inReplyTo":"7vbqdxui72.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH 1/2] Fix git-stash apply --index","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-28T07:02:06Z","receivedAt":"2007-07-28T07:02:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Two bugs that made the command practically unusable were fixed\nwith this.\n\n - A stash created with a clean index does not have any\n   difference between the base tree and the index tree.\n   Trying to apply the diff between them to the index would\n   error out with \"No changes\".  Even when the user asked to\n   unstash with --index, do not bother with --index action if\n   the base tree and the index tree match.\n\n - After successfully performing the working tree merge, the\n   index was reloaded from an earlier state of unstashed index\n   with \"read-tree\"; this left all the paths cache dirty.  By\n   moving the call to git-status after this read-tree, match the\n   cached stat information in the index.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n git-stash.sh |   23 +++++++++++++++++------\n 1 files changed, 17 insertions(+), 6 deletions(-)\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex 0073e9d..873e7be 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -128,19 +128,24 @@ apply_stash () {\n \tc_tree=$(git write-tree) ||\n \t\tdie 'Cannot apply a stash in the middle of a merge'\n \n+\t# stash records the work tree, and is a merge between the\n+\t# base commit (first parent) and the index tree (second parent).\n \ts=$(git rev-parse --revs-only --no-flags --default $ref_stash \"$@\") &&\n \tw_tree=$(git rev-parse --verify \"$s:\") &&\n-\tb_tree=$(git rev-parse --verify \"$s^:\") ||\n+\tb_tree=$(git rev-parse --verify \"$s^1:\") &&\n+\ti_tree=$(git rev-parse --verify \"$s^2:\") ||\n \t\tdie \"$*: no valid stashed state found\"\n \n-\ttest -z \"$unstash_index\" || {\n+\tunstashed_index_tree=\n+\tif test -n \"$unstash_index\" && test \"$b_tree\" != \"$i_tree\"\n+\tthen\n \t\tgit diff --binary $s^2^..$s^2 | git apply --cached\n \t\ttest $? -ne 0 &&\n \t\t\tdie 'Conflicts in index. Try without --index.'\n \t\tunstashed_index_tree=$(git-write-tree) ||\n \t\t\tdie 'Could not save index tree'\n \t\tgit reset\n-\t}\n+\tfi\n \n \teval \"\n \t\tGITHEAD_$w_tree='Stashed changes' &&\n@@ -157,13 +162,19 @@ apply_stash () {\n \t\tgit read-tree --reset $c_tree &&\n \t\tgit update-index --add --stdin <\"$a\" ||\n \t\t\tdie \"Cannot unstage modified files\"\n-\t\tgit-status\n \t\trm -f \"$a\"\n-\t\ttest -z \"$unstash_index\" || git read-tree $unstashed_index_tree\n+\t\tif test -n \"$unstashed_index_tree\"\n+\t\tthen\n+\t\t\tgit read-tree \"$unstashed_index_tree\"\n+\t\tfi\n+\t\tgit status || :\n \telse\n \t\t# Merge conflict; keep the exit status from merge-recursive\n \t\tstatus=$?\n-\t\ttest -z \"$unstash_index\" || echo 'Index was not unstashed.' >&2\n+\t\tif test -n \"$unstash_index\"\n+\t\tthen\n+\t\t\techo >&2 'Index was not unstashed.'\n+\t\tfi\n \t\texit $status\n \tfi\n }\n-- \n1.5.3.rc3.16.g9f04-dirty\n"},{"id":"48871","messageId":"7vy7h1t3hs.fsf@assigned-by-dhcp.cox.net","threadId":"9269","inReplyTo":"7vbqdxui72.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH 2/2] git-stash apply --index: optimize postprocessing","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-28T07:02:39Z","receivedAt":"2007-07-28T07:02:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Originally, \"apply --index\" codepath was bolted on to the\n\"update working tree files and index, but then revert the\nchanges we make to the index except for added files so that we\ndo not forget about them\" codepath, almost as an afterthought.\nBecause \"apply --index\" first prepares the final index state\nupfront, \"revert except the added paths\" postprocessing does not\nhave to be done.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n git-stash.sh |   13 +++++++------\n 1 files changed, 7 insertions(+), 6 deletions(-)\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex 873e7be..30425ce 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -157,15 +157,16 @@ apply_stash () {\n \tif git-merge-recursive $b_tree -- $c_tree $w_tree\n \tthen\n \t\t# No conflict\n-\t\ta=\"$TMP-added\" &&\n-\t\tgit diff --cached --name-only --diff-filter=A $c_tree >\"$a\" &&\n-\t\tgit read-tree --reset $c_tree &&\n-\t\tgit update-index --add --stdin <\"$a\" ||\n-\t\t\tdie \"Cannot unstage modified files\"\n-\t\trm -f \"$a\"\n \t\tif test -n \"$unstashed_index_tree\"\n \t\tthen\n \t\t\tgit read-tree \"$unstashed_index_tree\"\n+\t\telse\n+\t\t\ta=\"$TMP-added\" &&\n+\t\t\tgit diff --cached --name-only --diff-filter=A $c_tree >\"$a\" &&\n+\t\t\tgit read-tree --reset $c_tree &&\n+\t\t\tgit update-index --add --stdin <\"$a\" ||\n+\t\t\t\tdie \"Cannot unstage modified files\"\n+\t\t\trm -f \"$a\"\n \t\tfi\n \t\tgit status || :\n \telse\n-- \n1.5.3.rc3.16.g9f04-dirty\n"},{"id":"48889","messageId":"200707280907.l6S974eE015202@mi0.bluebottle.com","threadId":"9269","inReplyTo":"7vbqdxui72.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 0/2] git-stash last-minute fixes","fromName":"しらいしななこ","fromEmail":"nanako3@bluebottle.com","sentAt":"2007-07-28T09:06:49Z","receivedAt":"2007-07-28T09:06:49Z","isPatch":true,"sender":{"key":"nanako3@lavabit.com","avatar":"https://gravatar.com/avatar/3777b9e201c5883a62b1a6fdf7c53f2d712d1d80989146063ea861e33aad72a8?d=mp&s=160"},"body":"Quoting Junio C Hamano <gitster@pobox.com> writes:\n\n> Here are a small patch series to git-stash.\n>\n>  [1/2] Fix git-stash apply --index\n>\n>  This fixes two rather embarrasing bugs in \"apply --index\".\n>\n>  [2/2] git-stash apply --index: optimize postprocessing\n>\n>  This builds on top of the previous one to avoid unnecessary\n>  index manipulations that is later wiped by a read-tree.\n\nThank you for the patch.  I have not used the --index things\nmyself and did not notice these breakages.\n\n-- \nNanako Shiraishi\nhttp://ivory.ap.teacup.com/nanako3/\n\n----------------------------------------------------------------------\nGet a free email address with REAL anti-spam protection.\nhttp://www.bluebottle.com/tag/1\n"}]}