From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25522 invoked by alias); 17 Jun 2015 12:56:54 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 35504 Received: (qmail 25934 invoked from network); 17 Jun 2015 12:56:49 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1434545413; bh=8AIEuzRZgBpCo7IC/yMYg+v/P651QDNNYg+P7m51WRk=; h=From:To:Subject:Date:From:Subject; b=EUfpTnuTG942553oHLTaALByxf5gdmJ+I3d+WA7rnkJClNGtKJg6WV7Y5kPqI155FIQsdXN3aWJEmIs6UFij0zHLe8amgcFSceanqfAhxZ/m6MJtVJMHFoRY4nOsn4YGnOURu60GuebmwYXyCrgdY5u3XdB1cHx0qvsh7YMRa0G9GrF1wsVU+iJ+qs0N85CAXKtxhPbupSIhvPw778kjwc6Dt8jw+rhT2QCR6WYmqNMy0sD721lQy1UJJYgA2j4ptwMqWRT60dTKqgh9/cggmhT9uKzpvyjGAGpi6Ta9bD0KcwU8u7TVz2cSkpFdLklqXDXO7vyS5RiHO2ppuWq7gw== X-Yahoo-Newman-Id: 572020.11237.bm@smtp133.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: svNZ2AMVM1l.pPJ7nTokOxVWxGYxismFh7pABk8euLWKSSI EqnI97kY.lcYIMYlPbU_ucxRoSERxzFvFgTwbTabiOfxyqMyu_7Hrpt2MGir 1lqHuUnv9vXQK1s1FfngQKj3T8pzXdMJss_K1w_fbGmoORUYp6CQ.3pVq6Ik hNNebPp9RdzDfNYtjFpAjGO_Gt3vl.d15hTyX_7yIZH100UnvS8CVnap31iE 00CvC_ecSu6ZRorcUIugf7xS5smPz.MrRNXeZYJd3RrSRsINAKQuIs8DO8Qh 6yXGviIi42W9dCbbbekxxwiRli2ukJgl.b6yF9FxeQL7BJLsH4ci7sTeMDP8 S1337fyeQ5Pa3xss3CZj9OaPJCJa99OHSAX7I9XR3btH477B6r9JZzhz5DDk _ci3z6JCrH015Aj8KD9BP0bx.GVmo.9PC_FxDH4dPYRvbLoHn9D8U1m.9MKT _ryBAqeWL_8CwLBNAztaEznwk_dTL7gIvYfPqeRNQJRuWRpxIfqNly80juL6 hwrbmRhoSGvPhez9VD_OMay28HXH5M2UL X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- From: Oliver Kiddle To: Zsh workers Subject: PATCH: complete % placeholders for git log --format MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <28722.1434545412.1@thecus.kiddle.eu> Date: Wed, 17 Jun 2015 14:50:12 +0200 Message-ID: <28723.1434545412@thecus.kiddle.eu> After git log --format=format: you can specify custom formats. With newer versions of git there's some things this doesn't handle like padding fields and complex colour specifications but it handles anything I'd likely do in a one-off command. Main reason this doesn't use _describe is that it forces the -l compadd option. Oliver diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 088a7db..3e72886 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -6269,6 +6269,95 @@ __git_setup_diff_stage_options () { ) } +(( $+functions[__git_format_placeholders] )) || +__git_format_placeholders() { + local sep + local -a disp names placeholders expl + if compset -P 'format:'; then + compset -P '(%[^acgCG]|%?[^%]|[^%])#' + if compset -P '%C'; then + _wanted colors expl color compadd reset red green blue + return + fi + if [[ -prefix %G ]]; then + placeholders=( + 'GG:raw verification message' + 'G?:indicate [G]ood, [B]ad, [U]ntrusted or [N]o signature' + 'GS:name of signer' + 'GK:signing key' + ) + disp=( -l ) + elif [[ -prefix %g ]]; then + placeholders=( + gD:'reflog selector' + gd:'short reflog selector' + gn:'reflog identity' + gs:'reflog subject' + ) + disp=( -l ) + elif [[ $PREFIX = (#b)%([ac]) ]]; then + placeholders=( + n:'name' + N:'name (use .mailmap)' + e:'email' + E:'email (use .mailmap)' + d:'date' + D:'date, RFC2822 style' + r:'date, relative' + t:'date, UNIX timestamp' + i:'date, like ISO 8601' + I:'date, strict ISO 8601' + ) + placeholders=( $match[1]$^placeholders ) + else + placeholders=( + H:commit\ hash + h:'abbreviated commit hash' + T:'tree hash' + t:'abbreviated tree hash' + P:'parent hash' + p:'abbreviated parent hash' + a:'author details' + c:'committer details' + d:'ref name in brackets' + D:'ref name' + e:encoding + s:subject + f:'sanitized subject' + g:reflog + b:body + B:'raw body' + N:notes + G:GPG\ details + C:color + m:mark + n:newline + %:raw\ % + x:'hex code' + w:'switch line wrapping' + ) + fi + names=( ${placeholders%%:*} ) + if zstyle -T ":completion:${curcontext}:" verbose; then + zstyle -s ":completion:${curcontext}:" list-separator sep || sep=-- + zformat -a placeholders " $sep " $placeholders + disp+=(-d placeholders) + else + disp=() + fi + _wanted placeholders expl placeholder \ + compadd -p % -S '' "$disp[@]" "$@" - "$names[@]" + else + _describe -t formats format '( oneline:"commit-ids and subject of messages" + short:"few headers and only subject of messages" + medium:"most parts of messages" + full:"all parts of commit messages" + fuller:"like full and includes dates" + email:"use email headers like From and Subject" + raw:"the raw commits" )' -- '( format:"specify own format" )' -S ':' + fi +} + (( $+functions[__git_setup_revision_options] )) || __git_setup_revision_options () { local -a diff_options @@ -6276,16 +6365,7 @@ __git_setup_revision_options () { revision_options=( $diff_options - # TODO: format pretty print format is a lot more advanced than this. - # TODO: You can't actually specify --format without a format. - '(-v --header)'{--pretty=-,--format=-}'[pretty print commit messages]::format:((oneline\:"commit-ids and subject of messages" - short\:"few headers and only subject of messages" - medium\:"most parts of messages" - full\:"all parts of commit messages" - fuller\:"like full and includes dates" - email\:"use email headers like From and Subject" - raw\:"the raw commits" - format\:"specify own format"))' + '(-v --header)'{--pretty=-,--format=-}'[pretty print commit messages]::format:__git_format_placeholders' '(--abbrev-commit --no-abbrev-commit)--abbrev-commit[show only partial prefixes of commit object names]' '(--abbrev-commit --no-abbrev-commit)--no-abbrev-commit[show the full 40-byte hexadecimal commit object name]' '(--abbrev --no-abbrev)--abbrev=[set minimum SHA1 display-length (for use with --abbrev-commit)]: :__git_guard_number length'