Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 405506

Summary: Exception when fetching/pulling and no Gerrit notes yet
Product: [Technology] JGit Reporter: Dani Megert <daniel_megert>
Component: JGitAssignee: Project Inbox <jgit.core-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: major    
Priority: P3 CC: denis.roy, matthias.sohn
Version: 2.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Dani Megert CLA 2013-04-11 14:30:06 EDT
I've setup my repo to work with Gerrit, i.e. I have added this line:

fetch = refs/notes/review:refs/notes/review

Now, because there are no notes yet, I get an exception when fetching/pulling:

!ENTRY org.eclipse.egit.ui 4 0 2013-04-11 20:13:29.435
!MESSAGE Remote does not have refs/notes/review available for fetch.
!STACK 0
org.eclipse.jgit.api.errors.TransportException: Remote does not have refs/notes/review available for fetch.
	at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:137)
	at org.eclipse.jgit.api.PullCommand.call(PullCommand.java:245)
	at org.eclipse.egit.core.op.PullOperation$1.run(PullOperation.java:90)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2345)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2327)
	at org.eclipse.egit.core.op.PullOperation.execute(PullOperation.java:121)
	at org.eclipse.egit.ui.internal.pull.PullOperationUI.execute(PullOperationUI.java:115)
	at org.eclipse.egit.ui.internal.pull.PullOperationUI$1.run(PullOperationUI.java:90)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Caused by: org.eclipse.jgit.errors.TransportException: Remote does not have refs/notes/review available for fetch.
	at org.eclipse.jgit.transport.FetchProcess.expandSingle(FetchProcess.java:371)
	at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:148)
	at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:122)
	at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1104)
	at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:128)
	... 8 more
Comment 1 Dani Megert CLA 2013-04-12 03:15:53 EDT
The bad thing is, that it just aborts i.e. it does not fetch/pull the normal changes from the repo just because the notes are missing.
Comment 2 Matthias Sohn CLA 2013-04-17 18:42:19 EDT
I think this is consistent with the behavior of native git, I tried fetching
a non-existing branch from jgit using native git and this also fails with
an error:

[jgit (master)]$ git fetch origin xxx:xxx
fatal: Couldn't find remote ref xxx
Unexpected end of command stream

when using a refspec with wildcards the command silently does fetch nothing:

[jgit (master)]$ git fetch origin xxx/*:xxx/*
[jgit (master)]$

so if you set
fetch = refs/notes/*:refs/notes/*
instead of
fetch = refs/notes/review:refs/notes/review

the fetch command should succeed (also from JGit)
Comment 3 Dani Megert CLA 2013-04-19 05:46:01 EDT
I don't know why I used

fetch = refs/notes/review:refs/notes/review

Maybe a wiki or the Gerrit Configurator added this in the old days. I verified that the current docs and the configurator suggest:
fetch = refs/notes/*:refs/notes/*
Comment 4 Matthias Sohn CLA 2013-04-19 08:37:06 EDT
some time ago there was a EGit version which configured
fetch = refs/notes/review:refs/notes/review

this was fixed with
https://git.eclipse.org/r/#/c/4428/