G-Node / gin-cli

Command line client for GIN
https://gin.g-node.org
Other
12 stars 6 forks source link

Problem with filenames beginning with - (Windows only?) #238

Open JiriVanek opened 5 years ago

JiriVanek commented 5 years ago

for file name called -.sh on windows I got this error ''' .....\repo>gin upload -- .-sh panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x10 pc=0x74f4c6]

goroutine 21 [running]: github.com/G-Node/gin-cli/git.filterpaths.func1(0x11c100e0, 0x4, 0x0, 0x0, 0x90c9a0, 0x11d20ea0, 0x20, 0x829600) /home/achilleas/code/go/src/github.com/G-Node/gin-cli/git/util.go:110 +0x56 path/filepath.Walk(0x11c100e0, 0x4, 0x11d20e80, 0x11d3a2f4, 0x11d37270) /usr/lib/go/src/path/filepath/path.go:402 +0x60 github.com/G-Node/gin-cli/git.filterpaths(0x11db4018, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0) /home/achilleas/code/go/src/github.com/G-Node/gin-cli/git/util.go:120 +0xb6 github.com/G-Node/gin-cli/git.gitAddDirect(0x11db4018, 0x1, 0x1, 0x0, 0x0, 0x0) /home/achilleas/code/go/src/github.com/G-Node/gin-cli/git/git.go:996 +0x1d6 github.com/G-Node/gin-cli/git.Add(0x11db4018, 0x1, 0x1, 0x11d368c0) /home/achilleas/code/go/src/github.com/G-Node/gin-cli/git/git.go:261 +0x6d5 created by github.com/G-Node/gin-cli/ginclient.Add /home/achilleas/code/go/src/github.com/G-Node/gin-cli/ginclient/repos.go:248 +0x1ea '''

the same result was with command gin upload "-.sh" upload with "gin upload ." work even with this file

VERSION: GIN command line client 1.5 Build 001238 (08c5a3d03a2111ac3b1fa99432bcf46143b7f6e3) git: 2.20.1.windows.1 git-annex: 6.20180927-gc5b6c55af

achilleas-k commented 5 years ago

Was this fixed? We've made a bunch of changes to the client since then and it seems to work okay on Linux, but I haven't tested on Windows.

JiriVanek commented 5 years ago

no, the file still cannot use "-" as name or as a first sign in name. D:\gin\repo>gin upload "-name.txt" Error: unknown shorthand flag: 'n' in -name.txt

achilleas-k commented 5 years ago

Does it break like before or does it print the help?

Did you try like before with the gin upload -- -.sh?

achilleas-k commented 5 years ago

If the nil pointer dereference issue is fixed, I'm inclined to close this since the issue with having files prefixed by - is a bit more general and is probably best solved through documenting that flags and file names can be separated by --.

JiriVanek commented 5 years ago

if I try it with upload -- "-name", but that stucks on ::adding file changes

2019/05/07 13:18:34 VERSION: GIN command line client 1.7 Build 001383 (4d5a7b35bd37d29d0c0ca32a9c675684914b9801) git: 2.21.0.windows.1 git-annex: 7.20190323-g437fa438e 2019/05/07 13:18:34 COMMAND: gin upload -- -name.txt 2019/05/07 13:18:34 CWD: D:\gin\repo 2019/05/07 13:18:34 IsRepo 'D:\gin\repo'? 2019/05/07 13:18:34 true 2019/05/07 13:18:34 env GIT_SSH_COMMAND=ssh -i C:/Users/vanek2/AppData/Roaming/g-node/gin/gin.key -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes -o 'UserKnownHostsFile="C:\Users\vanek2\AppData\Roaming\g-node\gin\known_hosts"' 2019/05/07 13:18:34 Running shell command (Dir: D:\gin\repo): git config --get gin.remote 2019/05/07 13:18:34 IsRepo 'D:\gin\repo'? 2019/05/07 13:18:34 true 2019/05/07 13:18:34 ExpandGlobs: Checking for glob expansion for -name.txt 2019/05/07 13:18:34 env GIT_SSH_COMMAND=ssh -i C:/Users/vanek2/AppData/Roaming/g-node/gin/gin.key -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes -o 'UserKnownHostsFile="C:\Users\vanek2\AppData\Roaming\g-node\gin\known_hosts"' 2019/05/07 13:18:34 Running shell command (Dir: D:\gin\repo): git annex add --json -c annex.largefiles=((largerthan=10M) and (exclude=config.yml)) -name.txt

achilleas-k commented 5 years ago

Ok, that's interesting. Thanks. I'll have to test myself and see what's going on. Keeping this open.