grep: turn off gitlink detection for --no-index
[gitweb.git] / builtin / remote.c
index dee6551e358fda98bfe5048a7f042f5fda3ca185..fda5c2e53d28ae84f4876ca77ac9fefebee9ada2 100644 (file)
@@ -119,7 +119,7 @@ static void add_branch(const char *key, const char *branchname,
        else
                strbuf_addf(tmp, "refs/heads/%s:refs/remotes/%s/%s",
                                branchname, remotename, branchname);
-       git_config_set_multivar_or_die(key, tmp->buf, "^$", 0);
+       git_config_set_multivar(key, tmp->buf, "^$", 0);
 }
 
 static const char mirror_advice[] =
@@ -186,10 +186,7 @@ static int add(int argc, const char **argv)
        url = argv[1];
 
        remote = remote_get(name);
-       if (remote && (remote->url_nr > 1 ||
-                       (strcmp(name, remote->url[0]) &&
-                               strcmp(url, remote->url[0])) ||
-                       remote->fetch_refspec_nr))
+       if (remote_is_configured(remote))
                die(_("remote %s already exists."), name);
 
        strbuf_addf(&buf2, "refs/heads/test:refs/remotes/%s/test", name);
@@ -197,7 +194,7 @@ static int add(int argc, const char **argv)
                die(_("'%s' is not a valid remote name"), name);
 
        strbuf_addf(&buf, "remote.%s.url", name);
-       git_config_set_or_die(buf.buf, url);
+       git_config_set(buf.buf, url);
 
        if (!mirror || mirror & MIRROR_FETCH) {
                strbuf_reset(&buf);
@@ -213,14 +210,14 @@ static int add(int argc, const char **argv)
        if (mirror & MIRROR_PUSH) {
                strbuf_reset(&buf);
                strbuf_addf(&buf, "remote.%s.mirror", name);
-               git_config_set_or_die(buf.buf, "true");
+               git_config_set(buf.buf, "true");
        }
 
        if (fetch_tags != TAGS_DEFAULT) {
                strbuf_reset(&buf);
                strbuf_addf(&buf, "remote.%s.tagopt", name);
-               git_config_set_or_die(buf.buf,
-                                     fetch_tags == TAGS_SET ? "--tags" : "--no-tags");
+               git_config_set(buf.buf,
+                              fetch_tags == TAGS_SET ? "--tags" : "--no-tags");
        }
 
        if (fetch && fetch_remote(name))
@@ -247,7 +244,7 @@ static int add(int argc, const char **argv)
 struct branch_info {
        char *remote_name;
        struct string_list merge;
-       int rebase;
+       enum { NO_REBASE, NORMAL_REBASE, INTERACTIVE_REBASE } rebase;
 };
 
 static struct string_list branch_list;
@@ -307,7 +304,9 @@ static int config_read_branches(const char *key, const char *value, void *cb)
                        if (v >= 0)
                                info->rebase = v;
                        else if (!strcmp(value, "preserve"))
-                               info->rebase = 1;
+                               info->rebase = NORMAL_REBASE;
+                       else if (!strcmp(value, "interactive"))
+                               info->rebase = INTERACTIVE_REBASE;
                }
        }
        return 0;
@@ -586,15 +585,15 @@ static int migrate_file(struct remote *remote)
 
        strbuf_addf(&buf, "remote.%s.url", remote->name);
        for (i = 0; i < remote->url_nr; i++)
-               git_config_set_multivar_or_die(buf.buf, remote->url[i], "^$", 0);
+               git_config_set_multivar(buf.buf, remote->url[i], "^$", 0);
        strbuf_reset(&buf);
        strbuf_addf(&buf, "remote.%s.push", remote->name);
        for (i = 0; i < remote->push_refspec_nr; i++)
-               git_config_set_multivar_or_die(buf.buf, remote->push_refspec[i], "^$", 0);
+               git_config_set_multivar(buf.buf, remote->push_refspec[i], "^$", 0);
        strbuf_reset(&buf);
        strbuf_addf(&buf, "remote.%s.fetch", remote->name);
        for (i = 0; i < remote->fetch_refspec_nr; i++)
-               git_config_set_multivar_or_die(buf.buf, remote->fetch_refspec[i], "^$", 0);
+               git_config_set_multivar(buf.buf, remote->fetch_refspec[i], "^$", 0);
        if (remote->origin == REMOTE_REMOTES)
                unlink_or_warn(git_path("remotes/%s", remote->name));
        else if (remote->origin == REMOTE_BRANCHES)
@@ -623,14 +622,14 @@ static int mv(int argc, const char **argv)
        rename.remote_branches = &remote_branches;
 
        oldremote = remote_get(rename.old);
-       if (!oldremote)
+       if (!remote_is_configured(oldremote))
                die(_("No such remote: %s"), rename.old);
 
        if (!strcmp(rename.old, rename.new) && oldremote->origin != REMOTE_CONFIG)
                return migrate_file(oldremote);
 
        newremote = remote_get(rename.new);
-       if (newremote && (newremote->url_nr > 1 || newremote->fetch_refspec_nr))
+       if (remote_is_configured(newremote))
                die(_("remote %s already exists."), rename.new);
 
        strbuf_addf(&buf, "refs/heads/test:refs/remotes/%s/test", rename.new);
@@ -646,7 +645,7 @@ static int mv(int argc, const char **argv)
 
        strbuf_reset(&buf);
        strbuf_addf(&buf, "remote.%s.fetch", rename.new);
