Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Fix __git_is_treeish and add __git_is_committish
- X-seq: zsh-workers 28018
- From: Holger Weiss <holger@xxxxxxxxxxxxxxxx>
- To: Zsh Workers <zsh-workers@xxxxxxx>
- Subject: [PATCH] Fix __git_is_treeish and add __git_is_committish
- Date: Wed, 9 Jun 2010 18:29:13 +0200
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mail-followup-to: Zsh Workers <zsh-workers@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
The __git_is_treeish function is meant to check whether the provided
argument specifies a "tree-ish" Git object. The function runs
git rev-parse $1 --
and passes the result on to "git cat-file". However, due to the
trailing "--", "git rev-parse" spits out two lines, such as:
2719f952d367293602d481dddec8827771e12197
--
Therefore, the "git cat-file" call always fails and __git_is_treeish
always returns false.
This patch simply removes the "--" argument from the "git rev-parse"
call. While at it, it also adds a __git_is_committish function (which
I'll use in my next patch) and lets both functions call the generic
__git_is_type function.
---
Completion/Unix/Command/_git | 24 +++++++++++++++++-------
1 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 9c2d486..e53018f 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -1597,13 +1597,6 @@ _git-branch () {
}
__git_zstyle_default ':completion::complete:git-branch:delete-argument-rest:*' ignore-line yes
-(( $+functions[__git_is_treeish] )) ||
-__git_is_treeish () {
- local sha1
- sha1="$(git rev-parse $1 -- 2> /dev/null)" &&
- [[ "$(git cat-file -t "${sha1}^{tree}" 2> /dev/null)" == tree ]]
-}
-
# TODO: __git_tree_ishs is just stupid. It should be giving us a list of tags
# and perhaps also allow all that just with ^{tree} and so on. Not quite sure
# how to do that, though.
@@ -4423,6 +4416,23 @@ __git_setup_revision_arguments () {
# ---
+(( $+functions[__git_is_type] )) ||
+__git_is_type () {
+ local sha1
+ sha1="$(git rev-parse $2 2> /dev/null)" &&
+ [[ "$(git cat-file -t "${sha1}^{$1}" 2> /dev/null)" == $1 ]]
+}
+
+(( $+functions[__git_is_committish] )) ||
+__git_is_committish () {
+ __git_is_type commit $1
+}
+
+(( $+functions[__git_is_treeish] )) ||
+__git_is_treeish () {
+ __git_is_type tree $1
+}
+
(( $+functions[__git_is_indexed] )) ||
__git_is_indexed () {
[[ -n $(git ls-files $REPLY) ]]
--
Holger
Messages sorted by:
Reverse Date,
Date,
Thread,
Author