mroth / scmpuff

:1234: Numeric file shortcuts for common git commands
https://mroth.github.io/scmpuff/
MIT License
384 stars 22 forks source link

Cannot use # in commit message with zsh+prezto #17

Closed VoidAndAny closed 2 years ago

VoidAndAny commented 8 years ago

Same error than in scm breeze (unresolved):https://github.com/ndbroadbent/scm_breeze/issues/129 If there is a # in the commit message, the following error is raised :

(eval):1: no matches found: REF #111 test

It is particularly annoying because I must use # to reference ticket (Redmine) Thanks a lot.

mroth commented 8 years ago

@VoidAndAny can you provide the exact command that is producing this error? I cannot reproduce.

$ which git
git () {
    case $1 in
        (commit | blame | log | rebase | merge) eval "$(scmpuff expand -- "$SCMPUFF_GIT_CMD" "$@")" ;;
        (checkout | diff | rm | reset) eval "$(scmpuff expand --relative -- "$SCMPUFF_GIT_CMD" "$@")" ;;
        (add) eval "$(scmpuff expand -- "$SCMPUFF_GIT_CMD" "$@")"
            scmpuff_status ;;
        (*) "$SCMPUFF_GIT_CMD" "$@" ;;
    esac
}
$ git commit -m "REF #111 test"
[master 44d2f6e] REF #111 test
 1 file changed, 1 insertion(+), 1 deletion(-)

P.s. just checking, but perhaps you might still have scm_breeze still installed?

VoidAndAny commented 8 years ago

First, thanks for your answer and for scmpuff.

which git
git () {
    case $1 in
        (commit | blame | log | rebase | merge) eval "$(scmpuff expand -- "$SCMPUFF_GIT_CMD" "$@")" ;;
        (checkout | diff | rm | reset) eval "$(scmpuff expand --relative -- "$SCMPUFF_GIT_CMD" "$@")" ;;
        (add) eval "$(scmpuff expand -- "$SCMPUFF_GIT_CMD" "$@")"
            scmpuff_status ;;
        (*) "$SCMPUFF_GIT_CMD" "$@" ;;
    esac
}
~/Sites/oo-wp git:master ❯❯❯ touch test

~/Sites/oo-wp git:master ❯❯❯ gs 
# On branch: master  |  [*] => $e*
#
➤ Untracked files
#
#      untracked:  [1] test
#

~/Sites/oo-wp git:master ❯❯❯ ga 1
# On branch: master  |  [*] => $e*
#
➤ Changes to be committed
#
#       new file:  [1] test
#

~/Sites/oo-wp git:master ❯❯❯ gc -m "REF #15344 attempt to commit with hashtag in commit message"
(eval):1: no matches found: REF #15344 attempt to commit with hashtag in commit message

If it can help, I use ZSH with Prezto, Sorin theme and this module enabled :

zstyle ':prezto:load' pmodule \
  'environment' \
  'terminal' \
  'editor' \
  'git' \
  'history' \
  'history-substring-search' \
  'directory' \
  'spectrum' \
  'utility' \
  'completion' \
  'prompt'

And no SCM Breeze isn't installed, it's a fresh install on a new Mac.

Thanks.

mroth commented 8 years ago

Interesting.. some things to try, let's see if the gc shortcut somehow has something to do with this:

That will at least potentially rule out one category before we dig into whether Prezto is causing some conflict. Thanks for your help!

VoidAndAny commented 8 years ago

Here is:

❯❯❯ which gc
gc: aliased to git commit --verbose

Argghhh, I think you hit, the problem doesn't seems to be with scmpuff...

❯❯❯ git commit -m "REF #15344 attempt to commit with hashtag"
(eval):1: no matches found: REF #15344 attempt to commit with hashtag
VoidAndAny commented 8 years ago

It is confirmed, I disabled prezto and no more error.... Sorry, I will open an issue in prezto repo.

VoidAndAny commented 8 years ago

Finally maybe not....

❯❯❯ echo "REF #15344 attempt to commit with hashtag" 
REF #15344 attempt to commit with hashtag

Works fine with prezto.

mroth commented 8 years ago

Strange, I just tried aliasing gc to be identical to yours, still working fine here. It may be Prezto, but I want to figure out how/why and work around it. Since you get the error when not using the gc alias then it seems like it's definitely something with the interaction of scmpuff's git wrapper and what prezto does to the environment, but not sure what.

Since it's failing with the eval line, I think it's something that is happening in that git wrapper function itself (the one you see in which git), rather than scmpuff's internals.

