diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2017-05-11 15:48:28 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-05-12 15:05:59 +0900 |
commit | a57e2151bf3c8710aaa0b045496797113369ed25 (patch) | |
tree | 08ccefbf9fbaf3accafb2119d34ac4b12eafe0c7 | |
parent | 54d46f4826154e4eccd47d7709b34824d107f8e9 (diff) | |
download | git-js/retire-old-remote-spec.tar.gz |
PREVIEW: remove support for .git/remotes/ and .git/branches/js/retire-old-remote-spec
At long last, after a cycle or three of warning users who *still* use
the ancient feature of .git/remotes/ and .git/branches/, it is time to
retire the code.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | path.c | 2 | ||||
-rw-r--r-- | remote.c | 96 | ||||
-rw-r--r-- | remote.h | 4 |
3 files changed, 1 insertions, 101 deletions
@@ -104,7 +104,6 @@ struct common_dir { }; static struct common_dir common_list[] = { - { 0, 1, 0, "branches" }, { 0, 1, 0, "hooks" }, { 0, 1, 0, "info" }, { 0, 0, 1, "info/sparse-checkout" }, @@ -115,7 +114,6 @@ static struct common_dir common_list[] = { { 0, 1, 0, "objects" }, { 0, 1, 0, "refs" }, { 0, 1, 1, "refs/bisect" }, - { 0, 1, 0, "remotes" }, { 0, 1, 0, "worktrees" }, { 0, 1, 0, "rr-cache" }, { 0, 1, 0, "svn" }, @@ -241,89 +241,6 @@ static void add_instead_of(struct rewrite *rewrite, const char *instead_of) rewrite->instead_of_nr++; } -static const char *skip_spaces(const char *s) -{ - while (isspace(*s)) - s++; - return s; -} - -static void read_remotes_file(struct remote *remote) -{ - struct strbuf buf = STRBUF_INIT; - FILE *f = fopen(git_path("remotes/%s", remote->name), "r"); - - if (!f) - return; - - warning(_("the remote '%s' uses the long-deprecated '%s' file"), - remote->name, git_path("branches/%s", remote->name)); - - remote->configured_in_repo = 1; - remote->origin = REMOTE_REMOTES; - while (strbuf_getline(&buf, f) != EOF) { - const char *v; - - strbuf_rtrim(&buf); - - if (skip_prefix(buf.buf, "URL:", &v)) - add_url_alias(remote, xstrdup(skip_spaces(v))); - else if (skip_prefix(buf.buf, "Push:", &v)) - add_push_refspec(remote, xstrdup(skip_spaces(v))); - else if (skip_prefix(buf.buf, "Pull:", &v)) - add_fetch_refspec(remote, xstrdup(skip_spaces(v))); - } - strbuf_release(&buf); - fclose(f); -} - -static void read_branches_file(struct remote *remote) -{ - char *frag; - struct strbuf buf = STRBUF_INIT; - FILE *f = fopen(git_path("branches/%s", remote->name), "r"); - - if (!f) - return; - - strbuf_getline_lf(&buf, f); - fclose(f); - strbuf_trim(&buf); - if (!buf.len) { - strbuf_release(&buf); - return; - } - - warning(_("the branch '%s' uses the long-deprecated '%s' file"), - remote->name, git_path("branches/%s", remote->name)); - - remote->configured_in_repo = 1; - remote->origin = REMOTE_BRANCHES; - - /* - * The branches file would have URL and optionally - * #branch specified. The "master" (or specified) branch is - * fetched and stored in the local branch matching the - * remote name. - */ - frag = strchr(buf.buf, '#'); - if (frag) - *(frag++) = '\0'; - else - frag = "master"; - - add_url_alias(remote, strbuf_detach(&buf, NULL)); - add_fetch_refspec(remote, xstrfmt("refs/heads/%s:refs/heads/%s", - frag, remote->name)); - - /* - * Cogito compatible push: push current HEAD to remote #branch - * (master if missing) - */ - add_push_refspec(remote, xstrfmt("HEAD:refs/heads/%s", frag)); - remote->fetch_tags = 1; /* always auto-follow */ -} - static int handle_config(const char *key, const char *value, void *cb) { const char *name; @@ -652,13 +569,6 @@ void free_refspec(int nr_refspec, struct refspec *refspec) free(refspec); } -static int valid_remote_nick(const char *name) -{ - if (!name[0] || is_dot_or_dotdot(name)) - return 0; - return !strchr(name, '/'); /* no slash */ -} - const char *remote_for_branch(struct branch *branch, int *explicit) { if (branch && branch->remote_name) { @@ -700,12 +610,6 @@ static struct remote *remote_get_1(const char *name, name = get_default(current_branch, &name_given); ret = make_remote(name, 0); - if (valid_remote_nick(name) && have_git_dir()) { - if (!valid_remote(ret)) - read_remotes_file(ret); - if (!valid_remote(ret)) - read_branches_file(ret); - } if (name_given && !valid_remote(ret)) add_url_alias(ret, name); if (!valid_remote(ret)) @@ -6,9 +6,7 @@ enum { REMOTE_UNCONFIGURED = 0, - REMOTE_CONFIG, - REMOTE_REMOTES, - REMOTE_BRANCHES + REMOTE_CONFIG }; struct remote { |