jabref icon indicating copy to clipboard operation
jabref copied to clipboard

Add Diff View Before Comitting

Open DominikVoigt opened this issue 4 months ago • 41 comments

Is your suggestion for improvement related to a problem? Please describe. I would like to have the option to see the diffs before committing.

Describe the solution you'd like Using this type of display in addition to the commit message in the commmit dialog: Image

Additional context Add any other context or screenshots about the feature request here.

DominikVoigt avatar Jul 24 '26 10:07 DominikVoigt

/assign-me

thesauravpoddar avatar Jul 24 '26 14:07 thesauravpoddar

Thank you for your continued work in JabRef. At this point, you probably already know the basics and the important links. If not, our contributing guidelines is the place you should go to.

At this point in time, you raised 2 pull request(s) of which 50% (1/2) have been merged.

jabref-machine avatar Jul 24 '26 14:07 jabref-machine

@DominikVoigt @subhramit I have few questions Should the diff be shown directly inside the existing commit dialog, or should it open in a separate window? Is there already a anything similar to this like diff viewer component used elsewherecodebase that i can take as a reference for this feature?

thesauravpoddar avatar Jul 29 '26 17:07 thesauravpoddar

@koppor i am just getting confused which approach is better and consistent as per JabRef style for showing diff opening a new dialog or showing it in the same dialog of commit message. Rather then guessing and doing i think it's better to ask you. If you get time, please do reply to this

thesauravpoddar avatar Jul 31 '26 05:07 thesauravpoddar

From the picture in the description, I think a unified interface makes sense

subhramit avatar Jul 31 '26 05:07 subhramit

Meaning - show it in the same window

subhramit avatar Jul 31 '26 05:07 subhramit

Meaning - show it in the same window

Okay understood thanks

thesauravpoddar avatar Jul 31 '26 05:07 thesauravpoddar

@subhramit during implementation i felt a caveat that when some files chnages and we go to commit it does not show the files that are changed is it a design choice? or i am missing something? I feel Diff view in some sense will allow this but isn't it good if in commit dialog user can see the changed files

thesauravpoddar avatar Aug 01 '26 11:08 thesauravpoddar

@subhramit during implementation i felt a caveat that when some files chnages and we go to commit it does not show the files that are changed is it a design choice? or i am missing something? I feel Diff view in some sense will allow this but isn't it good if in commit dialog user can see the changed files

Perhaps @wanling0000 would be able to guide better here. Also, please provide a set of minimal, exact steps/screenshots with your question so that others who don't have context of this area can participate easily.

subhramit avatar Aug 01 '26 12:08 subhramit

@subhramit during implementation i felt a caveat that when some files chnages and we go to commit it does not show the files that are changed is it a design choice? or i am missing something? I feel Diff view in some sense will allow this but isn't it good if in commit dialog user can see the changed files

Perhaps @wanling0000 would be able to guide better here. Also, please provide a set of minimal, exact steps/screenshots with your question so that others who don't have context of this area can participate easily.

Okay

thesauravpoddar avatar Aug 01 '26 12:08 thesauravpoddar

@subhramit @wanling0000 So at this point everything is clean there is nothing to commit Image

But now I chnaged the Journal name now when i go to commit it does not show which files have chnaged it may very well happen accidently user change some file and some other files on purposely but when user will commit he commited accidently changed file too so I think commit dialog should show which files are changed though Diff view in some sense do that but i think it will be proper to show all those files

Image

thesauravpoddar avatar Aug 01 '26 13:08 thesauravpoddar

Are you sure you saved the file? (file ->save or ctrl S)

subhramit avatar Aug 01 '26 13:08 subhramit

Are you sure you saved the file? (file ->save or ctrl S)

yes after changing the journal name i did re save the file

thesauravpoddar avatar Aug 01 '26 13:08 thesauravpoddar

Are you sure you saved the file? (file ->save or ctrl S)

And as I saw in the codebase when we first upload all the files to github repo, initial commit is autometically done with a predefined commit message. So only whenever new files are chnaged we get the commit option