Thinking out loud...

So on that function, it should be proceeding down the case $1 in (commit | blame | log | rebase | merge) path, and then it appears to be failing on the line:

eval "$(scmpuff expand -- "$SCMPUFF_GIT_CMD" "$@")"

Where it's getting a "No matches found" error.

Curious, if you type that exact full eval command in your shell (including the eval), do you still get the "no matches" error? (in a normal context typing it in, the non-failure case should just the equivalent of git without any arguments).

While we're at it, can you document your exact versions of zsh, prezto, and scmpuff?

(Thanks so much for your patience in helping locate the edge case here!)

VoidAndAny commented 8 years ago

Thanks to you to look at this specific case...

~ ❯❯❯ eval "$(scmpuff expand -- "$SCMPUFF_GIT_CMD" "$@")"
usage: git [--version] [--help] [-C <path>] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
   clone      Clone a repository into a new directory
   init       Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
   add        Add file contents to the index
   mv         Move or rename a file, a directory, or a symlink
   reset      Reset current HEAD to the specified state
   rm         Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
   bisect     Use binary search to find the commit that introduced a bug
   grep       Print lines matching a pattern
   log        Show commit logs
   show       Show various types of objects
   status     Show the working tree status

grow, mark and tweak your common history
   branch     List, create, or delete branches
   checkout   Switch branches or restore working tree files
   commit     Record changes to the repository
   diff       Show changes between commits, commit and working tree, etc
   merge      Join two or more development histories together
   rebase     Forward-port local commits to the updated upstream head
   tag        Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
   fetch      Download objects and refs from another repository
   pull       Fetch from and integrate with another repository or a local branch
   push       Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.

And the versions:

~ ❯❯❯ git  --version
git version 2.6.4 (Apple Git-63)
~ ❯❯❯ zsh --version
zsh 5.2 (x86_64-apple-darwin15.0.0)

Prezto I'me on master branch, 4f19700919c8ebbaf75755fc0d03716d13183f49 commit

k1sul1 commented 7 years ago

Same thing here, also running zsh with Presto. Having a # in git commit -m fails with the same error message. I've a bit different versions:

which git
git () {
    for arg
    do
        if [[ ( $arg == commit* && $arg == -a* ) || $arg == -[^-]*a* ]]
        then
            stop_using_that_flag # prevents doing stupid stuff such as git commit -am ""
            return 1
        fi
    done
    case $1 in
        (commit|blame|log|rebase|merge) eval "$(scmpuff expand -- "$SCMPUFF_GIT_CMD" "$@")" ;;
        (checkout|diff|rm|reset) eval "$(scmpuff expand --relative -- "$SCMPUFF_GIT_CMD" "$@")" ;;
        (add) eval "$(scmpuff expand -- "$SCMPUFF_GIT_CMD" "$@")"
            scmpuff_status ;;
        (*) "$SCMPUFF_GIT_CMD" "$@" ;;
    esac
}
scmpuff version                      
scmpuff 0.2.1
git --version        
git version 2.12.0
hub version 2.2.9
zsh --version
zsh 5.3.1 (x86_64-apple-darwin16.3.0)
mroth commented 7 years ago

@k1sul1 interesting, looking at your which git output, this entire part:

        for arg
    do
        if [[ ( $arg == commit* && $arg == -a* ) || $arg == -[^-]*a* ]]
        then
            stop_using_that_flag # prevents doing stupid stuff such as git commit -am ""
            return 1
        fi
    done

is definitely not part of scmpuff's git wrapper. do you know how it is getting there? I don't see a stop_using_that_flag anywhere when searching prezto's repository, and in fact its not coming up with anything relevant even with a search across all of github...

k1sul1 commented 7 years ago

Yeah, that's the "bit different" part, and it's there to prevent me from doing stupid stuff. That should't conflict with scmpuff :)

mroth commented 7 years ago

Gotcha. I'm still trying to figure out what prezto does to zsh that might interfere with this. Since the error is happening in the zsh function rather than scmpuff itself, it's literally something affecting just those 5 lines of script.

k1sul1 commented 7 years ago

Something bad I guess.

I'm just using good old gc (alias gc='git commit') without the -m flag to work around it.

mroth commented 2 years ago

This appears to have been resolved upstream (see above linked issue from prezto)

k1sul1 commented 2 years ago

Cool. Thanks for letting us now, and sorry for bothering you about this when it wasn't even your fault 😹