Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

git checkout @... completion



Hi All,

  i've modified the git completions in _git to complete git checkout's @{-n} syntax for recent branches. I'm pretty sure the way i've done it is somewhat ugly, because my understanding of the completion system is primitive. I've attached a patch (against a local copy) - please let me know if it's better to submit changes as a PR and i'll do that.

  More importantly, any review comments before the patch is usable are most welcome. In particular, it just offers the first for each unique amongst the most recent 9 branches. This is done by parsing the output of git log --walk-reflogs using the same logic as git uses to interpret the @... syntax according to my reading of sha1_name.c in the git source using a bit of awkery. Although simplistic, i think this is useful in practice.

  In particular, it could be rewritten to loop over git check-ref-format --branch "@{-$i}" for increasing i until a given (by completion style maybe, or environment variable) number of unique previous branches was found. This felt a bit more rounadabout (and effort) than the quick version here, but if it's more likely to be acceptable that this patch please let me know and i'll rework it. Any pointers to completions with a configurable depth / length that i could use to glean the right way to do this kind of thing welcome.

  Thanks for your time,

 - Robbie

Attachment: _git.patch
Description: Binary data



Messages sorted by: Reverse Date, Date, Thread, Author