Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Feature] Show Diff of LFS content #1386

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

Closed

Conversation

Copy link
Contributor

@henrik-andersson-sus henrik-andersson-sus commented Jun 4, 2025

We have a lot of files in lfs storage, and it would be a nice to be able to see the content of the diff. I've added a preference toggle to the diff view to de-reference the lfs pointers and use the already existing diff views for images and textures.

goran-w reacted with thumbs up emoji
Copy link
Collaborator

I do not like this implementation. I've pushed a new commit ed496a4.

Copy link
Collaborator

The reasons:

  • Since SourceGit only shows the file size change for ordinary binary files, and this information is also displayed in the LFS diff view, we only need to handle the case when the LFS object points to an image file.
  • Reading LFS file content directly from .git/lfs/objects is unsafe because after the user executes git lfs prune, this directory does not contain all the LFS objects.
  • Switching the display mode in Preferences is also not a good idea in my opinion.

Copy link
Collaborator

In my implementation, if the LFS points to an image, there're two tabs: LFS and IMAGE.

image

Copy link
Contributor Author

henrik-andersson-sus commented Jun 4, 2025
edited
Loading

Fair enough 👍

Copy link
Contributor Author

henrik-andersson-sus commented Jun 4, 2025
edited
Loading

The new implementation does not seem to support diff views of text files stored in LFS. Should it be implemented as a separate LFSTextDiff class as well then?

Copy link
Collaborator

I don't understand why the LFS is used to manage plain text files.

Copy link
Contributor

goran-w commented Jun 4, 2025

I don't understand why the LFS is used to manage plain text files.

@love-linger This is sometimes done with (large) text files, for example large .csv text files or large Unity .asset (YAML) text files...

Copy link
Contributor

goran-w commented Jun 4, 2025

@love-linger The main feature missing from your implementation of LFS image diff (compared to the one by @henrik-andersson-sus) is the Preference toggle of preferred view, LFS (Pointer) vs IMAGE (Content) - so we don't have to manually switch that EVERY time for EVERY image file! Could you please add that?

Copy link
Collaborator

love-linger commented Jun 4, 2025 via email

How to quickly determine whether an lfs object points to a plain text file? For image files, this is very easy, because AvaloniaUI supports limited image file types, and we can judge according to the file extension. It is not advisable to read the whole file to do that job when selecting lfs changes. Whether in terms of operating efficiency or memory usage. For example, for large model files, lighting baking data in the game, navigation mesh of large scale game world, etc. At present, there has been an obvious delay in loading image changes pointed to by lfs.

Copy link
Contributor

goran-w commented Jun 4, 2025
edited
Loading

How to quickly determine whether an lfs object points to a plain text file? For image files, this is very easy, because AvaloniaUI supports limited image file types, and we can judge according to the file extension. It is not advisable to read the whole file to do that job when selecting lfs changes. Whether in terms of operating efficiency or memory usage.

What was used in this PR was to let git diff determine (just as for non-LFS files) whether the content is Binary or can produce a text-diff. However, for LFS content the --no-index flag had to be used, in order to diff file-content that Git has cached to disk from LFS, but as you pointed out we should first make sure the data is actually cached...

Anyway, at the moment we can live without LFS text-diff, and the LFS image-diff is already a great improvement.

However, we definitely need the option persisted! (As a Preference variable - but by that I don't mean that it should be controlled via the Preferences UI, only that our preferred LFS / IMAGE option should be remembered - just like the Ignore All Whitespaces toggle and several others.)

If (for example) it takes too long to load image-diffs, we'll simply switch back to LFS-view, but the most likely case is that we want to view the next LFS image-file using the same view as the previous one (having to switch views EVERY time will quickly become frustrating). Besides, looking at LFS pointer SHAs is not the most fun you can have in a work-day, anyway... 😂

Copy link
Contributor

goran-w commented Jun 5, 2025

Related commit eebadd6 adds persisting the LFS / IMAGE option choice. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /