littlebee / git-time-machine

Atom package that allows you to travel back in commit history
MIT License
1.12k stars 37 forks source link

Doesn’t work for names containing $ #115

Open BuonOmo opened 7 years ago

BuonOmo commented 7 years ago

I can’t get the full stacktrace but here’s my issue. I've got a file named $call.js, when I click on this file with time machine toggled I have both the git log --pretty[...] and selet a file in the git repo to see the timeline error.

My guess is that the string containing filename is not escaped before opened with git, which creates interpolation error...

cb-radio commented 7 years ago

I have renamed one of my files to contain a $ instead of space and include a leading $ in the file name and git-time-machine works on the names without spaces. I think your problem is actually the same as #117 in that you have a directory or subdirectory that has a space in the name.

BuonOmo commented 7 years ago

There is no space in my path.

Full path: /home/ubuonomo/dev/dashboard/app/js/assets/$asset.js Project path: app/js/assets/$asset.js

I could get the stacktrace:

Error: Command failed: git log --pretty="format:{#/dquotes/id#/dquotes/: #/dquotes/%H#/dquotes/, #/dquotes/authorName#/dquotes/: #/dquotes/%an#/dquotes/, #/dquotes/relativeDate#/dquotes/: #/dquotes/%cr#/dquotes/, #/dquotes/authorDate#/dquotes/: %at, #/dquotes/message#/dquotes/: #/dquotes/%s#/dquotes/, #/dquotes/body#/dquotes/: #/dquotes/%b#/dquotes/, #/dquotes/hash#/dquotes/: #/dquotes/%h#/dquotes/}" --topo-order --date=local --numstat /home/ubuonomo/dev/dashboard/app/js/assets/$asset.js fatal: ambiguous argument '/home/ubuonomo/dev/dashboard/app/js/assets/.js': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git [...] -- [...]'

You can see the last path is missing $asset. Tell me where to look and maybe I'll be able to make a PR :slightly_smiling_face:

EDIT:

after looking at the code I got that the error came from GitLog.getCommitHistory. But if we try to shell-escape our file path (file = file.replace(/(["\s'$`\\])/g, '\\$1')), then we get an ENOENT error. So maybe the error come from git-log-utils package.

cb-radio commented 7 years ago

perhaps if you single quote around the file path that could allow it to recognize that $ as a part of the file name instead of whatever your operating system (looks like Linux) does with $'s

in windows, if you want to specify a path that has a space in the name, the whole path is surrounded with ' like this: cd '.!Files\Accelerator Project\NC Files'

but $ doesn't seem to do anything to powershell so I can't be sure about the ' ' working for you.