Image

thesauravpoddar avatar Aug 01 '26 13:08 thesauravpoddar

@subhramit during implementation i felt a caveat that when some files chnages and we go to commit it does not show the files that are changed is it a design choice? or i am missing something? I feel Diff view in some sense will allow this but isn't it good if in the commit dialog user can see the changed files

Since JabRef's Git features were focused on semantic merge at the time, the current UI is like a MVP ^^ Showing what you're about to commit is a natural next step, so your instinct is right.

A rough idea of how it could be wired up (just thinking out loud):

  1. Diff the working tree (current .bib) against the last commit (HEAD). GitFileReader.readFileFromCommitcan get the HEAD version.
  2. Parse that string into a BibDatabaseContext.
  3. Use BibDatabaseDiff.compare to get the two-way semantic diff. Or DatabaseChangeList.compareAndGetChanges.
  4. For the UI, DatabaseChangesResolverDialog is a good reference. But that one is accept/deny and writes changes back, so we'd probably want a preview-only version of it embedded in the commit dialog?

This is just what I've got so far, you might have a better approach

wanling0000 avatar Aug 01 '26 13:08 wanling0000

@subhramit during implementation i felt a caveat that when some files chnages and we go to commit it does not show the files that are changed is it a design choice? or i am missing something? I feel Diff view in some sense will allow this but isn't it good if in the commit dialog user can see the changed files

Since JabRef's Git features were focused on semantic merge at the time, the current UI is like a MVP ^^ Showing what you're about to commit is a natural next step, so your instinct is right.

A rough idea of how it could be wired up (just thinking out loud):

  1. Diff the working tree (current .bib) against the last commit (HEAD). GitFileReader.readFileFromCommitcan get the HEAD version.
  2. Parse that string into a BibDatabaseContext.
  3. Use BibDatabaseDiff.compare to get the two-way semantic diff. Or DatabaseChangeList.compareAndGetChanges.
  4. For the UI, DatabaseChangesResolverDialog is a good reference. But that one is accept/deny and writes changes back, so we'd probably want a preview-only version of it embedded in the commit dialog?

This is just what I've got so far, you might have a better approach

I think there should be a 0th step getting the git Status to track down for which files we actually need to Diff the working tree (current .bib) against the last commit (HEAD) And to show the list on viewModel we can use the pattern of commitTask Pardon for my vague wording As this is un-related with this issue maintainers @koppor @subhramit @wanling0000 will decide what they want to do.

thesauravpoddar avatar Aug 01 '26 14:08 thesauravpoddar

And as @subhramit earlier told to show the Diff view in same dialog of commit view i think that would become clustred i think better apprach is to have show diff button and a new dialog for diff

thesauravpoddar avatar Aug 01 '26 14:08 thesauravpoddar

I think there should be a 0th step getting the git Status to track down for which files we actually need to Diff the working tree (current .bib) against the last commit (HEAD)\nAnd to show the list on viewModel we can use the pattern of commitTask\nPardon for my vague wording\nAs this is un-related with this issue

You are welcome to file a draft PR if you're interested to improve the git feature beyond this issue. It may take a couple of iterations, but we keep looking for volunteers who can help us, as this is a free-time project for us.

subhramit avatar Aug 01 '26 15:08 subhramit

I think there should be a 0th step getting the git Status to track down for which files we actually need to Diff the working tree (current .bib) against the last commit (HEAD)\nAnd to show the list on viewModel we can use the pattern of commitTask\nPardon for my vague wording\nAs this is un-related with this issue

You are welcome to file a draft PR if you're interested to improve the git feature beyond this issue. It may take a couple of iterations, but we keep looking for volunteers who can help us, as this is a free-time project for us.

Yes, sure i would glad to do that

thesauravpoddar avatar Aug 01 '26 15:08 thesauravpoddar

I have a doubt during testing of my implementation i am getting error related to UTF-8 format of .bib files, so my question is does JabRef supports non-UTF-8 .bib files?

thesauravpoddar avatar Aug 03 '26 16:08 thesauravpoddar