Code

git: browsing paths with spaces when using the start command
[git.git] / remote.c
index d12140e0fef5331188295da1f3190873ddc5bed8..2c3e9053a492e0029eb1f98a8d2c649564888197 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -366,7 +366,7 @@ static int handle_config(const char *key, const char *value, void *cb)
        }
        subkey = strrchr(name, '.');
        if (!subkey)
-               return error("Config with no key for remote %s", name);
+               return 0;
        remote = make_remote(name, subkey - name);
        remote->origin = REMOTE_CONFIG;
        if (!strcmp(subkey, ".mirror"))
@@ -667,6 +667,17 @@ struct remote *remote_get(const char *name)
        return ret;
 }
 
+int remote_is_configured(const char *name)
+{
+       int i;
+       read_config();
+
+       for (i = 0; i < remotes_nr; i++)
+               if (!strcmp(name, remotes[i]->name))
+                       return 1;
+       return 0;
+}
+
 int for_each_remote(each_remote_fn fn, void *priv)
 {
        int i, result = 0;
@@ -1388,13 +1399,13 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
        base = branch->merge[0]->dst;
        if (!resolve_ref(base, sha1, 1, NULL))
                return 0;
-       theirs = lookup_commit(sha1);
+       theirs = lookup_commit_reference(sha1);
        if (!theirs)
                return 0;
 
        if (!resolve_ref(branch->refname, sha1, 1, NULL))
                return 0;
-       ours = lookup_commit(sha1);
+       ours = lookup_commit_reference(sha1);
        if (!ours)
                return 0;
 
@@ -1402,10 +1413,9 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
        if (theirs == ours)
                return 0;
 
-       /* Run "rev-list --no-merges --left-right ours...theirs" internally... */
+       /* Run "rev-list --left-right ours...theirs" internally... */
        rev_argc = 0;
        rev_argv[rev_argc++] = NULL;
-       rev_argv[rev_argc++] = "--no-merges";
        rev_argv[rev_argc++] = "--left-right";
        rev_argv[rev_argc++] = symmetric;
        rev_argv[rev_argc++] = "--";
@@ -1450,11 +1460,7 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)
                return 0;
 
        base = branch->merge[0]->dst;
-       if (!prefixcmp(base, "refs/remotes/")) {
-               base += strlen("refs/remotes/");
-       } else if (!prefixcmp(base, "refs/heads/")) {
-               base += strlen("refs/heads/");
-       }
+       base = shorten_unambiguous_ref(base, 0);
        if (!num_theirs)
                strbuf_addf(sb, "Your branch is ahead of '%s' "
                            "by %d commit%s.\n",
@@ -1493,7 +1499,7 @@ static int one_local_ref(const char *refname, const unsigned char *sha1, int fla
 
 struct ref *get_local_heads(void)
 {
-       struct ref *local_refs, **local_tail = &local_refs;
+       struct ref *local_refs = NULL, **local_tail = &local_refs;
        for_each_ref(one_local_ref, &local_tail);
        return local_refs;
 }