eclipse-jgit / jgit

JGit, the Java implementation of git
https://www.eclipse.org/jgit/
Other
92 stars 31 forks source link

Binary Conflict file is empty (0 byte file). #14

Closed scgsupport closed 2 months ago

scgsupport commented 6 months ago

Version

6.6.0

Operating System

Windows

Bug description

We try merge the git workspace. If it has conflict binary files, it makes 0 byte file. The same case when we do it using git command, the binary file has maintain the content as local version and marked the file as conflict. We expect the same behavior in JGit API also.

Actual behavior

Binary conflicted files(example jpeg file conflict) are empty after merge with JGit API. This makes issue, user does not know the actual content of the file and they cannot open the file in corresponding tools.

Expected behavior

The same above case, if I perform the merge using git command, the file content remains as local version content. It marked the file as conflict. Hence user can open the file and see the content and resolve the conflict manually.

We expect the same git command behavior in JGit merge API.

2024-01-11 13_57_02-Clipboard image-2024-01-03-13-19-45-081

Relevant log output

No response

Other information

No response

tomaswolf commented 6 months ago

Does this also occur with the latest JGit 6.8.0?

scgsupport commented 6 months ago

Yes.. it occurs in 6.8.0.202311291450-r also.

kumarp149 commented 5 months ago

I think, I can work on this issue. I have gone through the code and got some insights on what's going wrong. Can I get this issue assigned to me, please

kumarp149 commented 5 months ago

In the class ResolveMerger.java, we are trying to create a RawText MergeResult in the method contentMerge. But for binary files, this method would throw BinaryBlobException which implies that the MergeResult has no chunks. Even with no chunks, we are trying to create a new OutputStream to file in workTreeUpdater.updateFileWithContent method which is making our file empty

kumarp149 commented 5 months ago

Hi Link for gerrit review: https://review.gerrithub.io/c/eclipse-jgit/jgit/+/1176055

Please go through and give your suggestions

kumarp149 commented 5 months ago

Link for the gerrit review: https://review.gerrithub.io/c/eclipse-jgit/jgit/+/1176833

Please go through it @tomaswolf

kumarp149 commented 4 months ago

Hi @tomaswolf Updated the gerrit review. Please go through it

tomaswolf commented 4 months ago

You don't need to ping me here. I get e-mails from gerrit anyway.

kumarp149 commented 2 months ago

Hi @msohn Can you please review the following gerrit review and help me with your feedback

https://review.gerrithub.io/c/eclipse-jgit/jgit/+/1176833

msohn commented 2 months ago

merged as 567315af548017cc58eadb91bba493b74c391009