karan / joe

:running: A .gitignore magician in your command line

Home Page:http://karan.github.io/joe/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Output piped via PowerShell on Windows into .gitignore not recognized by git

paulirwin opened this issue · comments

Steps to reproduce:

  1. Open PowerShell to a new empty git repo
  2. Create a file or folder (with a file in the folder) that should be ignored, such as a "bin" folder for the "visualstudio" template
  3. Run joe visualstudio > .gitignore per the documentation in README
  4. Run git add .
  5. Run git status. Note that the "bin" folder has been added as a staged change, despite being ignored.

This is due to PowerShell using some UTF-8 marks that git doesn't like but for some reason git doesn't warn you. You can see this output in Atom, with some line ending issues as well (note the presumably Unicode-related marks at the beginning of the file):

image

Note that if you run echo "bin/" > .gitignore it also doesn't work - so this is definitely a problem with either PowerShell or git, and not a problem with Joe. Also of note is that the piping works if this is run from Git Bash which is installed with Git for Windows. However, this means that either Joe should have functionality to create the .gitignore without redirecting standard output (such as a --create flag), and the documentation should at least be updated to note that redirecting output with > in PowerShell results in a file that is not usable by git. Unless there's some other way to work around this limitation in PowerShell.

You probably want to look into https://technet.microsoft.com/en-us/library/hh849882.aspx. PowerShell defaults to Unicode output if you use '>', so you must instead pipe to out-file and set the encoding there.

@awarrenlove Workarounds like that are acceptable, but updating the docs/readme to reflect that would be in order (if that's the only option) since the readme as-is doesn't work in PowerShell.