Reputation: 11
I have one file where I recently discovered that some blocks of code disappeared. After some investigation I was able to pinpoint the exact hash where this happened, which is the immediate one before HEAD. In the following picture the HEAD is on the left side and the previous revision on the right. The missing pieces of code are related with the performTableViewUpdates
code.
When checking the merge request from gitlab that originated the HEAD version, we can see that the block still existed but was untouched, being the only changes in line 279.
It's important to state that we are using Gitflow and that this consisted in a merge from a feature branch to the main one. Also, when doing git log -SperformTableViewUpdates
I'm able to find the commit that introduced the code but there's none related with the code removal.
As anyone experienced this weird behaviour?
Thank you.
Upvotes: 0
Views: 1499
Reputation: 4476
It can happen if some code is modified in a merge commit. For example, look at the following example:
I made a repository with a conflicting merge, when solving the merge, I added a line test
in my file, which is displayed nowhere when logging the commits, but git show hash
on the merge commit shows this change.
Here is the content of the merge commit itself:
ghislain@ubuntu: /tmp/tmp (master) ✔
> git show
commit 76433b9ae1e9102bc32620167beb915eb276b000 (HEAD -> master)
Merge: 39cc93b 28b8cbe
Author: Ghislain Rodrigues <[email protected]>
Date: Mon Apr 15 11:33:39 2019 +0100
Merge branch 'foo'
diff --cc foo
index cbb0f31,3bd1f0e..f5741a4
--- a/foo
+++ b/foo
@@@ -1,2 -1,2 +1,4 @@@
foo
+toot
+ bar
++test
With the last line being test
added.
Then here is a log with patch of the commits:
ghislain@ubuntu: /tmp/tmp (master) ✔
> git log --patch --oneline --graph
* 76433b9 (HEAD -> master) - Merge branch 'foo' (16 seconds ago) <Ghislain Rodrigues>
|\
| * 28b8cbe (foo) - Bar added (2 minutes ago) <Ghislain Rodrigues>| |
| | diff --git a/foo b/foo
| | index 257cc56..3bd1f0e 100644
| | --- a/foo
| | +++ b/foo
| | @@ -1 +1,2 @@
| | foo
| | +bar
* | 39cc93b - toto (50 seconds ago) <Ghislain Rodrigues>
|/ |
| diff --git a/foo b/foo
| index 257cc56..cbb0f31 100644
| --- a/foo
| +++ b/foo
| @@ -1 +1,2 @@
| foo
| +toot
* 6d186bf - foo content (2 minutes ago) <Ghislain Rodrigues>|
| diff --git a/foo b/foo
| index e69de29..257cc56 100644
| --- a/foo
| +++ b/foo
| @@ -0,0 +1 @@
| +foo
* 59e2195 - init (3 minutes ago) <Ghislain Rodrigues>
diff --git a/foo b/foo
new file mode 100644
index 0000000..e69de29
In the log, the test
line is never displayed, but the file looks like that (without local changes of course):
foo
toot
bar
test
So if you had a merge with the code you lost which has been removed in the merge, it might be why you don't see the change in your commit.
If it is your issue is that, you should be able to see your deleted code in the merge commit, by doing:
git show hash-of-the-merge
Upvotes: 1