Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
valentijnscholten opened this issue Mar 18, 2014 · 2 comments
Closed

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

valentijnscholten opened this issue Mar 18, 2014 · 2 comments

Comments

@valentijnscholten
Copy link

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

@msiemens
Copy link
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

@valentijnscholten
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants