mhagger / git-imerge

Incremental merge for git
GNU General Public License v2.0
2.68k stars 126 forks source link

Cannot proceed dead lock ( maybe related to `git lfs` in history? ) #190

Closed flybyray closed 2 years ago

flybyray commented 2 years ago

I am in the middle of git-imerge with GOAL merge git imerge start --name=imerge_ops_587 --goal=merge --first-parent feature/OPS-587 And somehow it looks like a dead lock no way to proceed with the merge. The file which appears by git status sometimes and produces git imerge output unstaged changes or uncommitted changes is from git lfs. The goal besides the merge would be to completly remove/replace(maybe 0-bytes) all lfs related files at the end of git imerge finish.

Is this possible with git imerge?

here some relevant details from the shell:

$ git status
On branch development
Your branch is up to date with 'origin/development'.

nothing to commit, working tree clean
$ git imerge list
* imerge_ops_587
$ git imerge diagram
       0    5   10   15   20   25   30   35   40   45   50   55   60   65   70   75   80   85   90   95  100  105  110  115  120  125  130  135  140  145  150  155  160   164
       |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |   |
   0 - ********************************************************************************************************************************************************************* - development
       *??...........*???...................*?..-+#?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
   2 - *---*--------------**-------------------*#???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
       |
     feature/OPS-587

Key:
  |,-,+ = rectangles forming current merge frontier
  * = merge done manually
  . = merge done automatically
  # = conflict that is currently blocking progress
  @ = merge was blocked but has been resolved
  ? = no merge recorded

$ git imerge continue
Switched to branch 'imerge/imerge_ops_587'
error: Your local changes to the following files would be overwritten by merge:
        files/yq_linux_amd64.tar.gz
Please commit your changes or stash them before you merge.
Aborting

Original first commit:
commit c7e26be21a7125a0fa947ce390fc4cbd795aec99 (refs/imerge/imerge_ops_587/manual/41-0)
Merge: 5bd64fad 9ed00fca
Author: author1
Date:   date1

    commit msg 1

Original second commit:
commit c0aa8319322c5b3021e7548f31d9bd9dbe8e2834 (origin/feature/OPS-587, refs/imerge/imerge_ops_587/manual/0-2, feature/OPS-587)
Author: author1
Date:   date2

    commit msg 2

There was a conflict merging commit 41-2, shown above.
Please resolve the conflict, commit the result, then type

    git-imerge continue

$ git status
On branch imerge/imerge_ops_587
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   files/yq_linux_amd64.tar.gz

no changes added to commit (use "git add" and/or "git commit -a")

$ git imerge continue
Cannot proceed: You have unstaged changes.

$ git add .
warning: CRLF will be replaced by LF in files/yq_linux_amd64.tar.gz.
The file will have its original line endings in your working directory

$ git imerge continue
Cannot proceed: Your index contains uncommitted changes.

$ git status --untracked-files --verbose
On branch imerge/imerge_ops_587
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   files/yq_linux_amd64.tar.gz

diff --git a/files/yq_linux_amd64.tar.gz b/files/yq_linux_amd64.tar.gz
index 36fabf0f..4e5ca8e9 100644
Binary files a/files/yq_linux_amd64.tar.gz and b/files/yq_linux_amd64.tar.gz differ
flybyray commented 2 years ago

With --manual merge. I debugged with a loop like this to break on merges or loop when the lfs file appears.

while true
do
  git log files/yq_linux_amd64.tar.gz || git imerge continue || break
  sleep 1
done

When I received a point when the file exists in git log hit Ctrl-C. Then i debugged with python trace module and found that this command returns error 1. 'git' 'diff-index' '--cached' '--quiet' '--ignore-submodules' 'HEAD' '--'

When executed manually without --quiet I see this output:

:100644 000000 36fabf0fed23a65d043807e75e161f6072f3b15a 0000000000000000000000000000000000000000 D    files/yq_linux_amd64.tar.gz

I think this is correct and a bug in git imerge because this is a staged file ( deleted ) and I would expect git imerge continue would operate as normal.

$ git status --verbose
On branch imerge/feature/OPS-587
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        deleted:    files/yq_linux_amd64.tar.gz

diff --git a/files/yq_linux_amd64.tar.gz b/files/yq_linux_amd64.tar.gz
deleted file mode 100644
index 36fabf0f..00000000
Binary files a/files/yq_linux_amd64.tar.gz and /dev/null differ
flybyray commented 2 years ago

I think I had an usage error here. Started from beginning again. And i think the essential thing was to just remove the file from index ( git rm --cached files/yq_linux_amd64.tar.gz ) and put it into .gitignore file than stage them. afterwards git imerge continue worked as expected.