diff --git a/reviewboard/webapi/resources/diff.py b/reviewboard/webapi/resources/diff.py
index 53f3652ec860f417c4d529ea22c38256bcf2555c..96ae0a16825d7a6e19b43f0b9af48b79f218b6de 100644
--- a/reviewboard/webapi/resources/diff.py
+++ b/reviewboard/webapi/resources/diff.py
@@ -91,6 +91,12 @@ class DiffResource(WebAPIResource):
                            'diff was uploaded.',
             'added_in': '1.7.13',
         },
+        'commit_count': {
+            'type': IntFieldType,
+            'description': 'The number of commits present in the case of '
+                           'review requests created with commit history.',
+            'added_in': '4.0',
+        },
     }
     item_child_resources = [
         resources.diffcommit,
@@ -457,5 +463,38 @@ class DiffResource(WebAPIResource):
         return super(DiffResource, self).get_links(
             child_resources, obj=obj, request=request, *args, **kwargs)
 
+    def serialize_object(self, obj, request=None, *args, **kwargs):
+        """Serialize a DiffSet.
+
+        This method excludes fields from features that are not enabled.
+
+        Args:
+            obj (reviewboard.diffviewer.models.diffset.DiffSet):
+                The DiffSet to serialize.
+
+            request (django.http.HttpRequest, optional):
+                The HTTP request from the client.
+
+            *args (tuple):
+                Additional positional arguments.
+
+            **kwargs (dict):
+                Additional keyword arguments.
+
+        Returns:
+            dict:
+            The serialized DiffSet.
+        """
+        result = super(DiffResource, self).serialize_object(
+            obj, request=request, *args, **kwargs)
+
+        if not dvcs_feature.is_enabled(request=request):
+            # The field may not have been serialized (e.g., if `only-fields`
+            # was set to a subset of fields that excludes
+            # `created_with_history`).
+            result.pop('commit_count', None)
+
+        return result
+
 
 diff_resource = DiffResource()
diff --git a/reviewboard/webapi/tests/test_diff.py b/reviewboard/webapi/tests/test_diff.py
index f302adaa29a8affd21f8df95e9e9daad7c49041f..6a42a381cd9bffb59b758a0b651c310bc69b49ec 100644
--- a/reviewboard/webapi/tests/test_diff.py
+++ b/reviewboard/webapi/tests/test_diff.py
@@ -343,9 +343,9 @@ class ResourceItemTests(ExtraDataItemMixin, ReviewRequestChildItemMixin,
             check_etags=True)
 
     @webapi_test_template
-    def test_get_links_dvcs_enabled(self):
-        """Testing the GET <URL> API does includes a link to the DiffCommit
-        resource when the DVCS feature is enabled
+    def test_get_links_fields_dvcs_enabled(self):
+        """Testing the GET <URL> API does includes DVCS-specific fields and
+        links when the DVCS feature is enabled
         """
         review_request = self.create_review_request(create_repository=True,
                                                     publish=True)
@@ -361,11 +361,14 @@ class ResourceItemTests(ExtraDataItemMixin, ReviewRequestChildItemMixin,
 
         item_rsp = rsp['diff']
         self.assertIn('links', item_rsp)
+        self.assertIn('commits', item_rsp['links'])
+
+        self.assertIn('commit_count', item_rsp)
 
     @webapi_test_template
-    def test_get_links_dvcs_disabled(self):
-        """Testing the GET <URL> API does not include a link to the DiffCommit
-        resource when the DVCS feature is disabled
+    def test_get_links_fields_dvcs_disabled(self):
+        """Testing the GET <URL> API does not includes DVCS-specific fields and
+        links when the DVCS feature is enabled
         """
         review_request = self.create_review_request(create_repository=True,
                                                     publish=True)
@@ -381,7 +384,8 @@ class ResourceItemTests(ExtraDataItemMixin, ReviewRequestChildItemMixin,
 
         item_rsp = rsp['diff']
         self.assertIn('links', item_rsp)
-        self.assertNotIn('diffcommits', item_rsp['links'])
+        self.assertNotIn('commits', item_rsp['links'])
+        self.assertNotIn('commit_count', item_rsp)
 
     #
     # HTTP PUT tests
