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 <jon.seymour@xxxxxxxxx> --- 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 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html