jupyterlab / jupyterlab-git

A Git extension for JupyterLab
BSD 3-Clause "New" or "Revised" License
1.45k stars 315 forks source link

Git diffing fails on merge conflict #896

Closed slenky closed 3 years ago

slenky commented 3 years ago

Description

Hello, We are having an issues with diffing both notebook and python files if there is a Merge Conflict.

Reproduce (notebook)

  1. You need to create a Merge conflict situation (i.e two guys changing a one file)
  2. Commit, and then try to pull.
  3. You'll get a Pull error message.
  4. Click on Diff on the file in Staged section: image
  5. This is what you'll get in UI: image
  6. And error in the logs: Unreadable Notebook: /home/kflovian/scripts/tm/yq-tutorials/Tutorial_template.ipynb NotJSONError('Notebook does not appear to be JSON: \'{\n "cells": [\n {\n "cell_type": "m...')

If you open this notebook in Editor, there will be git merge symbols (>>>>>> and <<<<<<) image

Reproduce (python file)

There is a different error pops up on Python file merge conflicts. If you repeat a steps above on Python file and click on Diff on Staged section, you'll get an error:

[W 2021-03-10 14:41:53.827 ServerApp] 500 POST /notebook/bohdana/nohybrid2/git/diffcontent?1615383700875 (127.0.0.1): Error [fatal: Path 'file.py' is in the index, but not at stage 0.
    Did you mean ':1:file.py'?
    ] occurred while executing [git show :file.py] command to retrieve plaintext diff.
[W 2021-03-10 14:41:53.828 ServerApp] Error [fatal: Path 'file.py' is in the index, but not at stage 0.
    Did you mean ':1:file.py'?
    ] occurred while executing [git show :file.py] command to retrieve plaintext diff.

If I execute git show :1:file.py in the terminal, it works.

Expected behavior

Git diff works.

Context

Other labextensions (built into JupyterLab) app dir: /opt/conda/share/jupyter/lab @krassowski/jupyterlab-lsp v3.4.1 enabled OK nbdime-jupyterlab v2.1.0-beta.1 enabled OK


- Git version:
git version 2.25.1
- Operating System and its version: Docker image
fcollonval commented 3 years ago

Thanks @slenky

Unfortunately the extension does not support conflict. Contribution are more than welcome on that front.