Vscode: Disallow staging of files with unresolved conflicts

Created on 3 Jul 2017  路  7Comments  路  Source: microsoft/vscode

Requesting to disallow staging of files with unresolved conflicts. Or at least show a warning message if a user is trying to stage a file with unresolved conflicts.

feature-request git good first issue help wanted

Most helpful comment

@BuraChuhadar @ferreus Let me introduce you guys to one another: #30568 #30529. 馃槅

All 7 comments

This is a cool idea actually, want to attempt a PR?

It's not that simple.
There are various types of conflicts possible, for example for conflict of types: (deleted by them / deleted by us) staging the file (git add), is a way to resole the conflict and keep the file.
In that case, refusing to stage the file, will prevent the user from resolving the conflict, and force the user to use alternative GIT client, to resole the conflict.

In such cases we can show a warning with: add/rm options. Or maybe show X,V buttons in the sidebar? But then, we need to show an indication of what actually happend , and a way to undo the operation before the actual commit. And it get's complicated.

For example, let's take this git conflict:

  1. master modify file foo
  2. branch fix delete file foo
  3. merge fix to master
  4. conflict: deleted by them

In this state, doing: git rm foo && git status
Shows:
Changes to be committed:
deleted foo
And this has a nice indication in VSCode

But if instead, i would do: git add foo && git status (Or stage the file from within VSCode)
I would see in terminal:

All conflicts fixed but you are still merging.
(use "git commit" to conclude merge)

Without any indication of our actions, and no way to undo the action.
VSCode shows the git repository as clean, without the need to commit at all. (Probably another issue)

I would be happy to work on this issue, but i don't know in what direction this should go.

I see your concern. What I observe in VSCode when there is a 'deleted by them' conflict in the SCM viewlet under the 'Merge Changes', is that the file has a strike-through style. I find that there are 2 options:

  • Upon mouse rollover, a '+' icon appears with the following tooltip: 'Stage Changes'. If I click on this icon, Git will resolve the conflict which will make the branch updated with nothing to commit. And that behavior is correct. Git simply negated the deletion that "_by them_" did. However that tooltip message is misleading, it didn鈥檛 stage the file, it simply resolved the conflict.
  • If I don鈥檛 click on the '+' icon and attempt to commit, the following notification appears that prevents a successful commit: 'Error: Git: Committing is not possible because you have unmerged files.'

In a 'deleted by us' scenario, the difference when compared from the scenario above is that when the '+' icon is clicked, it is indeed staged as an new file (Index added). So for the record, the only thing I see that needs to be fixed in a 'deleted by them' and 'deleted by us' scenario is the misleading tooltip message during a 'deleted by them' as mentioned above.

All other conflicts that contains conflict-markers (===, >>>, <<<) which are attempted to be added/staged should raise a warning as the OP suggested.

@joaomoreno this is my first try. Please review when you have the chance #30568. Thank you.

@BuraChuhadar @ferreus Let me introduce you guys to one another: #30568 #30529. 馃槅

Sadly, both of the PRs still couldn't pass CI. :(

Fixed by #30568

Was this page helpful?
0 / 5 - 0 ratings

Related issues

villiv picture villiv  路  3Comments

shanalikhan picture shanalikhan  路  3Comments

VitorLuizC picture VitorLuizC  路  3Comments

philipgiuliani picture philipgiuliani  路  3Comments

lukehoban picture lukehoban  路  3Comments