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

failed to decode in fish shell #78

Open
jsravn opened this issue Dec 3, 2022 · 7 comments
Open

failed to decode in fish shell #78

jsravn opened this issue Dec 3, 2022 · 7 comments

Comments

@jsravn
Copy link

jsravn commented Dec 3, 2022

Started using scmpuff in fish shell and it keeps failing to decode. Any ideas? Here is an example:

❯ gs
2022/12/03 12:42:03 
Failed to decode git status change code for chunk: [ A day2/day2.pro]
Please file a bug including this error message as well as the output of:

git status --porcelain

You can file the bug at: https://github.com/mroth/scmpuff/issues/

❯ git status --porcelain
 M aoc2022.pro
 A day2/day2.pro
 A day2/in.txt
 A day2/main.cpp

❯ scmpuff version
scmpuff 0.5.0
@mroth
Copy link
Owner

mroth commented Dec 3, 2022

Interesting. Does this only happen in fish in the same repository?

It looks like for some reason when this goes to process the change codes (https://github.com/mroth/scmpuff/blob/master/commands/status/process.go#L305), it's seeing an invalid code. Normally these change codes are two bytes. It looks like in this case you are simply adding some new files, so we would expect to see [A ] as the change code but instead we are seeing [ A] (quick conclusion from eyeballing it anyhow).

Could you run git status -z -b > output_fish.txt in an affected repository and attach the file? (The output will contain NUL bytes, so a cut and paste into the issue won't work). git status -z -b is the command run under the hood by scmpuff to get the status, which shouldn't be affected by the shell (we try to call the git binary directly), but.... (if you can run it in bash/zsh as well in the same directory and produce the file for comparison, that could help rule out any issues).

@jsravn
Copy link
Author

jsravn commented Dec 3, 2022

output_fish.txt

❯ gs
2022/12/03 15:51:55 
Failed to decode git status change code for chunk: [ A day3/test.cpp]
Please file a bug including this error message as well as the output of:

git status --porcelain

You can file the bug at: https://github.com/mroth/scmpuff/issues/

❯ hexdump -C output_fish.txt
00000000  23 23 20 6d 61 69 6e 2e  2e 2e 6f 72 69 67 69 6e  |## main...origin|
00000010  2f 6d 61 69 6e 00 20 4d  20 64 61 79 33 2f 64 61  |/main. M day3/da|
00000020  79 33 2e 70 72 6f 00 20  41 20 64 61 79 33 2f 74  |y3.pro. A day3/t|
00000030  65 73 74 2e 63 70 70 00  20 41 20 64 61 79 33 2f  |est.cpp. A day3/|
00000040  74 65 73 74 2e 68 00 3f  3f 20 64 61 79 33 2f 6f  |test.h.???? day3/o|
00000050  75 74 70 75 74 5f 66 69  73 68 2e 74 78 74 00     |utput_fish.txt.|
0000005f

@jsravn
Copy link
Author

jsravn commented Dec 3, 2022

Hmm same issue in bash, so I guess it's unrelated to the shell like you say.

@jsravn
Copy link
Author

jsravn commented Dec 3, 2022

Ah, so it's when a file is added with the -N flag in git, aka git add -N test.txt. I never use that flag normally - but apparently QtCreator (which I started playing with recently) adds files with it, which is what was triggering this.

@mroth
Copy link
Owner

mroth commented Dec 3, 2022

Fascinating! It's not documented as a possible status in the XY table for https://git-scm.com/docs/git-status (see "short format" section), but there are a few other undocumented things there too.

What does a normal git status show in this case? (We can code this case in to scmpuff, but I'm trying to understand what the UI for how that status is displayed to the user normally is).

@jsravn
Copy link
Author

jsravn commented Dec 3, 2022

When adding a file with -N:

❯ git status
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	new file:   test.txt

no changes added to commit (use "git add" and/or "git commit -a")

@howardburgess
Copy link
Contributor

Seems related to #53.

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

3 participants