Desktop does not display diff changes after renaming and staging file
See original GitHub issueDescription
I have a small source file. I renamed it, made some changes, and added all my changes to the git index.
In Desktop, I see the rename as I would expect, along with the message “The file was renamed but not changed”. This is incorrect. The file was changed. Once I commit, Desktop updates, then I go look at the commit in the history where it shows the correct thing: the rename and the change. I can do a soft reset to bring my changes back to the index, and I see the bug again. The issue persisted across a restart of the app.
Version
- GitHub Desktop: 1.3.5
- Operating system: OSX 10.13.4
Steps to Reproduce
Use the description and attached information.
Additional Information
Here is the original file:
function forEach(func, iterable) {
let c = 0;
for (const item of iterable) {
const ret = func(item, c++);
if (ret === false) {
break;
}
}
return c;
}
export default function curriedForEach(func, iterable) {
if (!iterable) {
return iterable => forEach(func, iterable);
}
return forEach(func, iterable);
}
Here is the result of git diff HEAD -M
for the relevant file:
diff --git a/src/functions/for-each.js b/src/transforms/for-each.js
similarity index 52%
rename from src/functions/for-each.js
rename to src/transforms/for-each.js
index 0bb2948..785740c 100644
--- a/src/functions/for-each.js
+++ b/src/transforms/for-each.js
@@ -10,9 +10,4 @@ function forEach(func, iterable) {
return c;
}
-export default function curriedForEach(func, iterable) {
- if (!iterable) {
- return iterable => forEach(func, iterable);
- }
- return forEach(func, iterable);
-}
+export default func => iterable => forEach(func, iterable);
Issue Analytics
- State:
- Created 5 years ago
- Reactions:9
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Git status shows files as changed even though contents are ...
Original answer below: The diff you show does not show a single different line. Can you post .git/config (or better git config -l...
Read more >Run git mv after renaming or moving a file
Yes, this bug is still there, but there is a workaround: If the files are staged before the commit, Visual Studio figures out...
Read more >Understanding renaming/moving files with git - Vjeko.com
So far, we know that git doesn't lose the history of renamed files, but by default doesn't show it. As I said, we'll...
Read more >Rename or Move files in GIT - Aram Koukia
Git keeps track of changes to files in the working directory of a repository by their name. When you move or rename a...
Read more >2.2 Git Basics - Recording Changes to the Repository
If you run this command directly after a clone, you should see something like ... to unstage) new file: README Changes not staged...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve been able to reproduce this, but the resolution for this isn’t quite clear. This is what Desktop currently runs when it diffs a file it knows has been renamed:
Most of those flags are noise so I’ll call out the differences here:
HEAD
as part of diffing renamed files, for reasons specified in the sourcehttps://github.com/desktop/desktop/blob/2d2e1455893ade496348e909ff0a7b742201c44b/app/src/lib/git/diff.ts#L166-L181
Desktop favours diffing against unstaged changes, but Git doesn’t detect renames until the content is staged, but once you stage the file to show the rename that impacts our ability to diff correctly.
I came across this today as well. IMO, GitHub Desktop does not have the correct behavior here. Compare with VS Code:
There is a diff I’m about to push up. That should be indicated in the UI. The difference is indeed that the changes are staged, e.g.
git diff
outputs nothing for that file, butgit diff --staged
does show the changes: