Merge branch 'stable-5.0' into stable-5.1

* stable-5.0:
  UploadPack: Avoid calling AdvertiseRefsHook twice

Change-Id: Ie9ce67921e38fff8338a148c4d9f2776be01d0b0
Signed-off-by: Jonathan Nieder <jrn@google.com>
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
index bac877a..48a3e0b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
@@ -805,8 +805,10 @@ private Map<String, Ref> getAdvertisedOrDefaultRefs() throws IOException {
 			return refs;
 		}
 
-		advertiseRefsHook.advertiseRefs(this);
-		advertiseRefsHookCalled = true;
+		if (!advertiseRefsHookCalled) {
+			advertiseRefsHook.advertiseRefs(this);
+			advertiseRefsHookCalled = true;
+		}
 		if (refs == null) {
 			// Fall back to all refs.
 			setAdvertisedRefs(