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

Fix string pattern for type-2 git status -z entries #1165

Merged
merged 1 commit into from
Feb 5, 2024

Conversation

rami3l
Copy link
Contributor

@rami3l rami3l commented Feb 5, 2024

Closes #1157.

Tested with the example from #1157 (comment):

-- NEW!
local match_2 = "(.)(.) (....) (%d+) (%d+) (%d+) (%w+) (%w+) (%a%d+) (.+)%z(.+)" 

local rest = "R. N... 100644 100644 100644 ac01e6941fe11104afee78fa73ad77f9707d169b ac01e6941fe11104afee78fa73ad77f9707d169b R100 lua/plugins/lsp/rust-analyzer.lua\0lua/plugins/lsp/rust_analyzer.lua"
local mode_staged, mode_unstaged, _, _, _, _, _, _, _, name, orig_name = rest:match(match_2)

print(orig_name) -- lua/plugins/lsp/rust_analyzer.lua
print(name)      -- lua/plugins/lsp/rust-analyzer.lua

@CKolkey CKolkey merged commit 463a32c into NeogitOrg:master Feb 5, 2024
3 checks passed
@CKolkey
Copy link
Member

CKolkey commented Feb 5, 2024

Great find :D

@rami3l rami3l deleted the patch-1 branch February 5, 2024 13:00
@rami3l rami3l restored the patch-1 branch February 5, 2024 13:33
@rami3l rami3l deleted the patch-1 branch February 5, 2024 13:34
@rami3l
Copy link
Contributor Author

rami3l commented Feb 5, 2024

@CKolkey Oops, the quick fix looks problematic... Sorry I'm still new to Lua and Neovim 🙇

Somehow the pattern matching fails completely now. Maybe we are not capturing '\0' in rest?

@CKolkey
Copy link
Member

CKolkey commented Feb 5, 2024

No worries, did a revert and will poke it later :)

@ofseed
Copy link
Contributor

ofseed commented Feb 5, 2024

Seems that it gets the wrong unstaged information with this commit.

This commit:
image

Reverted:
image

@CKolkey
Copy link
Member

CKolkey commented Feb 5, 2024

So, the underlying issue is that the null character is converted to a newline:

{ "# branch.oid dab4e50be18eab8f337b908cd871ab5f4dd031d3", "# branch.head master", "# branch.upstream origin/master", "# branch.ab +0 -0", "2 R. N... 100644 100644 100644 09c1b7ad1d5
0f6312afad0a03d83e912cdaabd32 09c1b7ad1d50f6312afad0a03d83e912cdaabd32 R100 LICENSE2", "LICENSE", "1 .M N... 100644 100644 100644 2b29d24f503804e2f78ebd66058c37885ac50ddc 2b29d24f503
804e2f78ebd66058c37885ac50ddc lua/neogit/lib/git/status.lua", "? lua/neogit/buffers/status/actions.lua", "? newfile", "" }

LICENSE2 \n LICENSE. If you grep for stdout_raw you'll find a few other workarounds for this newline thing. It's... slightly annoying, and possibly a self-own.

@CKolkey
Copy link
Member

CKolkey commented Feb 5, 2024

Alright, sorted it out. Thanks again for tracking down the source of the issue :)

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

Successfully merging this pull request may close these issues.

Renamed file cannot be shown properly
3 participants