diff options
| author | Junio C Hamano <gitster@pobox.com> | 2024-07-17 10:47:26 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-07-17 10:47:26 -0700 |
| commit | e13feda98f59cd34d8efce69b3db0cb16c4d3c3b (patch) | |
| tree | 1390777130994835724cfb3a5332a517a09f5bce /builtin/push.c | |
| parent | dd6d10285b91af584d0f9316467d870fa3d20c1d (diff) | |
| parent | 757c6ee7a3f6e1266bba0bf47545471c027c8340 (diff) | |
| download | git-e13feda98f59cd34d8efce69b3db0cb16c4d3c3b.tar.gz | |
Merge branch 'kn/push-empty-fix'
"git push '' HEAD:there" used to hit a BUG(); it has been corrected
to die with "fatal: bad repository ''".
* kn/push-empty-fix:
builtin/push: call set_refspecs after validating remote
Diffstat (limited to 'builtin/push.c')
| -rw-r--r-- | builtin/push.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/builtin/push.c b/builtin/push.c index 8260c6e46a..7a67398124 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -96,9 +96,8 @@ static void refspec_append_mapped(struct refspec *refspec, const char *ref, refspec_append(refspec, ref); } -static void set_refspecs(const char **refs, int nr, const char *repo) +static void set_refspecs(const char **refs, int nr, struct remote *remote) { - struct remote *remote = NULL; struct ref *local_refs = NULL; int i; @@ -124,17 +123,10 @@ static void set_refspecs(const char **refs, int nr, const char *repo) local_refs = get_local_heads(); /* Does "ref" uniquely name our ref? */ - if (count_refspec_match(ref, local_refs, &matched) != 1) { + if (count_refspec_match(ref, local_refs, &matched) != 1) refspec_append(&rs, ref); - } else { - /* lazily grab remote */ - if (!remote) - remote = remote_get(repo); - if (!remote) - BUG("must get a remote for repo '%s'", repo); - + else refspec_append_mapped(&rs, ref, remote, matched); - } } else refspec_append(&rs, ref); } @@ -630,10 +622,8 @@ int cmd_push(int argc, const char **argv, const char *prefix) if (tags) refspec_append(&rs, "refs/tags/*"); - if (argc > 0) { + if (argc > 0) repo = argv[0]; - set_refspecs(argv + 1, argc - 1, repo); - } remote = pushremote_get(repo); if (!remote) { @@ -649,6 +639,9 @@ int cmd_push(int argc, const char **argv, const char *prefix) " git push <name>\n")); } + if (argc > 0) + set_refspecs(argv + 1, argc - 1, remote); + if (remote->mirror) flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE); |
