Skip to content

Commit

Permalink
git-stash: use update-ref --create-reflog instead of creating files
Browse files Browse the repository at this point in the history
This is in support of alternate ref backends which don't necessarily
store reflogs as files.

Signed-off-by: David Turner <dturner@twopensource.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
David Turner authored and Junio C Hamano committed Jul 21, 2015
1 parent 144c76f commit 89dea97
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions git-stash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@ store_stash () {
stash_msg="Created via \"git stash store\"."
fi

# Make sure the reflog for stash is kept.
: >>"$(git rev-parse --git-path logs/$ref_stash)"
git update-ref -m "$stash_msg" $ref_stash $w_commit
git update-ref --create-reflog -m "$stash_msg" $ref_stash $w_commit
ret=$?
test $ret != 0 && test -z $quiet &&
die "$(eval_gettext "Cannot update \$ref_stash with \$w_commit")"
Expand Down Expand Up @@ -262,7 +260,7 @@ save_stash () {
say "$(gettext "No local changes to save")"
exit 0
fi
test -f "$(git rev-parse --git-path logs/$ref_stash)" ||
git reflog exists $ref_stash ||
clear_stash || die "$(gettext "Cannot initialize stash")"

create_stash "$stash_msg" $untracked
Expand Down

0 comments on commit 89dea97

Please sign in to comment.