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[] = {
|
2008-10-07 16:26:20 +02:00
|
|
|
"git push [--all | --mirror] [--dry-run] [--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);
|
|
|
|
}
|
|
|
|
|
2009-03-16 16:42:52 +01:00
|
|
|
static const char *warn_unconfigured_push_msg[] = {
|
|
|
|
"You did not specify any refspecs to push, and the current remote",
|
|
|
|
"has not configured any push refspecs. The default action in this",
|
|
|
|
"case is to push all matching refspecs, that is, all branches",
|
|
|
|
"that exist both locally and remotely will be updated. This may",
|
|
|
|
"not necessarily be what you want to happen.",
|
|
|
|
"",
|
|
|
|
"You can specify what action you want to take in this case, and",
|
|
|
|
"avoid seeing this message again, by configuring 'push.default' to:",
|
|
|
|
" 'nothing' : Do not push anythig",
|
|
|
|
" 'matching' : Push all matching branches (default)",
|
|
|
|
" 'tracking' : Push the current branch to whatever it is tracking",
|
|
|
|
" 'current' : Push the current branch"
|
|
|
|
};
|
|
|
|
|
|
|
|
static void warn_unconfigured_push(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(warn_unconfigured_push_msg); i++)
|
|
|
|
warning("%s", warn_unconfigured_push_msg[i]);
|
|
|
|
}
|
|
|
|
|
2009-03-16 16:42:51 +01:00
|
|
|
static void setup_default_push_refspecs(void)
|
|
|
|
{
|
|
|
|
git_config(git_default_config, NULL);
|
|
|
|
switch (push_default) {
|
|
|
|
case PUSH_DEFAULT_UNSPECIFIED:
|
2009-03-16 16:42:52 +01:00
|
|
|
warn_unconfigured_push();
|
2009-03-16 16:42:51 +01:00
|
|
|
/* fallthrough */
|
|
|
|
|
|
|
|
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);
|
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
|
|
|
if (!remote)
|
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
|
|
|
die("bad repository '%s'", repo);
|
|
|
|
|
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;
|
2007-09-19 06:49:27 +02:00
|
|
|
for (i = 0; i < remote->url_nr; i++) {
|
2007-09-11 05:03:04 +02:00
|
|
|
struct transport *transport =
|
2007-09-19 06:49:27 +02:00
|
|
|
transport_get(remote, remote->url[i]);
|
2006-08-23 12:39:10 +02:00
|
|
|
int err;
|
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)
|
2007-09-19 06:49:27 +02:00
|
|
|
fprintf(stderr, "Pushing to %s\n", remote->url[i]);
|
2007-09-11 05:03:04 +02:00
|
|
|
err = transport_push(transport, refspec_nr, refspec, flags);
|
|
|
|
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
|
|
|
|
2008-02-19 17:25:01 +01:00
|
|
|
error("failed to push some refs to '%s'", remote->url[i]);
|
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[] = {
|
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),
|
|
|
|
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
|
|
|
|
2007-11-05 04:35:37 +01:00
|
|
|
argc = parse_options(argc, argv, options, push_usage, 0);
|
|
|
|
|
|
|
|
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
|
|
|
}
|