]> git.ipfire.org Git - thirdparty/git.git/commit - git-stash.sh
detached-stash: introduce parse_flags_and_revs function
authorJon Seymour <jon.seymour@gmail.com>
Sat, 21 Aug 2010 04:46:22 +0000 (14:46 +1000)
committerJunio C Hamano <gitster@pobox.com>
Sun, 22 Aug 2010 06:51:21 +0000 (23:51 -0700)
commitef763129d105ff2b0501da7cd2ff71e99c89b477
tree33eb3daa1cebb0d44fb467702ef853e044598ab8
parent64fdc08dac6694d1e754580e7acb82dfa4988bb9
detached-stash: introduce parse_flags_and_revs function

Introduce parse_flags_and_revs. This function requires that
there is at most one stash-like revision parameter and
zero or more flags.

It knows how to parse -q,--quiet and --index flags, but leaves
other flags parsed.

Specified revisions are checked to see that they are at
least stash-like (meaning: they look like something created
by git stash save or git stash create).

If this is so, then IS_STASH_LIKE is initialized to a non-empty value.

If the specified revision also looks like a stash log entry reference,
then IS_STASH_REF is initialized to a non-empty value.

References of the form ref@{spec} are required to precisely identify
an individual commit.

If no reference is specified, stash@{0} is assumed.

Once the specified reference is validated to be at least stash_like
an ensemble of derived variables, (w_commit, w_tree, b_commit, etc)
is initialized with a single call to git rev-parse.

Repeated calls to parse_flags_and_rev() avoid repeated calls
to git rev-parse if the specified arguments have already been
parsed.

Subsequent patches in the series modify the existing
git stash subcommands to make use of these functions
as appropriate.

An ensemble of supporting functions that make use of the state
established by parse_flags_and_rev(). These are described below:

The ancillary functions are:

is_stash_like(): which can be used to test
whether a specified commit looks like a commit created with
git stash save or git stash create.

assert_stash_like(): which can be used by
commands that misbehave unless their arguments stash-like.

is_stash_ref(): which checks whether an argument
is valid stash reference(e.g. is of the form
['refs/']stash['@{'something'}])

assert_stash_ref(): which can be used by commands
that misbehave unless their arguments are both stash-like and
refer to valid stash entries.

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-stash.sh