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

[PATCH v2 6/6] git-stash: use git-reflog instead of creating files

From
David Turner <dturner@twopensource.com>
Date
Jun 25, 2015, 20:45 UTC
Message-ID
<1435265110-6414-6-git-send-email-dturner@twopensource.com>
In-Reply-To
<1435265110-6414-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 | 4 ++--
 refs.c       | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/git-stash.sh b/git-stash.sh
index 8e9e2cd..27155bc 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -184,7 +184,7 @@ store_stash () {
 	fi
 
 	# Make sure the reflog for stash is kept.
-	: >>"$(git rev-parse --git-path logs/$ref_stash)"
+	git reflog create "$ref_stash"
 	git update-ref -m "$stash_msg" $ref_stash $w_commit
 	ret=$?
 	test $ret != 0 && test -z $quiet &&
@@ -262,7 +262,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
diff --git a/refs.c b/refs.c
index 7b02c45..e11a32b 100644
--- a/refs.c
+++ b/refs.c
@@ -3123,6 +3123,7 @@ static int should_autocreate_reflog(const char *refname)
 	return starts_with(refname, "refs/heads/") ||
 		starts_with(refname, "refs/remotes/") ||
 		starts_with(refname, "refs/notes/") ||
+		!strcmp(refname, "refs/stash") ||
 		!strcmp(refname, "HEAD");
 }
 
-- 
2.0.4.314.gdbf7a51-twtrsrc
Previous: David Turner
Message 14 of 14 in “refs.c: add err arguments to reflog functions”
  1. 1/6 refs.c: add err arguments to reflog functionsDavid Turner, Jun 25, 2015
  2. 2/6 cherry-pick: treat CHERRY_PICK_HEAD and REVERT_HEAD as refsDavid Turner, Jun 25, 2015
  3. Junio C HamanoJun 25, 2015
  4. David TurnerJun 25, 2015
  5. 3/6 bisect: use refs infrastructure for BISECT_STARTDavid Turner, Jun 25, 2015
  6. Junio C HamanoJun 25, 2015
  7. David TurnerJun 25, 2015
  8. David TurnerJun 26, 2015
  9. 4/6 refs: add safe_create_reflog functionDavid Turner, Jun 25, 2015
  10. Junio C HamanoJun 25, 2015
  11. 5/6 git-reflog: add create and exists functionsDavid Turner, Jun 25, 2015
  12. Junio C HamanoJun 25, 2015
  13. David TurnerJun 25, 2015
  14. 6/6 git-stash: use git-reflog instead of creating filesDavid Turner, Jun 25, 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.