-       git_config_set_multivar_or_die(buf.buf, NULL, NULL, 1);
+       git_config_set_multivar(buf.buf, NULL, NULL, 1);
        strbuf_addf(&old_remote_context, ":refs/remotes/%s/", rename.old);
        for (i = 0; i < oldremote->fetch_refspec_nr; i++) {
                char *ptr;
@@ -666,7 +665,7 @@ static int mv(int argc, const char **argv)
                                  "\tPlease update the configuration manually if necessary."),
                                buf2.buf);
 
-               git_config_set_multivar_or_die(buf.buf, buf2.buf, "^$", 0);
+               git_config_set_multivar(buf.buf, buf2.buf, "^$", 0);
        }
 
        read_branches();
@@ -676,7 +675,7 @@ static int mv(int argc, const char **argv)
                if (info->remote_name && !strcmp(info->remote_name, rename.old)) {
                        strbuf_reset(&buf);
                        strbuf_addf(&buf, "branch.%s.remote", item->string);
-                       git_config_set_or_die(buf.buf, rename.new);
+                       git_config_set(buf.buf, rename.new);
                }
        }
 
@@ -758,7 +757,7 @@ static int rm(int argc, const char **argv)
                usage_with_options(builtin_remote_rm_usage, options);
 
        remote = remote_get(argv[1]);
-       if (!remote)
+       if (!remote_is_configured(remote))
                die(_("No such remote: %s"), argv[1]);
 
        known_remotes.to_delete = remote;
@@ -774,7 +773,7 @@ static int rm(int argc, const char **argv)
                                strbuf_reset(&buf);
                                strbuf_addf(&buf, "branch.%s.%s",
                                                item->string, *k);
-                               git_config_set_or_die(buf.buf, NULL);
+                               git_config_set(buf.buf, NULL);
                        }
                }
        }
@@ -964,7 +963,9 @@ static int show_local_info_item(struct string_list_item *item, void *cb_data)
 
        printf("    %-*s ", show_info->width, item->string);
        if (branch_info->rebase) {
-               printf_ln(_("rebases onto remote %s"), merge->items[0].string);
+               printf_ln(_(branch_info->rebase == INTERACTIVE_REBASE ?
+                       "rebases interactively onto remote %s" :
+                       "rebases onto remote %s"), merge->items[0].string);
                return 0;
        } else if (show_info->any_rebase) {
                printf_ln(_(" merges with remote %s"), merge->items[0].string);
@@ -1393,7 +1394,7 @@ static int update(int argc, const char **argv)
 
 static int remove_all_fetch_refspecs(const char *remote, const char *key)
 {
-       return git_config_set_multivar(key, NULL, NULL, 1);
+       return git_config_set_multivar_gently(key, NULL, NULL, 1);
 }
 
 static void add_branches(struct remote *remote, const char **branches,
@@ -1417,9 +1418,9 @@ static int set_remote_branches(const char *remotename, const char **branches,
 
        strbuf_addf(&key, "remote.%s.fetch", remotename);
 
-       if (!remote_is_configured(remotename))
-               die(_("No such remote '%s'"), remotename);
        remote = remote_get(remotename);
+       if (!remote_is_configured(remote))
+               die(_("No such remote '%s'"), remotename);
 
        if (!add_mode && remove_all_fetch_refspecs(remotename, key.buf)) {
                strbuf_release(&key);
@@ -1471,9 +1472,9 @@ static int get_url(int argc, const char **argv)
 
        remotename = argv[0];
 
-       if (!remote_is_configured(remotename))
-               die(_("No such remote '%s'"), remotename);
        remote = remote_get(remotename);
+       if (!remote_is_configured(remote))
+               die(_("No such remote '%s'"), remotename);
 
        url_nr = 0;
        if (push_mode) {
@@ -1539,9 +1540,9 @@ static int set_url(int argc, const char **argv)
        if (delete_mode)
                oldurl = newurl;
 
-       if (!remote_is_configured(remotename))
-               die(_("No such remote '%s'"), remotename);
        remote = remote_get(remotename);
+       if (!remote_is_configured(remote))
+               die(_("No such remote '%s'"), remotename);
 
        if (push_mode) {
                strbuf_addf(&name_buf, "remote.%s.pushurl", remotename);
@@ -1556,10 +1557,10 @@ static int set_url(int argc, const char **argv)
        /* Special cases that add new entry. */
        if ((!oldurl && !delete_mode) || add_mode) {
                if (add_mode)
-                       git_config_set_multivar_or_die(name_buf.buf, newurl,
+                       git_config_set_multivar(name_buf.buf, newurl,
                                                       "^$", 0);
                else
-                       git_config_set_or_die(name_buf.buf, newurl);
+                       git_config_set(name_buf.buf, newurl);
                strbuf_release(&name_buf);
 
                return 0;
@@ -1582,9 +1583,9 @@ static int set_url(int argc, const char **argv)
        regfree(&old_regex);
 
        if (!delete_mode)
-               git_config_set_multivar_or_die(name_buf.buf, newurl, oldurl, 0);
+               git_config_set_multivar(name_buf.buf, newurl, oldurl, 0);
        else
-               git_config_set_multivar_or_die(name_buf.buf, NULL, oldurl, 1);
+               git_config_set_multivar(name_buf.buf, NULL, oldurl, 1);
        return 0;
 }