lambdalisue / vim-gita

[Obsolete] An awesome git handling plugin for Vim
Other
226 stars 8 forks source link

Add diffget keymap for worktree #143

Open kota65535 opened 7 years ago

kota65535 commented 7 years ago

Summary (required)

In 2-way diff, Working tree can be reverted partially to Index by do or dp. It is useful to clean unneeded code.
But in 3-way diff, there is no keymap to make Worktree diffget from Index. This PR add do keymap to realize it.

lambdalisue commented 7 years ago

I wonder if you have considered about HEAD -> Worktree?

I'm not sure if I should care about HEAD -> Worktree as well but in that case, the mapping should be doi (diff obtain from index) for Index -> Worktree and dol (diff obtain from left/local) for HEAD -> Worktree. It's OK if you have consider about HEAD -> Worktree and decided to ignore it while I could not find any use case for HEAD -> Worktree but in case.

kota65535 commented 7 years ago

I wonder if you have considered about HEAD -> Worktree?

In fact, I tried it at first but I think it can be confusing.
If there are changes in Working tree only, there is no problem because HEAD and Index are equal. But in the situation that I'm going to revert staged changes partially, there are 2 ways to be considered.

  1. First HEAD -> Index, next Index -> Worktree
  2. First HEAD -> Worktree, next HEAD -> Index

I preferred the first approach because it is more similar to the usual workflow for me.
Second approach temporarily comes into the state that Index is not equal to both HEAD and Worktree, which does not occur in a usual workflow by git command, I think.

It may be better to do HEAD -> Index and Index -> Worktree at once.

lambdalisue commented 7 years ago

I preferred the first approach because it is more similar to the usual workflow for me. Second approach temporarily comes into the state that Index is not equal to both HEAD and Worktree, which does not occur in a usual workflow by git command, I think.

I see. I agree with you approach.

It may be better to do HEAD -> Index and Index -> Worktree at once.

Sounds interesting but I'm feeling that is a bit too much.

The code looks good so please add documentation about this new mapping around https://github.com/lambdalisue/vim-gita/blob/master/doc/gita.txt#L245-L263