From: Jon Seymour Date: Tue, 10 Aug 2010 00:04:42 GMT Subject: [PATCH v4 3/9] stash: introduce is_stash_ref and assert_stash_ref functions. Message-ID: <1281398688-21008-4-git-send-email-jon.seymour@gmail.com> In-Reply-To: <1281242771-24764-1-git-send-email-jon.seymour@gmail.com> Introduce a function, is_stash_ref, which checks whether an argument is valid stash reference (e.g. is of the form ['refs/']stash['@{'something'}]) Introduce a function, assert_stash_ref, which can be used to ensure that certain commands are only called with stash references as arguments. Signed-off-by: Jon Seymour --- git-stash.sh | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/git-stash.sh b/git-stash.sh index dbb7944..41a9359 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -223,6 +223,15 @@ show_stash () { git diff $flags $b_commit $w_commit } +is_stash_ref() { + revs="$(git rev-parse --revs-only --symbolic --verify --default ${ref_stash} "$@")" && + test "$ref_stash" = "$(git rev-parse --symbolic-full-name "${revs%@*}")" +} + +assert_stash_ref() { + is_stash_ref "$@" || die "$* is not a stash reference" +} + # # if this function returns, then: # s is set to the stash commit -- 1.6.5.rc3.8.g8ba5e