const char *str;
struct strvec prefixes;
struct object_id oid;
+ char *refname;
int refs_found;
};
if (!ends_with(refname, "/head"))
return 0;
- if (!data->refs_found++)
+ switch (data->refs_found++) {
+ case 0:
oidcpy(&data->oid, oid);
+ data->refname = xstrdup(refname);
+ break;
+ case 1:
+ error(_("found '%s' for '%s'"), data->refname, data->str);
+ /* fallthrough */
+ default:
+ error(_("found '%s' for '%s'"), refname, data->str);
+ }
return 0;
}
for_each_remote(remote_ref_cb, &data);
for_each_fullref_in_prefixes(NULL, data.prefixes.v, expand_ref_cb,
&data);
+ free(data.refname);
strvec_clear(&data.prefixes);
if (!data.refs_found)
return NULL;
- if (data.refs_found > 1) {
- warning(_("ambiguous mrid '%s'"), str);
- return NULL;
- }
+ if (data.refs_found > 1)
+ die(_("ambiguous mrid '%s'"), str);
return lookup_commit_reference(the_repository, &data.oid);
}
int cmd_create(int argc, const char **argv, const char *prefix);
int cmd_list(int argc, const char **argv, const char *prefix);
-int cmd_push(int argc, const char **argv, const char *prefix);
+int cmd_upload(int argc, const char **argv, const char *prefix);
#endif
#include "gimrr.h"
-#define HAS_LOCAL_REFS 1
-
#define UPLOAD_HEAD (1<<1)
#define UPLOAD_TAGS (1<<2)
#define UPLOAD_MBOX (1<<3)
ref_tail = &local_ref->ref;
for_each_string_list_item(item, &mrids) {
- struct ref **ref_tail_orig = ref_tail;
strbuf_reset(&ref_prefix);
strbuf_addf(&ref_prefix, "refs/mrs/local/%s/%s/",
remote->name, item->string);
for_each_fullref_in(ref_prefix.buf, get_mr_refs, &ref_tail);
- /* no new refs added for remote */
- if (ref_tail_orig == ref_tail)
- continue;
- if (item->util)
- warning(_("mr '%s' in different remotes"), item->string);
- item->util = (void *)HAS_LOCAL_REFS;
+ }
+
+ if (!mrids.nr) {
+ strbuf_reset(&ref_prefix);
+ strbuf_addf(&ref_prefix, "refs/mrs/local/%s/", remote->name);
+ for_each_fullref_in(ref_prefix.buf, get_mr_refs, &ref_tail);
}
strbuf_release(&ref_prefix);
{
struct ref *ref = local_refs;
+ if (!ref) {
+ strvec_push(names, "refs/mrs/");
+ return;
+ }
+
while (ref) {
- strvec_pushf(names, "refs/mrs/%s", local_ref_suffix(ref->name));
+ strvec_pushf(names, "refs/mrs/%s/", local_ref_suffix(ref->name));
ref = ref->next;
}
}
err += transport_disconnect(t);
done:
if (err)
- error(_("failed to upload some refs to remote '%s' "
+ error(_("Failed to upload some refs to remote '%s' "
"with url '%s'"), remote->name, anon_url);
free_refs(remote_refs);
for_each_remote(get_local_refs, NULL);
for (i = 0; i < local_refs_nr; ++i) {
+ if (!local_refs[i].ref) {
+ if (!quiet)
+ fprintf(stderr, "Nothing new to upload for '%s'\n",
+ local_refs[i].remote->name);
+ continue;
+ }
+
rv += upload_local_refs(local_refs[i].remote, local_refs[i].ref);
}