Patchwork [2,of,3] lfs: default the User-Agent header for blob transfers to 'git-lfs'

mail settings
Submitter Matt Harbison
Date Jan. 18, 2018, 11:51 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/26939/
State Accepted
Headers show


Matt Harbison - Jan. 18, 2018, 11:51 p.m.
# HG changeset patch
# User Matt Harbison <>
# Date 1516309161 18000
#      Thu Jan 18 15:59:21 2018 -0500
# Node ID b25b315be2f43cefdb364e52aa614ee3dcddefed
# Parent  3e89ebf3fc09542792ecccb41c9ea923e270bf76
lfs: default the User-Agent header for blob transfers to 'git-lfs'

The custom User-Agent for blob transfers was added in e7bb5fc4570c.  Now I've
hit another incompatibility with a server wanting the string to start with
'git' or 'git-lfs' [1].  I don't feel strongly about this either way, but a
Wireshark trace of git shows that when the Batch API is hit, the User-Agent is
'git-lfs/2.3.4'.  So this would probably ensure maximum interoperability.

This still leaves the experimental knob in, just in case.



diff --git a/hgext/lfs/ b/hgext/lfs/
--- a/hgext/lfs/
+++ b/hgext/lfs/
@@ -188,7 +188,7 @@  class _gitlfsremote(object):
         self.baseurl = baseurl.rstrip('/')
         useragent = repo.ui.config('experimental', 'lfs.user-agent')
         if not useragent:
-            useragent = 'mercurial/%s git/2.15.1' % util.version()
+            useragent = 'git-lfs/2.3.4 (Mercurial %s)' % util.version()
         self.urlopener = urlmod.opener(ui, authinfo, useragent)
         self.retry = ui.configint('lfs', 'retry')