graph: add support for --line-prefix on all graph-aware output
[gitweb.git] / builtin / submodule--helper.c
index 9be2c75e0e330c45e3d2092f102c0b09c10e7e2c..b09632e468e6b64e0329a685e0f3ba7517884c5c 100644 (file)
@@ -795,7 +795,7 @@ static int update_clone_task_finished(int result,
                suc->failed_clones[suc->failed_clones_nr++] = ce;
                return 0;
        } else {
-               idx = suc->current - suc->list.nr;
+               idx -= suc->list.nr;
                ce  = suc->failed_clones[idx];
                strbuf_addf(err, _("Failed to clone '%s' a second time, aborting"),
                            ce->name);
@@ -912,6 +912,24 @@ static const char *remote_submodule_branch(const char *path)
        if (!sub->branch)
                return "master";
 
+       if (!strcmp(sub->branch, ".")) {
+               unsigned char sha1[20];
+               const char *refname = resolve_ref_unsafe("HEAD", 0, sha1, NULL);
+
+               if (!refname)
+                       die(_("No such ref: %s"), "HEAD");
+
+               /* detached HEAD */
+               if (!strcmp(refname, "HEAD"))
+                       die(_("Submodule (%s) branch configured to inherit "
+                             "branch from superproject, but the superproject "
+                             "is not on any branch"), sub->name);
+
+               if (!skip_prefix(refname, "refs/heads/", &refname))
+                       die(_("Expecting a full ref name, got %s"), refname);
+               return refname;
+       }
+
        return sub->branch;
 }