desktop icon indicating copy to clipboard operation
desktop copied to clipboard

Permission changes are classified as whitespace changes

Open haykam821 opened this issue 3 years ago • 3 comments

Describe the bug

Even though file permissions are unrelated to whitespace, both the staged and commit change views will incorrectly report that a change to file permissions is a change to whitespace.

Version & OS

  • GitHub Desktop: 2.6.4
  • Operating System: macOS Big Sur 11.2.2

Steps to reproduce the behavior

  1. Run chmod +x <file>
  2. Select the file in GitHub Desktop
  3. Run git diff <file>
  4. Observe that GitHub Desktop reports "Only file permission changes found"

Expected behavior

When the 'hide whitespace changes' option is enabled, the view should display "No content changes found", or if a more specific message is desired, both views should display "Only file permission changes found".

Actual behavior

If the 'hide whitespace changes' option is enabled, the view displays "Only whitespace changes found". Otherwise, it displays "No content changes found".

Screenshots

"Only whitespace changes found" after changing file permissions

haykam821 avatar Mar 03 '21 20:03 haykam821

Thanks @haykam821! @say25 Any ideas here since you did a lot of the work on the whitespace features?

billygriffin avatar Mar 03 '21 22:03 billygriffin

General Guidance

@haykam821 I believe you actually need to run a command like git update-index --chmod=+x README.md for what you need to work. I've run into it a fair amount writing and editing bash scripts on Windows :sob: I ended up writing this - https://github.com/say25/docs/blob/master/bash/git-chmod

Triage

We don't actually support Hide Whitespace Changes on the Changes tab as the screenshot above implies (yet) - Hopefully coming soon in https://github.com/desktop/desktop/pull/6818 but this PR just had its first birthday (wink wink @billygriffin 😛)

Problem Statement

GitHub Desktop doesn't really support CHMOD well for a few reasons:

  1. If you try to commit just a CHMOD change in GitHub Desktop you actually will hit this error - chmod commit failure image and after you click close on the There are no changes to commit dialog, Desktop will actually discard your changes
  2. You will actually not see what permission changes occur within Desktop (there is also no way to change permissions either, but this is probably an "advanced workflow" so maybe that is ok?)
  3. If you view a commit in the history tab with only a CHMOD change, the behavior described above where you will see Only whitespace changes found will indeed occur

Proposed Solutions

  1. Get GitHub Desktop to support these workflows from a commit prospective (assuming you have the changes on your branch and you solely want Desktop to commit them)
  2. Add Permissions Changes to the GitHub Desktop UI - Example from GitHub.com UI - permission change image - Fake PR Screenshotted as example - https://github.com/say25/docs/pull/3/files
  3. In addition, maybe we should make the Only whitespace changes found "smarter" to handle no content changes to begin with

say25 avatar Mar 04 '21 05:03 say25

Reported again in https://github.com/desktop/desktop/issues/16575.

steveward avatar May 24 '23 14:05 steveward