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

Shows changed file as new in diff after permissions update #20

Open
Piturnah opened this issue Jan 15, 2023 · 2 comments
Open

Shows changed file as new in diff after permissions update #20

Piturnah opened this issue Jan 15, 2023 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@Piturnah
Copy link
Owner

Describe the bug

I checked out DCoxshall/dylstatus@b317670 and made a change resulting in the following diff to main.py:

diff --git a/main.py b/main.py
old mode 100644
new mode 100755
index b597543..ed2fbc3
--- a/main.py
+++ b/main.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
 import time
 from io import StringIO
 import sys

$ gex correctly lists the file under "Unstaged changes":

image

However, instead of listing the correct diff, when expanded it treats the file as though it was a new file. This is almost certainly a bug in src/parse.rs.

let diff: IResult<&str, &str> = tag("+++ b/")(diff.get(2).unwrap_or(&""));

Additional context

$ gex --version
gex 0.3.7-dev (fcd6818e126b3c76df319cff8e6f05aa833a159f)
@Piturnah Piturnah added the bug Something isn't working label Jan 15, 2023
@Piturnah Piturnah changed the title Shows changed file as new in diff Shows changed file as new in diff after permissions update Jan 15, 2023
@Piturnah
Copy link
Owner Author

After further investigation I have realised this was caused by using $ chmod +x main.py to add executable permissions. Without running this command, the diff produced by git looks like:

diff --git a/main.py b/main.py
index b597543..ed2fbc3 100644
--- a/main.py
+++ b/main.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
 import time
 from io import StringIO
 import sys

This should be easy to fix by ignoring the following lines in parsing:

old mode 100644
new mode 100755

But ideally they should be displayed somehow in the diff.

Current gex output:
image

@Piturnah
Copy link
Owner Author

Piturnah commented Jul 7, 2023

We could try treating the mode change as similarly to a "hunk", as its own optional field in the file diff. I will look at how Magit displays it.

@Piturnah Piturnah added this to the 1.0 milestone Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant