1#!/bin/sh 2# Copyright (c) 2007, Nanako Shiraishi 3 4dashless=$(basename "$0" | sed -e 's/-/ /') 5USAGE="list [<options>] 6 or:$dashlessshow [<stash>] 7 or:$dashlessdrop [-q|--quiet] [<stash>] 8 or:$dashless( pop | apply ) [--index] [-q|--quiet] [<stash>] 9 or:$dashlessbranch <branchname> [<stash>] 10 or:$dashlesssave [--patch] [-k|--[no-]keep-index] [-q|--quiet] 11 [-u|--include-untracked] [-a|--all] [<message>] 12 or:$dashless[push [--patch] [-k|--[no-]keep-index] [-q|--quiet] 13 [-u|--include-untracked] [-a|--all] [-m <message>] 14 [-- <pathspec>...]] 15 or:$dashlessclear" 16 17SUBDIRECTORY_OK=Yes 18OPTIONS_SPEC= 19START_DIR=$(pwd) 20. git-sh-setup 21require_work_tree 22prefix=$(git rev-parse --show-prefix)||exit1 23cd_to_toplevel 24 25TMP="$GIT_DIR/.git-stash.$$" 26TMPindex=${GIT_INDEX_FILE-"$(git rev-parse --git-path index)"}.stash.$$ 27trap'rm -f "$TMP-"* "$TMPindex"'0 28 29ref_stash=refs/stash 30 31if git config --get-colorbool color.interactive;then 32 help_color="$(git config --get-color color.interactive.help 'red bold')" 33 reset_color="$(git config --get-color '' reset)" 34else 35 help_color= 36 reset_color= 37fi 38 39# 40# Parses the remaining options looking for flags and 41# at most one revision defaulting to ${ref_stash}@{0} 42# if none found. 43# 44# Derives related tree and commit objects from the 45# revision, if one is found. 46# 47# stash records the work tree, and is a merge between the 48# base commit (first parent) and the index tree (second parent). 49# 50# REV is set to the symbolic version of the specified stash-like commit 51# IS_STASH_LIKE is non-blank if ${REV} looks like a stash 52# IS_STASH_REF is non-blank if the ${REV} looks like a stash ref 53# s is set to the SHA1 of the stash commit 54# w_commit is set to the commit containing the working tree 55# b_commit is set to the base commit 56# i_commit is set to the commit containing the index tree 57# u_commit is set to the commit containing the untracked files tree 58# w_tree is set to the working tree 59# b_tree is set to the base tree 60# i_tree is set to the index tree 61# u_tree is set to the untracked files tree 62# 63# GIT_QUIET is set to t if -q is specified 64# INDEX_OPTION is set to --index if --index is specified. 65# FLAGS is set to the remaining flags (if allowed) 66# 67# dies if: 68# * too many revisions specified 69# * no revision is specified and there is no stash stack 70# * a revision is specified which cannot be resolve to a SHA1 71# * a non-existent stash reference is specified 72# * unknown flags were set and ALLOW_UNKNOWN_FLAGS is not "t" 73# 74 75test"$1"="-p"&&set"push""$@" 76 77PARSE_CACHE='--not-parsed' 78# The default command is "push" if nothing but options are given 79seen_non_option= 80for opt 81do 82case"$opt"in 83--)break;; 84-*) ;; 85*) seen_non_option=t;break;; 86esac 87done 88 89test -n"$seen_non_option"||set"push""$@" 90 91# Main command set 92case"$1"in 93list) 94shift 95 git stash--helper list "$@" 96;; 97show) 98shift 99 git stash--helper show "$@" 100;; 101save) 102shift 103cd"$START_DIR" 104 git stash--helper save "$@" 105;; 106push) 107shift 108cd"$START_DIR" 109 git stash--helper push "$@" 110;; 111apply) 112shift 113cd"$START_DIR" 114 git stash--helper apply "$@" 115;; 116clear) 117shift 118 git stash--helperclear"$@" 119;; 120create) 121shift 122 git stash--helper create --message"$*" 123;; 124store) 125shift 126 git stash--helper store "$@" 127;; 128drop) 129shift 130 git stash--helper drop "$@" 131;; 132pop) 133shift 134cd"$START_DIR" 135 git stash--helper pop "$@" 136;; 137branch) 138shift 139cd"$START_DIR" 140 git stash--helper branch "$@" 141;; 142*) 143case$#in 1440) 145cd"$START_DIR" 146 git stash--helper push && 147 say "$(gettext "(To restore them type \"git stash apply\")")" 148 ;; 149 *) 150 usage 151 esac 152 ;; 153esac