This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 242625 - With IDE open, sometimes .git/MERGE_HEAD missing after CLI git merge
Summary: With IDE open, sometimes .git/MERGE_HEAD missing after CLI git merge
Status: RESOLVED FIXED
Alias: None
Product: versioncontrol
Classification: Unclassified
Component: Git (show other bugs)
Version: 8.0
Hardware: PC Linux
: P1 normal (vote)
Assignee: Ondrej Vrabec
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-06 17:54 UTC by Jesse Glick
Modified: 2014-10-13 20:37 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2014-03-06 17:54:37 UTC
NB dev builds, from a few months back and from now.

http://stackoverflow.com/questions/19985906/git-merge-not-creating-merge-commit-no-merge-head

I use NB for diffing & committing but do all other Git operations from a shell. On occasion I have noticed that after running ‘git merge <otherbranch>’ when this has conflicts, even if I resolve all of the conflicts (from the shell / Emacs) and ‘git commit’, the commit message shows that I am making a regular commit, not a merge commit; indeed .git/MERGE_HEAD is not present. Of course in this situation the commit is bogus and must be discarded.

Finally a comment from another user pointed me to the cause: at the time, NetBeans is running with my project open. If I close NetBeans and retry the whole operation (‘git reset --hard HEAD && git merge <otherbranch> && cat .git/MERGE_HEAD’) then it works fine.

Note that not only I am not trying to initiate the merge from the IDE, I am not even switching to the IDE’s window or using it in any way; it is apparently noticing the changes on disk and doing something in the background which winds up deleting MERGE_HEAD.

Marking P2 since if you do not know the trigger you can waste a lot of time trying to get the merge to run normally, or (worse) keep the bogus commit with the missing merge parent.

Note that this does not seem to happen most of the time, just sometimes. When it happened just now, there was a modify/delete conflict (file deleted in HEAD and modified in the merged branch). MERGE_HEAD is missing before I even try to resolve the conflict.
Comment 1 Ondrej Vrabec 2014-03-06 18:19:15 UTC
AFAIK MERGE_HEAD is deleted only when a commit or reset is called from NetBeans and only when that command succeeds. I doubt NB deletes the file while you're working in shell. It might be that CLI git does not even create that file, maybe because a potential read/write conflict when NB is checking for the file's existence (though i doubt it, it sounds like a coincidence with probability closing to zero). And even then it would probably be git's fault.
> Note that not only I am not trying to initiate the merge from the IDE, I am not
> even switching to the IDE’s window or using it in any way; it is apparently
> noticing the changes on disk and doing something in the background which winds
> up deleting MERGE_HEAD.
i will try it several times, but again, i am not aware of any background task deleting the file.
Comment 2 Ondrej Vrabec 2014-03-07 10:33:02 UTC
i cannot reproduce, but as you said it does not always happen. I can try and delay calls to code responsible for checking/reading MREGE_HEAD file for later when the repository is currently locked.

fixed: core-main #8f67177d2224
Comment 3 Quality Engineering 2014-03-10 02:24:26 UTC
Integrated into 'main-silver', will be available in build *201403100001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/8f67177d2224
User: Ondrej Vrabec <ovrabec@netbeans.org>
Log: Issue #242625 - With IDE open, sometimes .git/MERGE_HEAD missing after CLI git merge
refresh repository info later when the repository contains index.lock file.
Comment 4 markiewb 2014-03-27 12:52:14 UTC
Happens also in 
Product Version: NetBeans IDE 8.0 (Build 201403101706)
Java: 1.8.0; Java HotSpot(TM) 64-Bit Server VM 25.0-b70
Runtime: Java(TM) SE Runtime Environment 1.8.0-b132
System: Windows 7 version 6.1 running on amd64; Cp1252; de_DE (nb)

Which is very bad. I lost hours realize that NB is the cause.
I will try a dev build and give you feedback
Comment 5 markiewb 2014-03-27 13:26:03 UTC
(In reply to markiewb from comment #4)
> Happens also in 
> Product Version: NetBeans IDE 8.0 (Build 201403101706)
> Java: 1.8.0; Java HotSpot(TM) 64-Bit Server VM 25.0-b70
> Runtime: Java(TM) SE Runtime Environment 1.8.0-b132
> System: Windows 7 version 6.1 running on amd64; Cp1252; de_DE (nb)
> 
> Which is very bad. I lost hours realize that NB is the cause.
> I will try a dev build and give you feedback

Reopen. Issue is still present in Dev Build 201403270001

Product Version: NetBeans IDE Dev (Build 201403270001)
Java: 1.8.0; Java HotSpot(TM) 64-Bit Server VM 25.0-b70
Runtime: Java(TM) SE Runtime Environment 1.8.0-b132
System: Windows 7 version 6.1 running on amd64; Cp1252; de_DE (nb)
Comment 6 Ondrej Vrabec 2014-03-28 07:42:25 UTC
(In reply to markiewb from comment #5)
> Reopen. Issue is still present in Dev Build 201403270001
That's bad. I have no idea how to reproduce, i am not aware of any place we might delete such a file. If you can reproduce, point me to a specific project i can try it with and provide steps to reproduce (what branches you merge etc.)
Comment 7 Ondrej Vrabec 2014-04-04 12:03:38 UTC
Trying another round, there was still a chance that a locked repository was refreshed (metadata read) and CLI process interrupted by NetBeans. Please let me know if you can reproduce it again.

fix: http://hg.netbeans.org/core-main/rev/41ff10528665
Comment 8 Quality Engineering 2014-04-06 01:31:10 UTC
Integrated into 'main-silver', will be available in build *201404060001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/41ff10528665
User: Ondrej Vrabec <ovrabec@netbeans.org>
Log: #242625 - With IDE open, sometimes .git/MERGE_HEAD missing after CLI git merge
Never start any JGit command while another process is touching the repository.
Instead wait for the lock to be released and refresh repository state in NetBeans later.
Comment 9 Ondrej Vrabec 2014-06-18 10:48:01 UTC
I think i found it. Happens always when you create new file in IDE.

fix: http://hg.netbeans.org/core-main/rev/38a75766c601
Comment 10 Quality Engineering 2014-06-19 02:36:31 UTC
Integrated into 'main-silver', will be available in build *201406190001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/38a75766c601
User: Ondrej Vrabec <ovrabec@netbeans.org>
Log: #242625 - With IDE open, sometimes .git/MERGE_HEAD missing after CLI git merge
Never delete the metadata files when running mere reset -- PATHS command