git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v8 7/7] git-stash: use update-ref --create-reflog instead of creating files

From
David Turner <dturner@twopensource.com>
Date
Jul 9, 2015, 22:51 UTC
Message-ID
<1436482260-28088-8-git-send-email-dturner@twopensource.com>
In-Reply-To
<1436482260-28088-1-git-send-email-dturner@twopensource.com>

This is in support of alternate ref backends which don't necessarily store reflogs as files.

Signed-off-by: David Turner <dturner@twopensource.com>
---
 git-stash.sh | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/git-stash.sh b/git-stash.sh
index 8e9e2cd..1d5ba7a 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -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")"
@@ -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
-- 
2.0.5.499.g01f6352.dirty-twtrsrc
Previous: Michael HaggertyNext: Philip Oakley
Message 11 of 14 in “ref backend preamble”
  1. 0/7 ref backend preambleDavid Turner, Jul 9, 2015
  2. 1/7 refs.c: add err arguments to reflog functionsDavid Turner, Jul 9, 2015
  3. Michael HaggertyJul 21, 2015
  4. 2/7 refs: Break out check for reflog autocreationDavid Turner, Jul 9, 2015
  5. 3/7 refs: new public ref function: safe_create_reflogDavid Turner, Jul 9, 2015
  6. 4/7 git-reflog: add exists commandDavid Turner, Jul 9, 2015
  7. Michael HaggertyJul 21, 2015
  8. 5/7 refs: add REF_FORCE_CREATE_REFLOG flagDavid Turner, Jul 9, 2015
  9. 6/7 update-ref and tag: add --create-reflog argDavid Turner, Jul 9, 2015
  10. Michael HaggertyJul 21, 2015
  11. 7/7 git-stash: use update-ref --create-reflog instead of creating filesDavid Turner, Jul 9, 2015
  12. Philip OakleyJul 10, 2015
  13. David TurnerJul 10, 2015
  14. Michael HaggertyJul 21, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.