-->

visualstudio.com thinks latest libgit2 is old

2019-07-21 21:04发布

问题:

When cloning or fetching from visualstudio.com I get a sideband message that "you're using an older version of Git".

This happens with libgit2 commit f1323d9 that is from January 10.

Is there anything I can do about this and is this anything I should worry about?

It can be replicated with something like

#include <stdio.h>
#include <git2.h>

static int cred_acquire_cb(git_cred **cred, const char *url, 
                           const char *username_from_url,
                           unsigned int allowed_types, void *payload) {
  return git_cred_userpass_plaintext_new(cred, "email@address.com", "token");
}

static int sideband_progress_cb(const char *str, int len, void *payload) {
   printf("%s", str);
   return 0;
}

int main() {
   git_libgit2_init();

   git_clone_options clone_options = GIT_CLONE_OPTIONS_INIT;
   clone_options.fetch_opts.callbacks.credentials = cred_acquire_cb;
   clone_options.fetch_opts.callbacks.sideband_progress = sideband_progress_cb;

   git_repository *repo = NULL;
   const char *url = "https://account.visualstudio.com/project/_git/repo";
   const char *path = "repo";
   int error = git_clone(&repo, url, path, &clone_options);
   if(error < 0) {
      fprintf(stderr, "error = %d, %s\n", error, giterr_last()->message);       
   }

   return 0;
}

回答1:

No - there's nothing to worry about here. VSTS is trying to be helpful by looking at the version of Git that you're running and suggesting that you upgrade if you're running something outdated.

libgit2 has to send a Git version string as part of its user agent, pretending to be Git itself, because some hosting providers[1] are "over enthusiastic" about looking at the user agent[2] and if they don't see a git/ prefix at the start, will assume that you're a web browser and redirect you to their home page.

This is much the same way that every graphical web browser claims to be Mozilla.

标签: c libgit2