git builtin "push"
This adds a builtin "push" command, which is largely just a C'ification of
the "git-push.sh" script.
Now, the reason I did it as a built-in is partly because it's yet another
step on relying less on shell, but it's actually mostly because I've
wanted to be able to push to _multiple_ repositories, and the most obvious
and simplest interface for that would seem be to just have a "remotes"
file that has multiple URL entries.
(For "pull", having multiple entries should either just select the first
one, or you could fall back on the others on failure - your choice).
And quite frankly, it just became too damn messy to do that in shell.
Besides, we actually have a fair amount of infrastructure in C, so it just
wasn't that hard to do.
Of course, this is almost totally untested. It probably doesn't work for
anything but the one trial I threw at it. "Simple" doesn't necessarily
mean "obviously correct".
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-30 06:22:49 +02:00
|
|
|
/*
|
|
|
|
* "git push"
|
|
|
|
*/
|
|
|
|
#include "cache.h"
|
|
|
|
#include "refs.h"
|
|
|
|
#include "run-command.h"
|
|
|
|
#include "builtin.h"
|
2007-05-12 17:45:53 +02:00
|
|
|
#include "remote.h"
|
2007-09-11 05:03:04 +02:00
|
|
|
#include "transport.h"
|
2007-11-05 04:35:37 +01:00
|
|
|
#include "parse-options.h"
|
git builtin "push"
This adds a builtin "push" command, which is largely just a C'ification of
the "git-push.sh" script.
Now, the reason I did it as a built-in is partly because it's yet another
step on relying less on shell, but it's actually mostly because I've
wanted to be able to push to _multiple_ repositories, and the most obvious
and simplest interface for that would seem be to just have a "remotes"
file that has multiple URL entries.
(For "pull", having multiple entries should either just select the first
one, or you could fall back on the others on failure - your choice).
And quite frankly, it just became too damn messy to do that in shell.
Besides, we actually have a fair amount of infrastructure in C, so it just
wasn't that hard to do.
Of course, this is almost totally untested. It probably doesn't work for
anything but the one trial I threw at it. "Simple" doesn't necessarily
mean "obviously correct".
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-30 06:22:49 +02:00
|
|
|
|
2007-11-05 04:35:37 +01:00
|
|
|
static const char * const push_usage[] = {
|
2009-06-23 03:10:01 +02:00
|
|
|
"git push [--all | --mirror] [--dry-run] [--porcelain] [--tags] [--receive-pack=<git-receive-pack>] [--repo=<repository>] [-f | --force] [-v] [<repository> <refspec>...]",
|
2007-11-05 04:35:37 +01:00
|
|
|
NULL,
|
|
|
|
};
|
git builtin "push"
This adds a builtin "push" command, which is largely just a C'ification of
the "git-push.sh" script.
Now, the reason I did it as a built-in is partly because it's yet another
step on relying less on shell, but it's actually mostly because I've
wanted to be able to push to _multiple_ repositories, and the most obvious
and simplest interface for that would seem be to just have a "remotes"
file that has multiple URL entries.
(For "pull", having multiple entries should either just select the first
one, or you could fall back on the others on failure - your choice).
And quite frankly, it just became too damn messy to do that in shell.
Besides, we actually have a fair amount of infrastructure in C, so it just
wasn't that hard to do.
Of course, this is almost totally untested. It probably doesn't work for
anything but the one trial I threw at it. "Simple" doesn't necessarily
mean "obviously correct".
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-30 06:22:49 +02:00
|
|
|
|
2008-07-20 14:02:20 +02:00
|
|
|
static int thin;
|
2007-01-19 13:49:27 +01:00
|
|
|
static const char *receivepack;
|
git builtin "push"
This adds a builtin "push" command, which is largely just a C'ification of
the "git-push.sh" script.
Now, the reason I did it as a built-in is partly because it's yet another
step on relying less on shell, but it's actually mostly because I've
wanted to be able to push to _multiple_ repositories, and the most obvious
and simplest interface for that would seem be to just have a "remotes"
file that has multiple URL entries.
(For "pull", having multiple entries should either just select the first
one, or you could fall back on the others on failure - your choice).
And quite frankly, it just became too damn messy to do that in shell.
Besides, we actually have a fair amount of infrastructure in C, so it just
wasn't that hard to do.
Of course, this is almost totally untested. It probably doesn't work for
anything but the one trial I threw at it. "Simple" doesn't necessarily
mean "obviously correct".
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-30 06:22:49 +02:00
|
|
|
|
2006-08-15 19:23:48 +02:00
|
|
|
static const char **refspec;
|
|
|
|
static int refspec_nr;
|
git builtin "push"
This adds a builtin "push" command, which is largely just a C'ification of
the "git-push.sh" script.
Now, the reason I did it as a built-in is partly because it's yet another
step on relying less on shell, but it's actually mostly because I've
wanted to be able to push to _multiple_ repositories, and the most obvious
and simplest interface for that would seem be to just have a "remotes"
file that has multiple URL entries.
(For "pull", having multiple entries should either just select the first
one, or you could fall back on the others on failure - your choice).
And quite frankly, it just became too damn messy to do that in shell.
Besides, we actually have a fair amount of infrastructure in C, so it just
wasn't that hard to do.
Of course, this is almost totally untested. It probably doesn't work for
anything but the one trial I threw at it. "Simple" doesn't necessarily
mean "obviously correct".
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-30 06:22:49 +02:00
|
|
|
|
|
|
|
static void add_refspec(const char *ref)
|
|
|
|
{
|
|
|
|
int nr = refspec_nr + 1;
|
|
|
|
refspec = xrealloc(refspec, nr * sizeof(char *));
|
|
|
|
refspec[nr-1] = ref;
|
|
|
|
refspec_nr = nr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set_refspecs(const char **refs, int nr)
|
|
|
|
{
|
2007-05-25 07:20:56 +02:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < nr; i++) {
|
|
|
|
const char *ref = refs[i];
|
|
|
|
if (!strcmp("tag", ref)) {
|
|
|
|
char *tag;
|
|
|
|
int len;
|
|
|
|
if (nr <= ++i)
|
|
|
|
die("tag shorthand without <tag>");
|
|
|
|
len = strlen(refs[i]) + 11;
|
|
|
|
tag = xmalloc(len);
|
|
|
|
strcpy(tag, "refs/tags/");
|
|
|
|
strcat(tag, refs[i]);
|
|
|
|
ref = tag;
|
2006-12-13 19:03:39 +01:00
|
|
|
}
|
2007-05-25 07:20:56 +02:00
|
|
|
add_refspec(ref);
|
git builtin "push"
This adds a builtin "push" command, which is largely just a C'ification of
the "git-push.sh" script.
Now, the reason I did it as a built-in is partly because it's yet another
step on relying less on shell, but it's actually mostly because I've
wanted to be able to push to _multiple_ repositories, and the most obvious
and simplest interface for that would seem be to just have a "remotes"
file that has multiple URL entries.
(For "pull", having multiple entries should either just select the first
one, or you could fall back on the others on failure - your choice).
And quite frankly, it just became too damn messy to do that in shell.
Besides, we actually have a fair amount of infrastructure in C, so it just
wasn't that hard to do.
Of course, this is almost totally untested. It probably doesn't work for
anything but the one trial I threw at it. "Simple" doesn't necessarily
mean "obviously correct".
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-30 06:22:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-16 16:42:51 +01:00
|
|
|
static void setup_push_tracking(void)
|
|
|
|
{
|
|
|
|
struct strbuf refspec = STRBUF_INIT;
|
|
|
|
struct branch *branch = branch_get(NULL);
|
|
|
|
if (!branch)
|
|
|
|
die("You are not currently on a branch.");
|
|
|
|
if (!branch->merge_nr)
|
|
|
|
die("The current branch %s is not tracking anything.",
|
|
|
|
branch->name);
|
|
|
|
if (branch->merge_nr != 1)
|
|
|
|
die("The current branch %s is tracking multiple branches, "
|
|
|
|
"refusing to push.", branch->name);
|
|
|
|
strbuf_addf(&refspec, "%s:%s", branch->name, branch->merge[0]->src);
|
|
|
|
add_refspec(refspec.buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setup_default_push_refspecs(void)
|
|
|
|
{
|
|
|
|
git_config(git_default_config, NULL);
|
|
|
|
switch (push_default) {
|
2009-07-19 02:19:47 +02:00
|
|
|
default:
|
2009-03-16 16:42:51 +01:00
|
|
|
case PUSH_DEFAULT_MATCHING:
|
|
|
|
add_refspec(":");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PUSH_DEFAULT_TRACKING:
|
|
|
|
setup_push_tracking();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PUSH_DEFAULT_CURRENT:
|
|
|
|
add_refspec("HEAD");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PUSH_DEFAULT_NOTHING:
|
|
|
|
die("You didn't specify any refspecs to push, and "
|
|
|
|
"push.default is \"nothing\".");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-11 05:03:04 +02:00
|
|
|
static int do_push(const char *repo, int flags)
|
git builtin "push"
This adds a builtin "push" command, which is largely just a C'ification of
the "git-push.sh" script.
Now, the reason I did it as a built-in is partly because it's yet another
step on relying less on shell, but it's actually mostly because I've
wanted to be able to push to _multiple_ repositories, and the most obvious
and simplest interface for that would seem be to just have a "remotes"
file that has multiple URL entries.
(For "pull", having multiple entries should either just select the first
one, or you could fall back on the others on failure - your choice).
And quite frankly, it just became too damn messy to do that in shell.
Besides, we actually have a fair amount of infrastructure in C, so it just
wasn't that hard to do.
Of course, this is almost totally untested. It probably doesn't work for
anything but the one trial I threw at it. "Simple" doesn't necessarily
mean "obviously correct".
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-30 06:22:49 +02:00
|
|
|
{
|
2007-05-12 17:45:53 +02:00
|
|
|
int i, errs;
|
|
|
|
struct remote *remote = remote_get(repo);
|
2009-06-09 18:01:34 +02:00
|
|
|
const char **url;
|
|
|
|
int url_nr;
|
git builtin "push"
This adds a builtin "push" command, which is largely just a C'ification of
the "git-push.sh" script.
Now, the reason I did it as a built-in is partly because it's yet another
step on relying less on shell, but it's actually mostly because I've
wanted to be able to push to _multiple_ repositories, and the most obvious
and simplest interface for that would seem be to just have a "remotes"
file that has multiple URL entries.
(For "pull", having multiple entries should either just select the first
one, or you could fall back on the others on failure - your choice).
And quite frankly, it just became too damn messy to do that in shell.
Besides, we actually have a fair amount of infrastructure in C, so it just
wasn't that hard to do.
Of course, this is almost totally untested. It probably doesn't work for
anything but the one trial I threw at it. "Simple" doesn't necessarily
mean "obviously correct".
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-30 06:22:49 +02:00
|
|
|
|
Give error when no remote is configured
When there's no explicitly-named remote, we use the remote specified
for the current branch, which in turn defaults to "origin". But it
this case should require the remote to actually be configured, and not
fall back to the path "origin".
Possibly, the config file's "remote = something" should require the
something to be a configured remote instead of a bare repository URL,
but we actually test with a bare repository URL.
In fetch, we were giving the sensible error message when coming up
with a URL failed, but this wasn't actually reachable, so move that
error up and use it when appropriate.
In push, we need a new error message, because the old one (formerly
unreachable without a lot of help) used the repo name, which was NULL.
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-03-11 06:47:20 +01:00
|
|
|
if (!remote) {
|
|
|
|
if (repo)
|
|
|
|
die("bad repository '%s'", repo);
|
|
|
|
die("No destination configured to push to.");
|
|
|
|
}
|
git builtin "push"
This adds a builtin "push" command, which is largely just a C'ification of
the "git-push.sh" script.
Now, the reason I did it as a built-in is partly because it's yet another
step on relying less on shell, but it's actually mostly because I've
wanted to be able to push to _multiple_ repositories, and the most obvious
and simplest interface for that would seem be to just have a "remotes"
file that has multiple URL entries.
(For "pull", having multiple entries should either just select the first
one, or you could fall back on the others on failure - your choice).
And quite frankly, it just became too damn messy to do that in shell.
Besides, we actually have a fair amount of infrastructure in C, so it just
wasn't that hard to do.
Of course, this is almost totally untested. It probably doesn't work for
anything but the one trial I threw at it. "Simple" doesn't necessarily
mean "obviously correct".
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-30 06:22:49 +02:00
|
|
|
|
2008-04-17 13:17:20 +02:00
|
|
|
if (remote->mirror)
|
|
|
|
flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
|
|
|
|
|
2008-08-16 19:58:32 +02:00
|
|
|
if ((flags & TRANSPORT_PUSH_ALL) && refspec) {
|
|
|
|
if (!strcmp(*refspec, "refs/tags/*"))
|
|
|
|
return error("--all and --tags are incompatible");
|
|
|
|
return error("--all can't be combined with refspecs");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((flags & TRANSPORT_PUSH_MIRROR) && refspec) {
|
|
|
|
if (!strcmp(*refspec, "refs/tags/*"))
|
|
|
|
return error("--mirror and --tags are incompatible");
|
|
|
|
return error("--mirror can't be combined with refspecs");
|
|
|
|
}
|
2008-04-17 13:17:20 +02:00
|
|
|
|
|
|
|
if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) ==
|
|
|
|
(TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) {
|
|
|
|
return error("--all and --mirror are incompatible");
|
|
|
|
}
|
|
|
|
|
2009-03-16 16:42:51 +01:00
|
|
|
if (!refspec && !(flags & TRANSPORT_PUSH_ALL)) {
|
|
|
|
if (remote->push_refspec_nr) {
|
|
|
|
refspec = remote->push_refspec;
|
|
|
|
refspec_nr = remote->push_refspec_nr;
|
|
|
|
} else if (!(flags & TRANSPORT_PUSH_MIRROR))
|
|
|
|
setup_default_push_refspecs();
|
2007-05-12 17:45:53 +02:00
|
|
|
}
|
2007-04-07 08:04:53 +02:00
|
|
|
errs = 0;
|
2009-06-09 18:01:34 +02:00
|
|
|
if (remote->pushurl_nr) {
|
|
|
|
url = remote->pushurl;
|
|
|
|
url_nr = remote->pushurl_nr;
|
|
|
|
} else {
|
|
|
|
url = remote->url;
|
|
|
|
url_nr = remote->url_nr;
|
|
|
|
}
|
|
|
|
for (i = 0; i < url_nr; i++) {
|
2007-09-11 05:03:04 +02:00
|
|
|
struct transport *transport =
|
2009-06-09 18:01:34 +02:00
|
|
|
transport_get(remote, url[i]);
|
2006-08-23 12:39:10 +02:00
|
|
|
int err;
|
2009-08-08 09:51:08 +02:00
|
|
|
int nonfastforward;
|
2007-09-11 05:03:04 +02:00
|
|
|
if (receivepack)
|
|
|
|
transport_set_option(transport,
|
|
|
|
TRANS_OPT_RECEIVEPACK, receivepack);
|
|
|
|
if (thin)
|
|
|
|
transport_set_option(transport, TRANS_OPT_THIN, "yes");
|
|
|
|
|
2008-07-20 14:02:20 +02:00
|
|
|
if (flags & TRANSPORT_PUSH_VERBOSE)
|
2009-06-09 18:01:34 +02:00
|
|
|
fprintf(stderr, "Pushing to %s\n", url[i]);
|
2009-08-08 09:51:08 +02:00
|
|
|
err = transport_push(transport, refspec_nr, refspec, flags,
|
|
|
|
&nonfastforward);
|
2007-09-11 05:03:04 +02:00
|
|
|
err |= transport_disconnect(transport);
|
|
|
|
|
2006-08-23 12:39:10 +02:00
|
|
|
if (!err)
|
git builtin "push"
This adds a builtin "push" command, which is largely just a C'ification of
the "git-push.sh" script.
Now, the reason I did it as a built-in is partly because it's yet another
step on relying less on shell, but it's actually mostly because I've
wanted to be able to push to _multiple_ repositories, and the most obvious
and simplest interface for that would seem be to just have a "remotes"
file that has multiple URL entries.
(For "pull", having multiple entries should either just select the first
one, or you could fall back on the others on failure - your choice).
And quite frankly, it just became too damn messy to do that in shell.
Besides, we actually have a fair amount of infrastructure in C, so it just
wasn't that hard to do.
Of course, this is almost totally untested. It probably doesn't work for
anything but the one trial I threw at it. "Simple" doesn't necessarily
mean "obviously correct".
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-30 06:22:49 +02:00
|
|
|
continue;
|
2007-04-07 08:04:55 +02:00
|
|
|
|
2009-06-09 18:01:34 +02:00
|
|
|
error("failed to push some refs to '%s'", url[i]);
|
2009-08-08 09:51:08 +02:00
|
|
|
if (nonfastforward) {
|
2009-09-06 08:47:20 +02:00
|
|
|
printf("To prevent you from losing history, non-fast-forward updates were rejected\n"
|
|
|
|
"Merge the remote changes before pushing again. See the 'non-fast forward'\n"
|
|
|
|
"section of 'git push --help' for details.\n");
|
2009-08-08 09:51:08 +02:00
|
|
|
}
|
2007-04-07 08:04:53 +02:00
|
|
|
errs++;
|
git builtin "push"
This adds a builtin "push" command, which is largely just a C'ification of
the "git-push.sh" script.
Now, the reason I did it as a built-in is partly because it's yet another
step on relying less on shell, but it's actually mostly because I've
wanted to be able to push to _multiple_ repositories, and the most obvious
and simplest interface for that would seem be to just have a "remotes"
file that has multiple URL entries.
(For "pull", having multiple entries should either just select the first
one, or you could fall back on the others on failure - your choice).
And quite frankly, it just became too damn messy to do that in shell.
Besides, we actually have a fair amount of infrastructure in C, so it just
wasn't that hard to do.
Of course, this is almost totally untested. It probably doesn't work for
anything but the one trial I threw at it. "Simple" doesn't necessarily
mean "obviously correct".
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-30 06:22:49 +02:00
|
|
|
}
|
2007-04-07 08:04:53 +02:00
|
|
|
return !!errs;
|
git builtin "push"
This adds a builtin "push" command, which is largely just a C'ification of
the "git-push.sh" script.
Now, the reason I did it as a built-in is partly because it's yet another
step on relying less on shell, but it's actually mostly because I've
wanted to be able to push to _multiple_ repositories, and the most obvious
and simplest interface for that would seem be to just have a "remotes"
file that has multiple URL entries.
(For "pull", having multiple entries should either just select the first
one, or you could fall back on the others on failure - your choice).
And quite frankly, it just became too damn messy to do that in shell.
Besides, we actually have a fair amount of infrastructure in C, so it just
wasn't that hard to do.
Of course, this is almost totally untested. It probably doesn't work for
anything but the one trial I threw at it. "Simple" doesn't necessarily
mean "obviously correct".
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-30 06:22:49 +02:00
|
|
|
}
|
|
|
|
|
2006-07-29 07:44:25 +02:00
|
|
|
int cmd_push(int argc, const char **argv, const char *prefix)
|
git builtin "push"
This adds a builtin "push" command, which is largely just a C'ification of
the "git-push.sh" script.
Now, the reason I did it as a built-in is partly because it's yet another
step on relying less on shell, but it's actually mostly because I've
wanted to be able to push to _multiple_ repositories, and the most obvious
and simplest interface for that would seem be to just have a "remotes"
file that has multiple URL entries.
(For "pull", having multiple entries should either just select the first
one, or you could fall back on the others on failure - your choice).
And quite frankly, it just became too damn messy to do that in shell.
Besides, we actually have a fair amount of infrastructure in C, so it just
wasn't that hard to do.
Of course, this is almost totally untested. It probably doesn't work for
anything but the one trial I threw at it. "Simple" doesn't necessarily
mean "obviously correct".
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-30 06:22:49 +02:00
|
|
|
{
|
2007-09-11 05:03:04 +02:00
|
|
|
int flags = 0;
|
2007-11-05 04:35:37 +01:00
|
|
|
int tags = 0;
|
2008-04-17 13:17:20 +02:00
|
|
|
int rc;
|
2007-05-12 17:45:53 +02:00
|
|
|
const char *repo = NULL; /* default repository */
|
git builtin "push"
This adds a builtin "push" command, which is largely just a C'ification of
the "git-push.sh" script.
Now, the reason I did it as a built-in is partly because it's yet another
step on relying less on shell, but it's actually mostly because I've
wanted to be able to push to _multiple_ repositories, and the most obvious
and simplest interface for that would seem be to just have a "remotes"
file that has multiple URL entries.
(For "pull", having multiple entries should either just select the first
one, or you could fall back on the others on failure - your choice).
And quite frankly, it just became too damn messy to do that in shell.
Besides, we actually have a fair amount of infrastructure in C, so it just
wasn't that hard to do.
Of course, this is almost totally untested. It probably doesn't work for
anything but the one trial I threw at it. "Simple" doesn't necessarily
mean "obviously correct".
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-30 06:22:49 +02:00
|
|
|
|
2007-11-05 04:35:37 +01:00
|
|
|
struct option options[] = {
|
2009-08-05 22:22:19 +02:00
|
|
|
OPT_BIT('q', "quiet", &flags, "be quiet", TRANSPORT_PUSH_QUIET),
|
2008-07-20 14:02:20 +02:00
|
|
|
OPT_BIT('v', "verbose", &flags, "be verbose", TRANSPORT_PUSH_VERBOSE),
|
2007-11-05 04:35:37 +01:00
|
|
|
OPT_STRING( 0 , "repo", &repo, "repository", "repository"),
|
2008-07-20 14:02:20 +02:00
|
|
|
OPT_BIT( 0 , "all", &flags, "push all refs", TRANSPORT_PUSH_ALL),
|
|
|
|
OPT_BIT( 0 , "mirror", &flags, "mirror all refs",
|
|
|
|
(TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE)),
|
2007-11-05 04:35:37 +01:00
|
|
|
OPT_BOOLEAN( 0 , "tags", &tags, "push tags"),
|
2008-07-20 14:02:20 +02:00
|
|
|
OPT_BIT( 0 , "dry-run", &flags, "dry run", TRANSPORT_PUSH_DRY_RUN),
|
2009-06-23 03:10:01 +02:00
|
|
|
OPT_BIT( 0, "porcelain", &flags, "machine-readable output", TRANSPORT_PUSH_PORCELAIN),
|
2008-07-20 14:02:20 +02:00
|
|
|
OPT_BIT('f', "force", &flags, "force updates", TRANSPORT_PUSH_FORCE),
|
2007-11-05 04:35:37 +01:00
|
|
|
OPT_BOOLEAN( 0 , "thin", &thin, "use thin pack"),
|
|
|
|
OPT_STRING( 0 , "receive-pack", &receivepack, "receive-pack", "receive pack program"),
|
|
|
|
OPT_STRING( 0 , "exec", &receivepack, "receive-pack", "receive pack program"),
|
|
|
|
OPT_END()
|
|
|
|
};
|
git builtin "push"
This adds a builtin "push" command, which is largely just a C'ification of
the "git-push.sh" script.
Now, the reason I did it as a built-in is partly because it's yet another
step on relying less on shell, but it's actually mostly because I've
wanted to be able to push to _multiple_ repositories, and the most obvious
and simplest interface for that would seem be to just have a "remotes"
file that has multiple URL entries.
(For "pull", having multiple entries should either just select the first
one, or you could fall back on the others on failure - your choice).
And quite frankly, it just became too damn messy to do that in shell.
Besides, we actually have a fair amount of infrastructure in C, so it just
wasn't that hard to do.
Of course, this is almost totally untested. It probably doesn't work for
anything but the one trial I threw at it. "Simple" doesn't necessarily
mean "obviously correct".
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-30 06:22:49 +02:00
|
|
|
|
2009-05-23 20:53:12 +02:00
|
|
|
argc = parse_options(argc, argv, prefix, options, push_usage, 0);
|
2007-11-05 04:35:37 +01:00
|
|
|
|
|
|
|
if (tags)
|
|
|
|
add_refspec("refs/tags/*");
|
|
|
|
|
|
|
|
if (argc > 0) {
|
|
|
|
repo = argv[0];
|
|
|
|
set_refspecs(argv + 1, argc - 1);
|
git builtin "push"
This adds a builtin "push" command, which is largely just a C'ification of
the "git-push.sh" script.
Now, the reason I did it as a built-in is partly because it's yet another
step on relying less on shell, but it's actually mostly because I've
wanted to be able to push to _multiple_ repositories, and the most obvious
and simplest interface for that would seem be to just have a "remotes"
file that has multiple URL entries.
(For "pull", having multiple entries should either just select the first
one, or you could fall back on the others on failure - your choice).
And quite frankly, it just became too damn messy to do that in shell.
Besides, we actually have a fair amount of infrastructure in C, so it just
wasn't that hard to do.
Of course, this is almost totally untested. It probably doesn't work for
anything but the one trial I threw at it. "Simple" doesn't necessarily
mean "obviously correct".
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-30 06:22:49 +02:00
|
|
|
}
|
2007-05-25 07:20:56 +02:00
|
|
|
|
2008-04-17 13:17:20 +02:00
|
|
|
rc = do_push(repo, flags);
|
|
|
|
if (rc == -1)
|
2007-11-10 00:32:25 +01:00
|
|
|
usage_with_options(push_usage, options);
|
2008-04-17 13:17:20 +02:00
|
|
|
else
|
|
|
|
return rc;
|
git builtin "push"
This adds a builtin "push" command, which is largely just a C'ification of
the "git-push.sh" script.
Now, the reason I did it as a built-in is partly because it's yet another
step on relying less on shell, but it's actually mostly because I've
wanted to be able to push to _multiple_ repositories, and the most obvious
and simplest interface for that would seem be to just have a "remotes"
file that has multiple URL entries.
(For "pull", having multiple entries should either just select the first
one, or you could fall back on the others on failure - your choice).
And quite frankly, it just became too damn messy to do that in shell.
Besides, we actually have a fair amount of infrastructure in C, so it just
wasn't that hard to do.
Of course, this is almost totally untested. It probably doesn't work for
anything but the one trial I threw at it. "Simple" doesn't necessarily
mean "obviously correct".
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-30 06:22:49 +02:00
|
|
|
}
|