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

Re: completion: git: --fixup: problem with _describe -2V and duplicate commit subjects

Hash: SHA1

On 23.03.2015 23:05, I wrote:

> I've noticed that with duplicate descriptions for different commits,
> the new completion for --fixup (__git_recent_commits) does not behave
> properly, triggered by the "-2V" used with _describe.
> When completing "git commit --fixup=" in a repo with two commits having
> "init" as its subject:
> Without "-2V":
>  -- commit object name --
> b1fc0ca  05a98c0  -- init
> With "-2V":
>  -- commit object name --
> -- init
>  -- commit object name --
> b1fc0ca                          05a98c0
> This does not only affect the duplicate commits, but will move all
> hashes to a separate "commit object name" section, leaving the
> descriptions without them.
> This was added in 236da69, where the options are passed on to next_label.

As a workaround I could imagine also adding the date, which is useful
by itself:

diff --git i/Completion/Unix/Command/_git w/Completion/Unix/Command/_git
index 5524cb0..d1b3617 100644
- --- i/Completion/Unix/Command/_git
+++ w/Completion/Unix/Command/_git
@@ -5644,14 +5644,14 @@ __git_commit_objects () {
 __git_recent_commits () {
   local gitdir expl start
   declare -a descr tags heads commits
- -  local i j k
+  local i j k l
   # Careful: most %d will expand to the empty string.  Quote properly!
- -  : "${(A)commits::=${(@f)"$(_call_program commits git --no-pager log -20 --format='%h%n%d%n%s')"}}"
+  : "${(A)commits::=${(@f)"$(_call_program commits git --no-pager log -20 --format='%h%n%d%n%s%n%cd')"}}"
   __git_command_successful $pipestatus || return 1
- -  for i j k in "$commits[@]" ; do
- -    descr+=($i:$k)
+  for i j k l in "$commits[@]" ; do
+    descr+=($i:"$k ($l)")
     j=${${j# \(}%\)} # strip leading ' (' and trailing ')'
     for j in ${(s:, :)j}; do
       if [[ $j == 'tag: '* ]] ; then

It would be nice if this could be shortened, e.g. by removing the timezone offset and
removing the current year, month etc.

There's a "relative date" option ("%cr"), but that might produce duplicates again.
If this can be fixed, it might be a good alternative to "%cd".

I've noticed btw that with `zsh -f` this is not the same, but commits are not grouped
together and appear to get sorted.  Therefore some zstyle might be involved here.

Version: GnuPG v2.0.22 (GNU/Linux)


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