question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Desktop does not display diff changes after renaming and staging file

See original GitHub issue

Description

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:open
  • Created 5 years ago
  • Reactions:9
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
shiftkeycommented, Sep 10, 2018

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:

git diff --no-ext-diff --patch-with-raw -z --no-color -- [path]

Most of those flags are noise so I’ll call out the differences here:

  • typically we’d also add the old path here for a renamed file, like we do for getting the diff in a commit, but that’s not the full resolution
  • GitHub Desktop doesn’t pass in HEAD as part of diffing renamed files, for reasons specified in the source

https://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.

0reactions
NickCravercommented, Aug 22, 2020

I came across this today as well. IMO, GitHub Desktop does not have the correct behavior here. Compare with VS Code: Screen Shot 2020-08-22 at 9 45 11 AM Screen Shot 2020-08-22 at 9 45 26 AM

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, but git diff --staged does show the changes:

diff --git a/tests/RedisConfigs/Sentinel/sentinel-26379.conf b/tests/RedisConfigs/Sentinel/sentinel-26479.conf
similarity index 87%
rename from tests/RedisConfigs/Sentinel/sentinel-26379.conf
rename to tests/RedisConfigs/Sentinel/sentinel-26479.conf
index 6d10f60..a341912 100644
--- a/tests/RedisConfigs/Sentinel/sentinel-26379.conf
+++ b/tests/RedisConfigs/Sentinel/sentinel-26479.conf
@@ -1,4 +1,4 @@
-port 26379
+port 26479
 sentinel monitor mymaster 127.0.0.1 7010 1
 sentinel down-after-milliseconds mymaster 1000
 sentinel failover-timeout mymaster 1000
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found