Skip to content

Git up doesn't (always) work with pretty log format #11

Closed

Description

@valentijnscholten

Hello,

I am not 100% sure this is a git up issue (I am relatively new to git and git up).

When I create a git alias to allow me to do a pretty log format:

git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

This works and gives me nice output.

When I try to set this log command as rebase log hook in git up:

git config --global git-up.rebase.log-hook "git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

This doesn't work:

c:\Data\kpn-ritesim>git up
Fetching origin
master  fast-forwarding...
Het systeem kan het opgegeven bestand niet vinden.

(This is actually a error message in Dutch, in English it's "File or command not found")

I was supecting it had someting to do with the ' character and I tried different alternatives:

git config --global git-up.rebase.log-hook "git log --color --graph --pretty=format:\'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset\' --abbrev-commit"

Same result.

git config --global git-up.rebase.log-hook "git log --color --graph --pretty=format:\"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset\" --abbrev-commit"

This command itself cannot be executed (throws the same error).

Since the git alias is working and the git up rebase hook isn't, could it be related to how git up executes the hook?

If I use a simpler git log command, it does work:

git config --global git-up.rebase.log-hook "echo \"changes on $1:\"; git log --oneline --decorate $1..$2"

I am on windows 7 x64.

Valentijn

Activity

  1. msiemens commented on Mar 18, 2014

    @msiemens
    Owner

    Hey,

    when running on Windows, PyGitUp writes the log-hook command to a temporary .bat file and then executes it via cmd.exe (see gitup.py#L301). So may it be that git.exe is not in your PATH and thus cannot be found?

    Markus

  2. valentijnscholten commented on Mar 19, 2014

    @valentijnscholten
    Author

    The simple example that works also does use git, so that's not the problem.

    It looks like something with variable expansion is going wrong. On Windows %C gets interpretated as a variable. If I play around with the format in the .gitconfig file, I am seeing some output like:

    C cd h
    

    Which looks like %C %cd %h gets expanded to C cd h.
    Maybe we need to escape these things, or disable variable expansion.

    I am trying to debug this by modifying the gitup.py on my local machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions