* [PATCH 1/2] mirror pushing
2007-11-08 12:11 git push mirror mode Andy Whitcroft
@ 2007-11-08 12:12 ` Andy Whitcroft
2007-11-08 12:12 ` [PATCH 2/2] git-push: plumb in --mirror mode Andy Whitcroft
` (4 subsequent siblings)
5 siblings, 0 replies; 23+ messages in thread
From: Andy Whitcroft @ 2007-11-08 12:12 UTC (permalink / raw)
To: git
Existing "git push --all" is almost perfect for backing up to
another repository, except that "--all" only means "all
branches" in modern git, and it does not delete old branches and
tags that exist at the back-up repository that you have removed
from your local repository.
This teaches "git-send-pack" a new "--mirror" option. The
difference from the "--all" option are that (1) it sends all
refs, not just branches, and (2) it deletes old refs you no
longer have on the local side from the remote side.
[apw@shadowen.org: rebase to next post arguments update]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
---
builtin-send-pack.c | 40 ++++++++++++++++++++++++++++------------
remote.c | 15 ++++++++++-----
send-pack.h | 1 +
3 files changed, 39 insertions(+), 17 deletions(-)
diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index 5a0f5c6..d5ead97 100644
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
@@ -8,7 +8,7 @@
#include "send-pack.h"
static const char send_pack_usage[] =
-"git-send-pack [--all] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n"
+"git-send-pack [--all | --mirror] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n"
" --all and explicit <ref> specification are mutually exclusive.";
static struct send_pack_args args = {
@@ -242,7 +242,7 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
if (!remote_tail)
remote_tail = &remote_refs;
if (match_refs(local_refs, remote_refs, &remote_tail,
- nr_refspec, refspec, args.send_all))
+ nr_refspec, refspec, args.send_all | (args.send_mirror << 1)))
return -1;
if (!remote_refs) {
@@ -259,20 +259,28 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
char old_hex[60], *new_hex;
int will_delete_ref;
const char *pretty_ref;
- const char *pretty_peer;
+ const char *pretty_peer = NULL; /* only used when not deleting */
+ const unsigned char *new_sha1;
- if (!ref->peer_ref)
- continue;
+ if (!ref->peer_ref) {
+ if (!args.send_mirror)
+ continue;
+ new_sha1 = null_sha1;
+ }
+ else
+ new_sha1 = ref->peer_ref->new_sha1;
if (!shown_dest) {
fprintf(stderr, "To %s\n", dest);
shown_dest = 1;
}
+ will_delete_ref = is_null_sha1(new_sha1);
+
pretty_ref = prettify_ref(ref->name);
- pretty_peer = prettify_ref(ref->peer_ref->name);
+ if (!will_delete_ref)
+ pretty_peer = prettify_ref(ref->peer_ref->name);
- will_delete_ref = is_null_sha1(ref->peer_ref->new_sha1);
if (will_delete_ref && !allow_deleting_refs) {
fprintf(stderr, " ! %-*s %s (remote does not support deleting refs)\n",
SUMMARY_WIDTH, "[rejected]", pretty_ref);
@@ -280,7 +288,7 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
continue;
}
if (!will_delete_ref &&
- !hashcmp(ref->old_sha1, ref->peer_ref->new_sha1)) {
+ !hashcmp(ref->old_sha1, new_sha1)) {
if (args.verbose)
fprintf(stderr, " = %-*s %s -> %s\n",
SUMMARY_WIDTH, "[up to date]",
@@ -312,8 +320,7 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
!is_null_sha1(ref->old_sha1) &&
!ref->force) {
if (!has_sha1_file(ref->old_sha1) ||
- !ref_newer(ref->peer_ref->new_sha1,
- ref->old_sha1)) {
+ !ref_newer(new_sha1, ref->old_sha1)) {
/* We do not have the remote ref, or
* we know that the remote ref is not
* an ancestor of what we are trying to
@@ -328,7 +335,7 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
continue;
}
}
- hashcpy(ref->new_sha1, ref->peer_ref->new_sha1);
+ hashcpy(ref->new_sha1, new_sha1);
if (!will_delete_ref)
new_refs++;
strcpy(old_hex, sha1_to_hex(ref->old_sha1));
@@ -459,6 +466,10 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
args.dry_run = 1;
continue;
}
+ if (!strcmp(arg, "--mirror")) {
+ args.send_mirror = 1;
+ continue;
+ }
if (!strcmp(arg, "--force")) {
args.force_update = 1;
continue;
@@ -483,7 +494,12 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
}
if (!dest)
usage(send_pack_usage);
- if (heads && args.send_all)
+ /*
+ * --all and --mirror are incompatible; neither makes sense
+ * with any refspecs.
+ */
+ if ((heads && (args.send_all || args.send_mirror)) ||
+ (args.send_all && args.send_mirror))
usage(send_pack_usage);
if (remote_name) {
diff --git a/remote.c b/remote.c
index 59defdb..45dd59b 100644
--- a/remote.c
+++ b/remote.c
@@ -722,10 +722,12 @@ static const struct refspec *check_pattern_match(const struct refspec *rs,
* without thinking.
*/
int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
- int nr_refspec, const char **refspec, int all)
+ int nr_refspec, const char **refspec, int flags)
{
struct refspec *rs =
parse_ref_spec(nr_refspec, (const char **) refspec);
+ int send_all = flags & 01;
+ int send_mirror = flags & 02;
if (match_explicit_refs(src, dst, dst_tail, rs, nr_refspec))
return -1;
@@ -742,7 +744,7 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
if (!pat)
continue;
}
- else if (prefixcmp(src->name, "refs/heads/"))
+ else if (!send_mirror && prefixcmp(src->name, "refs/heads/"))
/*
* "matching refs"; traditionally we pushed everything
* including refs outside refs/heads/ hierarchy, but
@@ -763,10 +765,13 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
if (dst_peer && dst_peer->peer_ref)
/* We're already sending something to this ref. */
goto free_name;
- if (!dst_peer && !nr_refspec && !all)
- /* Remote doesn't have it, and we have no
+
+ if (!dst_peer && !nr_refspec && !(send_all || send_mirror))
+ /*
+ * Remote doesn't have it, and we have no
* explicit pattern, and we don't have
- * --all. */
+ * --all nor --mirror.
+ */
goto free_name;
if (!dst_peer) {
/* Create a new one and link it */
diff --git a/send-pack.h b/send-pack.h
index 7a24f71..8ff1dc3 100644
--- a/send-pack.h
+++ b/send-pack.h
@@ -5,6 +5,7 @@ struct send_pack_args {
const char *receivepack;
unsigned verbose:1,
send_all:1,
+ send_mirror:1,
force_update:1,
use_thin_pack:1,
dry_run:1;
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 2/2] git-push: plumb in --mirror mode
2007-11-08 12:11 git push mirror mode Andy Whitcroft
2007-11-08 12:12 ` [PATCH 1/2] mirror pushing Andy Whitcroft
@ 2007-11-08 12:12 ` Andy Whitcroft
2007-11-08 12:19 ` git push mirror mode Johannes Schindelin
` (3 subsequent siblings)
5 siblings, 0 replies; 23+ messages in thread
From: Andy Whitcroft @ 2007-11-08 12:12 UTC (permalink / raw)
To: git
Plumb in the --mirror mode for git-push.
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
---
builtin-push.c | 14 ++++++++++++--
transport.c | 7 +++++++
transport.h | 1 +
3 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/builtin-push.c b/builtin-push.c
index 2c56195..d49157c 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -10,7 +10,7 @@
#include "parse-options.h"
static const char * const push_usage[] = {
- "git-push [--all] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>] [--repo=all] [-f | --force] [-v] [<repository> <refspec>...]",
+ "git-push [--all | --mirror] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>] [--repo=all] [-f | --force] [-v] [<repository> <refspec>...]",
NULL,
};
@@ -91,6 +91,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
{
int flags = 0;
int all = 0;
+ int mirror = 0;
int dry_run = 0;
int force = 0;
int tags = 0;
@@ -100,6 +101,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
OPT__VERBOSE(&verbose),
OPT_STRING( 0 , "repo", &repo, "repository", "repository"),
OPT_BOOLEAN( 0 , "all", &all, "push all refs"),
+ OPT_BOOLEAN( 0 , "mirror", &mirror, "mirror all refs"),
OPT_BOOLEAN( 0 , "tags", &tags, "push tags"),
OPT_BOOLEAN( 0 , "dry-run", &dry_run, "dry run"),
OPT_BOOLEAN('f', "force", &force, "force updates"),
@@ -119,13 +121,21 @@ int cmd_push(int argc, const char **argv, const char *prefix)
add_refspec("refs/tags/*");
if (all)
flags |= TRANSPORT_PUSH_ALL;
+ if (mirror)
+ flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
if (argc > 0) {
repo = argv[0];
set_refspecs(argv + 1, argc - 1);
}
- if ((flags & TRANSPORT_PUSH_ALL) && refspec)
+ if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) && refspec)
usage_with_options(push_usage, options);
+ if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) ==
+ (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) {
+ error("--all and --mirror are incompatible");
+ usage_with_options(push_usage, options);
+ }
+
return do_push(repo, flags);
}
diff --git a/transport.c b/transport.c
index f4577b7..08e62b1 100644
--- a/transport.c
+++ b/transport.c
@@ -284,6 +284,9 @@ static int rsync_transport_push(struct transport *transport,
struct child_process rsync;
const char *args[10];
+ if (flags & TRANSPORT_PUSH_MIRROR)
+ return error("rsync transport does not support mirror mode");
+
/* first push the objects */
strbuf_addstr(&buf, transport->url);
@@ -386,6 +389,9 @@ static int curl_transport_push(struct transport *transport, int refspec_nr, cons
int argc;
int err;
+ if (flags & TRANSPORT_PUSH_MIRROR)
+ return error("http transport does not support mirror mode");
+
argv = xmalloc((refspec_nr + 11) * sizeof(char *));
argv[0] = "http-push";
argc = 1;
@@ -653,6 +659,7 @@ static int git_transport_push(struct transport *transport, int refspec_nr, const
args.receivepack = data->receivepack;
args.send_all = !!(flags & TRANSPORT_PUSH_ALL);
+ args.send_mirror = !!(flags & TRANSPORT_PUSH_MIRROR);
args.force_update = !!(flags & TRANSPORT_PUSH_FORCE);
args.use_thin_pack = data->thin;
args.verbose = transport->verbose;
diff --git a/transport.h b/transport.h
index d27f562..7f337d2 100644
--- a/transport.h
+++ b/transport.h
@@ -30,6 +30,7 @@ struct transport {
#define TRANSPORT_PUSH_ALL 1
#define TRANSPORT_PUSH_FORCE 2
#define TRANSPORT_PUSH_DRY_RUN 4
+#define TRANSPORT_PUSH_MIRROR 8
/* Returns a transport suitable for the url */
struct transport *transport_get(struct remote *, const char *);
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: git push mirror mode
2007-11-08 12:11 git push mirror mode Andy Whitcroft
2007-11-08 12:12 ` [PATCH 1/2] mirror pushing Andy Whitcroft
2007-11-08 12:12 ` [PATCH 2/2] git-push: plumb in --mirror mode Andy Whitcroft
@ 2007-11-08 12:19 ` Johannes Schindelin
2007-11-08 12:44 ` Andy Whitcroft
` (2 more replies)
2007-11-08 14:24 ` [PATCH 1/2] mirror pushing Andy Whitcroft
` (2 subsequent siblings)
5 siblings, 3 replies; 23+ messages in thread
From: Johannes Schindelin @ 2007-11-08 12:19 UTC (permalink / raw)
To: Andy Whitcroft; +Cc: git
Hi,
On Thu, 8 Nov 2007, Andy Whitcroft wrote:
> Ok, sometime back Junio sent out a proof-of-concept change to
> send-pack allowing a mirror mode.
You added/left his sign-off, but did not attribute the patches to him.
Why?
Ciao,
Dscho
P.S.: Without tests I am opposed to inclusion. This _definitely_ needs
some tests.
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: git push mirror mode
2007-11-08 12:19 ` git push mirror mode Johannes Schindelin
@ 2007-11-08 12:44 ` Andy Whitcroft
2007-11-08 13:14 ` Andreas Ericsson
2007-11-08 12:49 ` Andy Whitcroft
2007-11-08 21:53 ` Junio C Hamano
2 siblings, 1 reply; 23+ messages in thread
From: Andy Whitcroft @ 2007-11-08 12:44 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git, Junio C Hamano
On Thu, Nov 08, 2007 at 12:19:18PM +0000, Johannes Schindelin wrote:
> Hi,
>
> On Thu, 8 Nov 2007, Andy Whitcroft wrote:
>
> > Ok, sometime back Junio sent out a proof-of-concept change to
> > send-pack allowing a mirror mode.
>
> You added/left his sign-off, but did not attribute the patches to him.
> Why?
I believe I left his signed off by from the original (first) patch, and
added mine to indicate that what I had modified was also unecombered.
The second patch is only signed off by me as I am the author. In my
world (admittedly a kernel hacker) the first Signed-off-by: indicates the
primary authorship of that patch and the [apw@...] part tries to clarify
the changes I made therein.
No intentional stripping of credit was intended, and I believe that the
attribution as written states Junio is the originator of this patch.
However that is the way I would read the meanings of these lines, if git
has different rules or you think there is a clearer way of stating this
I am happy to change it, and resend it so attributed.
-apw
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: git push mirror mode
2007-11-08 12:44 ` Andy Whitcroft
@ 2007-11-08 13:14 ` Andreas Ericsson
2007-11-08 13:44 ` Andy Whitcroft
0 siblings, 1 reply; 23+ messages in thread
From: Andreas Ericsson @ 2007-11-08 13:14 UTC (permalink / raw)
To: Andy Whitcroft; +Cc: Johannes Schindelin, git, Junio C Hamano
Andy Whitcroft wrote:
> On Thu, Nov 08, 2007 at 12:19:18PM +0000, Johannes Schindelin wrote:
>> Hi,
>>
>> On Thu, 8 Nov 2007, Andy Whitcroft wrote:
>>
>>> Ok, sometime back Junio sent out a proof-of-concept change to
>>> send-pack allowing a mirror mode.
>> You added/left his sign-off, but did not attribute the patches to him.
>> Why?
>
> I believe I left his signed off by from the original (first) patch, and
> added mine to indicate that what I had modified was also unecombered.
> The second patch is only signed off by me as I am the author. In my
> world (admittedly a kernel hacker) the first Signed-off-by: indicates the
> primary authorship of that patch and the [apw@...] part tries to clarify
> the changes I made therein.
>
> No intentional stripping of credit was intended, and I believe that the
> attribution as written states Junio is the originator of this patch.
> However that is the way I would read the meanings of these lines, if git
> has different rules or you think there is a clearer way of stating this
> I am happy to change it, and resend it so attributed.
>
Barring any errors in my understanding of the matter, here's how it
works for git.
git separates author from committer, so code attribution is done with
author, and "I verified this is sane" is done by committer. Those two
usually only ever differ when the user tells git commit that the author
was someone else than him/her self, or when rewriting history with git
rebase or similar. git am also maintains authorship (using the From:
line in emails), but sets $committer to the person running it, so when
you apply patches sent by email from someone else you get the code
attribution right by default.
The Signed-off-by line is, in git, used as "I touched the code here and
agree that it may be included in the mothership repo and all future
releases" (the spirit of that sentence is also in
Documentation/SubmittingPatches).
We also have Acked-by (as does the kernel, no? I think we inherited it
from there) to mean something along the lines of "I vote we include this",
but not always based on technical merit (ie, patches can have many acks
without having ever been tested).
Suggested-by, Tested-by and Reported-by are used less often, not always
written in dash-form, but hopefully always self-explanatory ;-)
--
Andreas Ericsson andreas.ericsson@op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: git push mirror mode
2007-11-08 13:14 ` Andreas Ericsson
@ 2007-11-08 13:44 ` Andy Whitcroft
2007-11-08 13:48 ` Andreas Ericsson
0 siblings, 1 reply; 23+ messages in thread
From: Andy Whitcroft @ 2007-11-08 13:44 UTC (permalink / raw)
To: Andreas Ericsson; +Cc: Johannes Schindelin, git, Junio C Hamano
On Thu, Nov 08, 2007 at 02:14:12PM +0100, Andreas Ericsson wrote:
> Barring any errors in my understanding of the matter, here's how it
> works for git.
>
> git separates author from committer, so code attribution is done with
> author, and "I verified this is sane" is done by committer. Those two
> usually only ever differ when the user tells git commit that the author
> was someone else than him/her self, or when rewriting history with git
> rebase or similar. git am also maintains authorship (using the From:
> line in emails), but sets $committer to the person running it, so when
> you apply patches sent by email from someone else you get the code
> attribution right by default.
>
> The Signed-off-by line is, in git, used as "I touched the code here and
> agree that it may be included in the mothership repo and all future
> releases" (the spirit of that sentence is also in
> Documentation/SubmittingPatches).
>
> We also have Acked-by (as does the kernel, no? I think we inherited it
> from there) to mean something along the lines of "I vote we include this",
> but not always based on technical merit (ie, patches can have many acks
> without having ever been tested).
>
> Suggested-by, Tested-by and Reported-by are used less often, not always
> written in dash-form, but hopefully always self-explanatory ;-)
What that doesn't tell me is how when sending an email carrying a patch
one ensures the attribution is correct when loaded into git.
Having messed about with it a bit it does seem that if one wants git to
attribute the patch to junio I have to add a From: line to the top of
the email payload.
I'll resend so attributed.
-apw
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: git push mirror mode
2007-11-08 13:44 ` Andy Whitcroft
@ 2007-11-08 13:48 ` Andreas Ericsson
0 siblings, 0 replies; 23+ messages in thread
From: Andreas Ericsson @ 2007-11-08 13:48 UTC (permalink / raw)
To: Andy Whitcroft; +Cc: Johannes Schindelin, git, Junio C Hamano
Andy Whitcroft wrote:
> On Thu, Nov 08, 2007 at 02:14:12PM +0100, Andreas Ericsson wrote:
>
>> Barring any errors in my understanding of the matter, here's how it
>> works for git.
>>
>> git separates author from committer, so code attribution is done with
>> author, and "I verified this is sane" is done by committer. Those two
>> usually only ever differ when the user tells git commit that the author
>> was someone else than him/her self, or when rewriting history with git
>> rebase or similar. git am also maintains authorship (using the From:
>> line in emails), but sets $committer to the person running it, so when
>> you apply patches sent by email from someone else you get the code
>> attribution right by default.
>>
>> The Signed-off-by line is, in git, used as "I touched the code here and
>> agree that it may be included in the mothership repo and all future
>> releases" (the spirit of that sentence is also in
>> Documentation/SubmittingPatches).
>>
>> We also have Acked-by (as does the kernel, no? I think we inherited it
>> from there) to mean something along the lines of "I vote we include this",
>> but not always based on technical merit (ie, patches can have many acks
>> without having ever been tested).
>>
>> Suggested-by, Tested-by and Reported-by are used less often, not always
>> written in dash-form, but hopefully always self-explanatory ;-)
>
> What that doesn't tell me is how when sending an email carrying a patch
> one ensures the attribution is correct when loaded into git.
>
Ach damn. I had a sentence there reading "From: can also be specified in
the email body to attribute code to someone else than the sender." It's
in my clipboard, but I forgot to paste it :-/
> Having messed about with it a bit it does seem that if one wants git to
> attribute the patch to junio I have to add a From: line to the top of
> the email payload.
>
> I'll resend so attributed.
>
Thanks.
--
Andreas Ericsson andreas.ericsson@op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: git push mirror mode
2007-11-08 12:19 ` git push mirror mode Johannes Schindelin
2007-11-08 12:44 ` Andy Whitcroft
@ 2007-11-08 12:49 ` Andy Whitcroft
2007-11-08 21:53 ` Junio C Hamano
2 siblings, 0 replies; 23+ messages in thread
From: Andy Whitcroft @ 2007-11-08 12:49 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
On Thu, Nov 08, 2007 at 12:19:18PM +0000, Johannes Schindelin wrote:
> P.S.: Without tests I am opposed to inclusion. This _definitely_ needs
> some tests.
This is very much 'pu' material right now. I've used it for a day
keeping some kernel repos in sync on a couple of test boxes. Hardly
extensive testing.
Yes some tests would be advisable. However I am no expert in the git
test system, so I am not going to be able to do that in short order.
What little time I had to work on this this morning was wasted by some
SarBox madness here (but that is another story). In the spirit of
making progress on what is a useful feature I pulled Junio's original
change forward, fixed up my patch to expose it the the user and gave it
some testing.
Whats there does seem to work and has a prima-facie use case. Hopefully
someone can provide the nessary tests before I can.
-apw
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: git push mirror mode
2007-11-08 12:19 ` git push mirror mode Johannes Schindelin
2007-11-08 12:44 ` Andy Whitcroft
2007-11-08 12:49 ` Andy Whitcroft
@ 2007-11-08 21:53 ` Junio C Hamano
2 siblings, 0 replies; 23+ messages in thread
From: Junio C Hamano @ 2007-11-08 21:53 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Andy Whitcroft, git
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> On Thu, 8 Nov 2007, Andy Whitcroft wrote:
>
>> Ok, sometime back Junio sent out a proof-of-concept change to
>> send-pack allowing a mirror mode.
>
> You added/left his sign-off, but did not attribute the patches to him.
No big deal; I do not think much of my changes remain in the
result. Mentioning "inspired by" would be nice as courtesy, but
I think this is mostly Andy's work.
As I haven't seen _his_ part of the change before he posted this
updated patch, copying my S-o-b line wasn't necessary either.
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 1/2] mirror pushing
2007-11-08 12:11 git push mirror mode Andy Whitcroft
` (2 preceding siblings ...)
2007-11-08 12:19 ` git push mirror mode Johannes Schindelin
@ 2007-11-08 14:24 ` Andy Whitcroft
2007-11-08 15:03 ` Johannes Schindelin
2007-11-08 14:25 ` [PATCH 2/2] git-push: plumb in --mirror mode Andy Whitcroft
2007-11-08 16:58 ` git push mirror mode V3 Andy Whitcroft
5 siblings, 1 reply; 23+ messages in thread
From: Andy Whitcroft @ 2007-11-08 14:24 UTC (permalink / raw)
To: git
From: Junio C Hamano <gitster@pobox.com>
Existing "git push --all" is almost perfect for backing up to
another repository, except that "--all" only means "all
branches" in modern git, and it does not delete old branches and
tags that exist at the back-up repository that you have removed
from your local repository.
This teaches "git-send-pack" a new "--mirror" option. The
difference from the "--all" option are that (1) it sends all
refs, not just branches, and (2) it deletes old refs you no
longer have on the local side from the remote side.
[apw@shadowen.org: rebase to next post arguments update]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
---
builtin-send-pack.c | 40 ++++++++++++++++++++++++++++------------
remote.c | 15 ++++++++++-----
send-pack.h | 1 +
3 files changed, 39 insertions(+), 17 deletions(-)
diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index 5a0f5c6..d5ead97 100644
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
@@ -8,7 +8,7 @@
#include "send-pack.h"
static const char send_pack_usage[] =
-"git-send-pack [--all] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n"
+"git-send-pack [--all | --mirror] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n"
" --all and explicit <ref> specification are mutually exclusive.";
static struct send_pack_args args = {
@@ -242,7 +242,7 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
if (!remote_tail)
remote_tail = &remote_refs;
if (match_refs(local_refs, remote_refs, &remote_tail,
- nr_refspec, refspec, args.send_all))
+ nr_refspec, refspec, args.send_all | (args.send_mirror << 1)))
return -1;
if (!remote_refs) {
@@ -259,20 +259,28 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
char old_hex[60], *new_hex;
int will_delete_ref;
const char *pretty_ref;
- const char *pretty_peer;
+ const char *pretty_peer = NULL; /* only used when not deleting */
+ const unsigned char *new_sha1;
- if (!ref->peer_ref)
- continue;
+ if (!ref->peer_ref) {
+ if (!args.send_mirror)
+ continue;
+ new_sha1 = null_sha1;
+ }
+ else
+ new_sha1 = ref->peer_ref->new_sha1;
if (!shown_dest) {
fprintf(stderr, "To %s\n", dest);
shown_dest = 1;
}
+ will_delete_ref = is_null_sha1(new_sha1);
+
pretty_ref = prettify_ref(ref->name);
- pretty_peer = prettify_ref(ref->peer_ref->name);
+ if (!will_delete_ref)
+ pretty_peer = prettify_ref(ref->peer_ref->name);
- will_delete_ref = is_null_sha1(ref->peer_ref->new_sha1);
if (will_delete_ref && !allow_deleting_refs) {
fprintf(stderr, " ! %-*s %s (remote does not support deleting refs)\n",
SUMMARY_WIDTH, "[rejected]", pretty_ref);
@@ -280,7 +288,7 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
continue;
}
if (!will_delete_ref &&
- !hashcmp(ref->old_sha1, ref->peer_ref->new_sha1)) {
+ !hashcmp(ref->old_sha1, new_sha1)) {
if (args.verbose)
fprintf(stderr, " = %-*s %s -> %s\n",
SUMMARY_WIDTH, "[up to date]",
@@ -312,8 +320,7 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
!is_null_sha1(ref->old_sha1) &&
!ref->force) {
if (!has_sha1_file(ref->old_sha1) ||
- !ref_newer(ref->peer_ref->new_sha1,
- ref->old_sha1)) {
+ !ref_newer(new_sha1, ref->old_sha1)) {
/* We do not have the remote ref, or
* we know that the remote ref is not
* an ancestor of what we are trying to
@@ -328,7 +335,7 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
continue;
}
}
- hashcpy(ref->new_sha1, ref->peer_ref->new_sha1);
+ hashcpy(ref->new_sha1, new_sha1);
if (!will_delete_ref)
new_refs++;
strcpy(old_hex, sha1_to_hex(ref->old_sha1));
@@ -459,6 +466,10 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
args.dry_run = 1;
continue;
}
+ if (!strcmp(arg, "--mirror")) {
+ args.send_mirror = 1;
+ continue;
+ }
if (!strcmp(arg, "--force")) {
args.force_update = 1;
continue;
@@ -483,7 +494,12 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
}
if (!dest)
usage(send_pack_usage);
- if (heads && args.send_all)
+ /*
+ * --all and --mirror are incompatible; neither makes sense
+ * with any refspecs.
+ */
+ if ((heads && (args.send_all || args.send_mirror)) ||
+ (args.send_all && args.send_mirror))
usage(send_pack_usage);
if (remote_name) {
diff --git a/remote.c b/remote.c
index 59defdb..45dd59b 100644
--- a/remote.c
+++ b/remote.c
@@ -722,10 +722,12 @@ static const struct refspec *check_pattern_match(const struct refspec *rs,
* without thinking.
*/
int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
- int nr_refspec, const char **refspec, int all)
+ int nr_refspec, const char **refspec, int flags)
{
struct refspec *rs =
parse_ref_spec(nr_refspec, (const char **) refspec);
+ int send_all = flags & 01;
+ int send_mirror = flags & 02;
if (match_explicit_refs(src, dst, dst_tail, rs, nr_refspec))
return -1;
@@ -742,7 +744,7 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
if (!pat)
continue;
}
- else if (prefixcmp(src->name, "refs/heads/"))
+ else if (!send_mirror && prefixcmp(src->name, "refs/heads/"))
/*
* "matching refs"; traditionally we pushed everything
* including refs outside refs/heads/ hierarchy, but
@@ -763,10 +765,13 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
if (dst_peer && dst_peer->peer_ref)
/* We're already sending something to this ref. */
goto free_name;
- if (!dst_peer && !nr_refspec && !all)
- /* Remote doesn't have it, and we have no
+
+ if (!dst_peer && !nr_refspec && !(send_all || send_mirror))
+ /*
+ * Remote doesn't have it, and we have no
* explicit pattern, and we don't have
- * --all. */
+ * --all nor --mirror.
+ */
goto free_name;
if (!dst_peer) {
/* Create a new one and link it */
diff --git a/send-pack.h b/send-pack.h
index 7a24f71..8ff1dc3 100644
--- a/send-pack.h
+++ b/send-pack.h
@@ -5,6 +5,7 @@ struct send_pack_args {
const char *receivepack;
unsigned verbose:1,
send_all:1,
+ send_mirror:1,
force_update:1,
use_thin_pack:1,
dry_run:1;
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH 1/2] mirror pushing
2007-11-08 14:24 ` [PATCH 1/2] mirror pushing Andy Whitcroft
@ 2007-11-08 15:03 ` Johannes Schindelin
0 siblings, 0 replies; 23+ messages in thread
From: Johannes Schindelin @ 2007-11-08 15:03 UTC (permalink / raw)
To: Andy Whitcroft; +Cc: git
Hi,
On Thu, 8 Nov 2007, Andy Whitcroft wrote:
> - nr_refspec, refspec, args.send_all))
> + nr_refspec, refspec, args.send_all | (args.send_mirror << 1)))
This line is too long. But it needsmore love: it's all too magic to have
a 1 for send_all, and a 2 for mirror. Please introduce an enum for that
in remote.h, and use those constants, so that this hunk and the following
one cannot get out of sync that easily.
> +++ b/remote.c
> @@ -722,10 +722,12 @@ static const struct refspec *check_pattern_match(const struct refspec *rs,
> * without thinking.
> */
> int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
> - int nr_refspec, const char **refspec, int all)
> + int nr_refspec, const char **refspec, int flags)
> {
> struct refspec *rs =
> parse_ref_spec(nr_refspec, (const char **) refspec);
> + int send_all = flags & 01;
> + int send_mirror = flags & 02;
>
> if (match_explicit_refs(src, dst, dst_tail, rs, nr_refspec))
> return -1;
Thanks,
Dscho
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 2/2] git-push: plumb in --mirror mode
2007-11-08 12:11 git push mirror mode Andy Whitcroft
` (3 preceding siblings ...)
2007-11-08 14:24 ` [PATCH 1/2] mirror pushing Andy Whitcroft
@ 2007-11-08 14:25 ` Andy Whitcroft
2007-11-08 16:58 ` git push mirror mode V3 Andy Whitcroft
5 siblings, 0 replies; 23+ messages in thread
From: Andy Whitcroft @ 2007-11-08 14:25 UTC (permalink / raw)
To: git
Plumb in the --mirror mode for git-push.
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
---
builtin-push.c | 14 ++++++++++++--
transport.c | 7 +++++++
transport.h | 1 +
3 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/builtin-push.c b/builtin-push.c
index 2c56195..d49157c 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -10,7 +10,7 @@
#include "parse-options.h"
static const char * const push_usage[] = {
- "git-push [--all] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>] [--repo=all] [-f | --force] [-v] [<repository> <refspec>...]",
+ "git-push [--all | --mirror] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>] [--repo=all] [-f | --force] [-v] [<repository> <refspec>...]",
NULL,
};
@@ -91,6 +91,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
{
int flags = 0;
int all = 0;
+ int mirror = 0;
int dry_run = 0;
int force = 0;
int tags = 0;
@@ -100,6 +101,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
OPT__VERBOSE(&verbose),
OPT_STRING( 0 , "repo", &repo, "repository", "repository"),
OPT_BOOLEAN( 0 , "all", &all, "push all refs"),
+ OPT_BOOLEAN( 0 , "mirror", &mirror, "mirror all refs"),
OPT_BOOLEAN( 0 , "tags", &tags, "push tags"),
OPT_BOOLEAN( 0 , "dry-run", &dry_run, "dry run"),
OPT_BOOLEAN('f', "force", &force, "force updates"),
@@ -119,13 +121,21 @@ int cmd_push(int argc, const char **argv, const char *prefix)
add_refspec("refs/tags/*");
if (all)
flags |= TRANSPORT_PUSH_ALL;
+ if (mirror)
+ flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
if (argc > 0) {
repo = argv[0];
set_refspecs(argv + 1, argc - 1);
}
- if ((flags & TRANSPORT_PUSH_ALL) && refspec)
+ if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) && refspec)
usage_with_options(push_usage, options);
+ if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) ==
+ (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) {
+ error("--all and --mirror are incompatible");
+ usage_with_options(push_usage, options);
+ }
+
return do_push(repo, flags);
}
diff --git a/transport.c b/transport.c
index f4577b7..08e62b1 100644
--- a/transport.c
+++ b/transport.c
@@ -284,6 +284,9 @@ static int rsync_transport_push(struct transport *transport,
struct child_process rsync;
const char *args[10];
+ if (flags & TRANSPORT_PUSH_MIRROR)
+ return error("rsync transport does not support mirror mode");
+
/* first push the objects */
strbuf_addstr(&buf, transport->url);
@@ -386,6 +389,9 @@ static int curl_transport_push(struct transport *transport, int refspec_nr, cons
int argc;
int err;
+ if (flags & TRANSPORT_PUSH_MIRROR)
+ return error("http transport does not support mirror mode");
+
argv = xmalloc((refspec_nr + 11) * sizeof(char *));
argv[0] = "http-push";
argc = 1;
@@ -653,6 +659,7 @@ static int git_transport_push(struct transport *transport, int refspec_nr, const
args.receivepack = data->receivepack;
args.send_all = !!(flags & TRANSPORT_PUSH_ALL);
+ args.send_mirror = !!(flags & TRANSPORT_PUSH_MIRROR);
args.force_update = !!(flags & TRANSPORT_PUSH_FORCE);
args.use_thin_pack = data->thin;
args.verbose = transport->verbose;
diff --git a/transport.h b/transport.h
index d27f562..7f337d2 100644
--- a/transport.h
+++ b/transport.h
@@ -30,6 +30,7 @@ struct transport {
#define TRANSPORT_PUSH_ALL 1
#define TRANSPORT_PUSH_FORCE 2
#define TRANSPORT_PUSH_DRY_RUN 4
+#define TRANSPORT_PUSH_MIRROR 8
/* Returns a transport suitable for the url */
struct transport *transport_get(struct remote *, const char *);
^ permalink raw reply related [flat|nested] 23+ messages in thread
* git push mirror mode V3
2007-11-08 12:11 git push mirror mode Andy Whitcroft
` (4 preceding siblings ...)
2007-11-08 14:25 ` [PATCH 2/2] git-push: plumb in --mirror mode Andy Whitcroft
@ 2007-11-08 16:58 ` Andy Whitcroft
2007-11-08 17:00 ` [PATCH 1/4] mirror pushing Andy Whitcroft
` (3 more replies)
5 siblings, 4 replies; 23+ messages in thread
From: Andy Whitcroft @ 2007-11-08 16:58 UTC (permalink / raw)
To: git
Ok, here is an update based on feedback from the list. I bit the bullet
and added some basic tests. The stack passes the test suite. Hopefully
the attribution is ok on the first patch now. I have kept my
modifications to it a separate patch for the time being to keep
attribution simple.
-apw
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 1/4] mirror pushing
2007-11-08 16:58 ` git push mirror mode V3 Andy Whitcroft
@ 2007-11-08 17:00 ` Andy Whitcroft
2007-11-08 17:01 ` [PATCH 2/4] mirror pushing -- clean up match_refs flags Andy Whitcroft
` (2 subsequent siblings)
3 siblings, 0 replies; 23+ messages in thread
From: Andy Whitcroft @ 2007-11-08 17:00 UTC (permalink / raw)
To: git
From: Junio C Hamano <gitster@pobox.com>
Existing "git push --all" is almost perfect for backing up to
another repository, except that "--all" only means "all
branches" in modern git, and it does not delete old branches and
tags that exist at the back-up repository that you have removed
from your local repository.
This teaches "git-send-pack" a new "--mirror" option. The
difference from the "--all" option are that (1) it sends all
refs, not just branches, and (2) it deletes old refs you no
longer have on the local side from the remote side.
[apw@shadowen.org: rebase to next post arguments update]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
---
builtin-send-pack.c | 40 ++++++++++++++++++++++++++++------------
remote.c | 15 ++++++++++-----
send-pack.h | 1 +
3 files changed, 39 insertions(+), 17 deletions(-)
diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index 5a0f5c6..d5ead97 100644
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
@@ -8,7 +8,7 @@
#include "send-pack.h"
static const char send_pack_usage[] =
-"git-send-pack [--all] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n"
+"git-send-pack [--all | --mirror] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n"
" --all and explicit <ref> specification are mutually exclusive.";
static struct send_pack_args args = {
@@ -242,7 +242,7 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
if (!remote_tail)
remote_tail = &remote_refs;
if (match_refs(local_refs, remote_refs, &remote_tail,
- nr_refspec, refspec, args.send_all))
+ nr_refspec, refspec, args.send_all | (args.send_mirror << 1)))
return -1;
if (!remote_refs) {
@@ -259,20 +259,28 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
char old_hex[60], *new_hex;
int will_delete_ref;
const char *pretty_ref;
- const char *pretty_peer;
+ const char *pretty_peer = NULL; /* only used when not deleting */
+ const unsigned char *new_sha1;
- if (!ref->peer_ref)
- continue;
+ if (!ref->peer_ref) {
+ if (!args.send_mirror)
+ continue;
+ new_sha1 = null_sha1;
+ }
+ else
+ new_sha1 = ref->peer_ref->new_sha1;
if (!shown_dest) {
fprintf(stderr, "To %s\n", dest);
shown_dest = 1;
}
+ will_delete_ref = is_null_sha1(new_sha1);
+
pretty_ref = prettify_ref(ref->name);
- pretty_peer = prettify_ref(ref->peer_ref->name);
+ if (!will_delete_ref)
+ pretty_peer = prettify_ref(ref->peer_ref->name);
- will_delete_ref = is_null_sha1(ref->peer_ref->new_sha1);
if (will_delete_ref && !allow_deleting_refs) {
fprintf(stderr, " ! %-*s %s (remote does not support deleting refs)\n",
SUMMARY_WIDTH, "[rejected]", pretty_ref);
@@ -280,7 +288,7 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
continue;
}
if (!will_delete_ref &&
- !hashcmp(ref->old_sha1, ref->peer_ref->new_sha1)) {
+ !hashcmp(ref->old_sha1, new_sha1)) {
if (args.verbose)
fprintf(stderr, " = %-*s %s -> %s\n",
SUMMARY_WIDTH, "[up to date]",
@@ -312,8 +320,7 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
!is_null_sha1(ref->old_sha1) &&
!ref->force) {
if (!has_sha1_file(ref->old_sha1) ||
- !ref_newer(ref->peer_ref->new_sha1,
- ref->old_sha1)) {
+ !ref_newer(new_sha1, ref->old_sha1)) {
/* We do not have the remote ref, or
* we know that the remote ref is not
* an ancestor of what we are trying to
@@ -328,7 +335,7 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
continue;
}
}
- hashcpy(ref->new_sha1, ref->peer_ref->new_sha1);
+ hashcpy(ref->new_sha1, new_sha1);
if (!will_delete_ref)
new_refs++;
strcpy(old_hex, sha1_to_hex(ref->old_sha1));
@@ -459,6 +466,10 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
args.dry_run = 1;
continue;
}
+ if (!strcmp(arg, "--mirror")) {
+ args.send_mirror = 1;
+ continue;
+ }
if (!strcmp(arg, "--force")) {
args.force_update = 1;
continue;
@@ -483,7 +494,12 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
}
if (!dest)
usage(send_pack_usage);
- if (heads && args.send_all)
+ /*
+ * --all and --mirror are incompatible; neither makes sense
+ * with any refspecs.
+ */
+ if ((heads && (args.send_all || args.send_mirror)) ||
+ (args.send_all && args.send_mirror))
usage(send_pack_usage);
if (remote_name) {
diff --git a/remote.c b/remote.c
index 59defdb..45dd59b 100644
--- a/remote.c
+++ b/remote.c
@@ -722,10 +722,12 @@ static const struct refspec *check_pattern_match(const struct refspec *rs,
* without thinking.
*/
int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
- int nr_refspec, const char **refspec, int all)
+ int nr_refspec, const char **refspec, int flags)
{
struct refspec *rs =
parse_ref_spec(nr_refspec, (const char **) refspec);
+ int send_all = flags & 01;
+ int send_mirror = flags & 02;
if (match_explicit_refs(src, dst, dst_tail, rs, nr_refspec))
return -1;
@@ -742,7 +744,7 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
if (!pat)
continue;
}
- else if (prefixcmp(src->name, "refs/heads/"))
+ else if (!send_mirror && prefixcmp(src->name, "refs/heads/"))
/*
* "matching refs"; traditionally we pushed everything
* including refs outside refs/heads/ hierarchy, but
@@ -763,10 +765,13 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
if (dst_peer && dst_peer->peer_ref)
/* We're already sending something to this ref. */
goto free_name;
- if (!dst_peer && !nr_refspec && !all)
- /* Remote doesn't have it, and we have no
+
+ if (!dst_peer && !nr_refspec && !(send_all || send_mirror))
+ /*
+ * Remote doesn't have it, and we have no
* explicit pattern, and we don't have
- * --all. */
+ * --all nor --mirror.
+ */
goto free_name;
if (!dst_peer) {
/* Create a new one and link it */
diff --git a/send-pack.h b/send-pack.h
index 7a24f71..8ff1dc3 100644
--- a/send-pack.h
+++ b/send-pack.h
@@ -5,6 +5,7 @@ struct send_pack_args {
const char *receivepack;
unsigned verbose:1,
send_all:1,
+ send_mirror:1,
force_update:1,
use_thin_pack:1,
dry_run:1;
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 2/4] mirror pushing -- clean up match_refs flags
2007-11-08 16:58 ` git push mirror mode V3 Andy Whitcroft
2007-11-08 17:00 ` [PATCH 1/4] mirror pushing Andy Whitcroft
@ 2007-11-08 17:01 ` Andy Whitcroft
2007-11-08 17:01 ` [PATCH 3/4] git-push: plumb in --mirror mode Andy Whitcroft
2007-11-08 17:01 ` [PATCH 4/4] tests: git push mirror mode tests Andy Whitcroft
3 siblings, 0 replies; 23+ messages in thread
From: Andy Whitcroft @ 2007-11-08 17:01 UTC (permalink / raw)
To: git
Add a new enum to define the match_refs flags field and switch
all callers to it.
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
---
builtin-send-pack.c | 8 +++++++-
http-push.c | 4 ++--
remote.c | 4 ++--
remote.h | 7 +++++++
4 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index d5ead97..d42164e 100644
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
@@ -227,6 +227,12 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
int allow_deleting_refs = 0;
int expect_status_report = 0;
int shown_dest = 0;
+ int flags = MATCH_REFS_NONE;
+
+ if (args.send_all)
+ flags |= MATCH_REFS_ALL;
+ if (args.send_mirror)
+ flags |= MATCH_REFS_MIRROR;
/* No funny business with the matcher */
remote_tail = get_remote_heads(in, &remote_refs, 0, NULL, REF_NORMAL);
@@ -242,7 +248,7 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
if (!remote_tail)
remote_tail = &remote_refs;
if (match_refs(local_refs, remote_refs, &remote_tail,
- nr_refspec, refspec, args.send_all | (args.send_mirror << 1)))
+ nr_refspec, refspec, flags))
return -1;
if (!remote_refs) {
diff --git a/http-push.c b/http-push.c
index 99328f5..66b81f1 100644
--- a/http-push.c
+++ b/http-push.c
@@ -78,7 +78,7 @@ static struct curl_slist *no_pragma_header;
static struct curl_slist *default_headers;
static int push_verbosely;
-static int push_all;
+static int push_all = MATCH_REFS_NONE;
static int force_all;
static int dry_run;
@@ -2300,7 +2300,7 @@ int main(int argc, char **argv)
if (*arg == '-') {
if (!strcmp(arg, "--all")) {
- push_all = 1;
+ push_all = MATCH_REFS_ALL;
continue;
}
if (!strcmp(arg, "--force")) {
diff --git a/remote.c b/remote.c
index 45dd59b..09b7aad 100644
--- a/remote.c
+++ b/remote.c
@@ -726,8 +726,8 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
{
struct refspec *rs =
parse_ref_spec(nr_refspec, (const char **) refspec);
- int send_all = flags & 01;
- int send_mirror = flags & 02;
+ int send_all = flags & MATCH_REFS_ALL;
+ int send_mirror = flags & MATCH_REFS_MIRROR;
if (match_explicit_refs(src, dst, dst_tail, rs, nr_refspec))
return -1;
diff --git a/remote.h b/remote.h
index 6a4c7a0..b10036c 100644
--- a/remote.h
+++ b/remote.h
@@ -102,4 +102,11 @@ struct branch *branch_get(const char *name);
int branch_has_merge_config(struct branch *branch);
int branch_merge_matches(struct branch *, int n, const char *);
+/* Flags to match_refs. */
+enum match_refs_flags {
+ MATCH_REFS_NONE = 0,
+ MATCH_REFS_ALL = (1 << 0),
+ MATCH_REFS_MIRROR = (1 << 1),
+};
+
#endif
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 3/4] git-push: plumb in --mirror mode
2007-11-08 16:58 ` git push mirror mode V3 Andy Whitcroft
2007-11-08 17:00 ` [PATCH 1/4] mirror pushing Andy Whitcroft
2007-11-08 17:01 ` [PATCH 2/4] mirror pushing -- clean up match_refs flags Andy Whitcroft
@ 2007-11-08 17:01 ` Andy Whitcroft
2007-11-08 17:01 ` [PATCH 4/4] tests: git push mirror mode tests Andy Whitcroft
3 siblings, 0 replies; 23+ messages in thread
From: Andy Whitcroft @ 2007-11-08 17:01 UTC (permalink / raw)
To: git
Plumb in the --mirror mode for git-push.
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
---
builtin-push.c | 14 ++++++++++++--
transport.c | 7 +++++++
transport.h | 1 +
3 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/builtin-push.c b/builtin-push.c
index 2c56195..d49157c 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -10,7 +10,7 @@
#include "parse-options.h"
static const char * const push_usage[] = {
- "git-push [--all] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>] [--repo=all] [-f | --force] [-v] [<repository> <refspec>...]",
+ "git-push [--all | --mirror] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>] [--repo=all] [-f | --force] [-v] [<repository> <refspec>...]",
NULL,
};
@@ -91,6 +91,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
{
int flags = 0;
int all = 0;
+ int mirror = 0;
int dry_run = 0;
int force = 0;
int tags = 0;
@@ -100,6 +101,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
OPT__VERBOSE(&verbose),
OPT_STRING( 0 , "repo", &repo, "repository", "repository"),
OPT_BOOLEAN( 0 , "all", &all, "push all refs"),
+ OPT_BOOLEAN( 0 , "mirror", &mirror, "mirror all refs"),
OPT_BOOLEAN( 0 , "tags", &tags, "push tags"),
OPT_BOOLEAN( 0 , "dry-run", &dry_run, "dry run"),
OPT_BOOLEAN('f', "force", &force, "force updates"),
@@ -119,13 +121,21 @@ int cmd_push(int argc, const char **argv, const char *prefix)
add_refspec("refs/tags/*");
if (all)
flags |= TRANSPORT_PUSH_ALL;
+ if (mirror)
+ flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
if (argc > 0) {
repo = argv[0];
set_refspecs(argv + 1, argc - 1);
}
- if ((flags & TRANSPORT_PUSH_ALL) && refspec)
+ if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) && refspec)
usage_with_options(push_usage, options);
+ if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) ==
+ (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) {
+ error("--all and --mirror are incompatible");
+ usage_with_options(push_usage, options);
+ }
+
return do_push(repo, flags);
}
diff --git a/transport.c b/transport.c
index f4577b7..08e62b1 100644
--- a/transport.c
+++ b/transport.c
@@ -284,6 +284,9 @@ static int rsync_transport_push(struct transport *transport,
struct child_process rsync;
const char *args[10];
+ if (flags & TRANSPORT_PUSH_MIRROR)
+ return error("rsync transport does not support mirror mode");
+
/* first push the objects */
strbuf_addstr(&buf, transport->url);
@@ -386,6 +389,9 @@ static int curl_transport_push(struct transport *transport, int refspec_nr, cons
int argc;
int err;
+ if (flags & TRANSPORT_PUSH_MIRROR)
+ return error("http transport does not support mirror mode");
+
argv = xmalloc((refspec_nr + 11) * sizeof(char *));
argv[0] = "http-push";
argc = 1;
@@ -653,6 +659,7 @@ static int git_transport_push(struct transport *transport, int refspec_nr, const
args.receivepack = data->receivepack;
args.send_all = !!(flags & TRANSPORT_PUSH_ALL);
+ args.send_mirror = !!(flags & TRANSPORT_PUSH_MIRROR);
args.force_update = !!(flags & TRANSPORT_PUSH_FORCE);
args.use_thin_pack = data->thin;
args.verbose = transport->verbose;
diff --git a/transport.h b/transport.h
index d27f562..7f337d2 100644
--- a/transport.h
+++ b/transport.h
@@ -30,6 +30,7 @@ struct transport {
#define TRANSPORT_PUSH_ALL 1
#define TRANSPORT_PUSH_FORCE 2
#define TRANSPORT_PUSH_DRY_RUN 4
+#define TRANSPORT_PUSH_MIRROR 8
/* Returns a transport suitable for the url */
struct transport *transport_get(struct remote *, const char *);
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 4/4] tests: git push mirror mode tests
2007-11-08 16:58 ` git push mirror mode V3 Andy Whitcroft
` (2 preceding siblings ...)
2007-11-08 17:01 ` [PATCH 3/4] git-push: plumb in --mirror mode Andy Whitcroft
@ 2007-11-08 17:01 ` Andy Whitcroft
2007-11-09 10:21 ` [PATCH] tests: git push mirror mode tests V2 Andy Whitcroft
3 siblings, 1 reply; 23+ messages in thread
From: Andy Whitcroft @ 2007-11-08 17:01 UTC (permalink / raw)
To: git
Add some basic tests for git push --mirror mode.
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
---
t/t5517-push-mirror.sh | 101 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 101 insertions(+), 0 deletions(-)
diff --git a/t/t5517-push-mirror.sh b/t/t5517-push-mirror.sh
new file mode 100755
index 0000000..1a285d4
--- /dev/null
+++ b/t/t5517-push-mirror.sh
@@ -0,0 +1,101 @@
+#!/bin/sh
+
+test_description='pushing to a mirror repository'
+
+. ./test-lib.sh
+
+D=`pwd`
+
+mk_repo_pair () {
+ rm -rf master mirror &&
+ mkdir mirror && cd mirror &&
+ git init &&
+ cd .. &&
+ mkdir master && cd master &&
+ git init &&
+ git config remote.up.url ../mirror &&
+ cd ..
+}
+
+test_expect_success 'push mirror does not create new branches' '
+
+ mk_repo_pair &&
+ cd master &&
+ echo one >foo && git add foo && git commit -m one &&
+ master_master=$(git show-ref -s --verify refs/heads/master) &&
+ git push --mirror up &&
+ cd ../mirror &&
+ mirror_master=$(git show-ref -s --verify refs/heads/master) &&
+ test "$master_master" = "$mirror_master"
+
+'
+
+test_expect_success 'push mirror does not update existing branches' '
+
+ mk_repo_pair &&
+ cd master &&
+ echo one >foo && git add foo && git commit -m one &&
+ git push --mirror up &&
+ echo two >foo && git add foo && git commit -m two &&
+ master_master=$(git show-ref -s --verify refs/heads/master) &&
+ git push --mirror up &&
+ cd ../mirror &&
+ mirror_master=$(git show-ref -s --verify refs/heads/master) &&
+ test "$master_master" = "$mirror_master"
+
+'
+
+test_expect_success 'push mirror does not force update existing branches' '
+
+ mk_repo_pair &&
+ cd master &&
+ echo one >foo && git add foo && git commit -m one &&
+ git push --mirror up &&
+ echo two >foo && git add foo && git commit -m two &&
+ git push --mirror up &&
+ git reset --hard HEAD^
+ master_master=$(git show-ref -s --verify refs/heads/master) &&
+ git push --mirror up &&
+ cd ../mirror &&
+ mirror_master=$(git show-ref -s --verify refs/heads/master) &&
+ test "$master_master" = "$mirror_master"
+
+'
+
+test_expect_failure 'push mirror does not remove branches' '
+
+ mk_repo_pair &&
+ cd master &&
+ echo one >foo && git add foo && git commit -m one &&
+ git branch remove master &&
+ git push --mirror up &&
+ git branch -D remove
+ git push --mirror up &&
+ cd ../mirror &&
+ git show-ref -s --verify refs/heads/remove
+
+'
+
+test_expect_success 'push mirror does not add, update and remove together' '
+
+ mk_repo_pair &&
+ cd master &&
+ echo one >foo && git add foo && git commit -m one &&
+ git branch remove master &&
+ git push --mirror up &&
+ git branch -D remove &&
+ git branch add master &&
+ echo two >foo && git add foo && git commit -m two &&
+ master_master=$(git show-ref -s --verify refs/heads/master) &&
+ master_add=$(git show-ref -s --verify refs/heads/add) &&
+ git push --mirror up &&
+ cd ../mirror &&
+ mirror_master=$(git show-ref -s --verify refs/heads/master) &&
+ mirror_add=$(git show-ref -s --verify refs/heads/add) &&
+ test "$master_master" = "$mirror_master" &&
+ test "$master_add" = "$mirror_add" &&
+ ! git show-ref -s --verify refs/heads/remove
+
+'
+
+test_done
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH] tests: git push mirror mode tests V2
2007-11-08 17:01 ` [PATCH 4/4] tests: git push mirror mode tests Andy Whitcroft
@ 2007-11-09 10:21 ` Andy Whitcroft
2007-11-09 14:45 ` [PATCH] tests: git push mirror mode tests V2 -- add tag tests Andy Whitcroft
2007-11-09 20:05 ` [PATCH] tests: git push mirror mode tests V2 Junio C Hamano
0 siblings, 2 replies; 23+ messages in thread
From: Andy Whitcroft @ 2007-11-09 10:21 UTC (permalink / raw)
To: git
Add some basic tests for git push --mirror mode.
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
---
Following the discussion on how tests which change directory
should use subshells to prevent loss of CWD and of how
! is not something we can rely on, here is an updates to
the tests.
---
t/t5517-push-mirror.sh | 125 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 125 insertions(+), 0 deletions(-)
diff --git a/t/t5517-push-mirror.sh b/t/t5517-push-mirror.sh
new file mode 100755
index 0000000..a65d2f5
--- /dev/null
+++ b/t/t5517-push-mirror.sh
@@ -0,0 +1,125 @@
+#!/bin/sh
+
+test_description='pushing to a mirror repository'
+
+. ./test-lib.sh
+
+D=`pwd`
+
+invert () {
+ if "$@"; then
+ return 1
+ else
+ return 0
+ fi
+}
+
+mk_repo_pair () {
+ rm -rf master mirror &&
+ mkdir mirror &&
+ (
+ cd mirror &&
+ git init
+ ) &&
+ mkdir master &&
+ (
+ cd master &&
+ git init &&
+ git config remote.up.url ../mirror
+ )
+}
+
+
+test_expect_success 'push mirror does not create new branches' '
+
+ mk_repo_pair &&
+ (
+ cd master &&
+ echo one >foo && git add foo && git commit -m one &&
+ git push --mirror up
+ ) &&
+ master_master=$(cd master && git show-ref -s --verify refs/heads/master) &&
+ mirror_master=$(cd mirror && git show-ref -s --verify refs/heads/master) &&
+ test "$master_master" = "$mirror_master"
+
+'
+
+test_expect_success 'push mirror does not update existing branches' '
+
+ mk_repo_pair &&
+ (
+ cd master &&
+ echo one >foo && git add foo && git commit -m one &&
+ git push --mirror up &&
+ echo two >foo && git add foo && git commit -m two &&
+ git push --mirror up
+ ) &&
+ master_master=$(cd master && git show-ref -s --verify refs/heads/master) &&
+ mirror_master=$(cd mirror && git show-ref -s --verify refs/heads/master) &&
+ test "$master_master" = "$mirror_master"
+
+'
+
+test_expect_success 'push mirror does not force update existing branches' '
+
+ mk_repo_pair &&
+ (
+ cd master &&
+ echo one >foo && git add foo && git commit -m one &&
+ git push --mirror up &&
+ echo two >foo && git add foo && git commit -m two &&
+ git push --mirror up &&
+ git reset --hard HEAD^
+ git push --mirror up
+ ) &&
+ master_master=$(cd master && git show-ref -s --verify refs/heads/master) &&
+ mirror_master=$(cd mirror && git show-ref -s --verify refs/heads/master) &&
+ test "$master_master" = "$mirror_master"
+
+'
+
+test_expect_success 'push mirror does not remove branches' '
+
+ mk_repo_pair &&
+ (
+ cd master &&
+ echo one >foo && git add foo && git commit -m one &&
+ git branch remove master &&
+ git push --mirror up &&
+ git branch -D remove
+ git push --mirror up
+ ) &&
+ (
+ cd mirror &&
+ invert git show-ref -s --verify refs/heads/remove
+ )
+
+'
+
+test_expect_success 'push mirror does not add, update and remove together' '
+
+ mk_repo_pair &&
+ (
+ cd master &&
+ echo one >foo && git add foo && git commit -m one &&
+ git branch remove master &&
+ git push --mirror up &&
+ git branch -D remove &&
+ git branch add master &&
+ echo two >foo && git add foo && git commit -m two &&
+ git push --mirror up
+ ) &&
+ master_master=$(cd master && git show-ref -s --verify refs/heads/master) &&
+ master_add=$(cd master && git show-ref -s --verify refs/heads/add) &&
+ mirror_master=$(cd mirror && git show-ref -s --verify refs/heads/master) &&
+ mirror_add=$(cd mirror && git show-ref -s --verify refs/heads/add) &&
+ test "$master_master" = "$mirror_master" &&
+ test "$master_add" = "$mirror_add" &&
+ (
+ cd mirror &&
+ invert git show-ref -s --verify refs/heads/remove
+ )
+
+'
+
+test_done
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH] tests: git push mirror mode tests V2 -- add tag tests
2007-11-09 10:21 ` [PATCH] tests: git push mirror mode tests V2 Andy Whitcroft
@ 2007-11-09 14:45 ` Andy Whitcroft
2007-11-09 15:01 ` [PATCH] git-push: add documentation for the newly add --mirror mode Andy Whitcroft
2007-11-09 20:05 ` [PATCH] tests: git push mirror mode tests V2 Junio C Hamano
1 sibling, 1 reply; 23+ messages in thread
From: Andy Whitcroft @ 2007-11-09 14:45 UTC (permalink / raw)
To: git
Add additional tests to the the V2 tests testing the handling of
tags in --mirror mode. We expect these to be tracked in line with
the master.
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
---
Note that this patch is cumulative on top of the following
patch:
tests: git push mirror mode tests V2
These two patches together replace the 4/4 from the original
series.
---
t/t5517-push-mirror.sh | 105 +++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 104 insertions(+), 1 deletions(-)
diff --git a/t/t5517-push-mirror.sh b/t/t5517-push-mirror.sh
index a65d2f5..ec87ce5 100755
--- a/t/t5517-push-mirror.sh
+++ b/t/t5517-push-mirror.sh
@@ -30,6 +30,7 @@ mk_repo_pair () {
}
+# BRANCH tests
test_expect_success 'push mirror does not create new branches' '
mk_repo_pair &&
@@ -96,7 +97,7 @@ test_expect_success 'push mirror does not remove branches' '
'
-test_expect_success 'push mirror does not add, update and remove together' '
+test_expect_success 'push mirror does not add, update and remove branches together' '
mk_repo_pair &&
(
@@ -122,4 +123,106 @@ test_expect_success 'push mirror does not add, update and remove together' '
'
+
+# TAG tests
+test_expect_success 'push mirror does not create new tags' '
+
+ mk_repo_pair &&
+ (
+ cd master &&
+ echo one >foo && git add foo && git commit -m one &&
+ git tag -f tmaster master &&
+ git push --mirror up
+ ) &&
+ master_master=$(cd master && git show-ref -s --verify refs/tags/tmaster) &&
+ mirror_master=$(cd mirror && git show-ref -s --verify refs/tags/tmaster) &&
+ test "$master_master" = "$mirror_master"
+
+'
+
+test_expect_success 'push mirror does not update existing tags' '
+
+ mk_repo_pair &&
+ (
+ cd master &&
+ echo one >foo && git add foo && git commit -m one &&
+ git tag -f tmaster master &&
+ git push --mirror up &&
+ echo two >foo && git add foo && git commit -m two &&
+ git tag -f tmaster master &&
+ git push --mirror up
+ ) &&
+ master_master=$(cd master && git show-ref -s --verify refs/tags/tmaster) &&
+ mirror_master=$(cd mirror && git show-ref -s --verify refs/tags/tmaster) &&
+ test "$master_master" = "$mirror_master"
+
+'
+
+test_expect_success 'push mirror does not force update existing tags' '
+
+ mk_repo_pair &&
+ (
+ cd master &&
+ echo one >foo && git add foo && git commit -m one &&
+ git tag -f tmaster master &&
+ git push --mirror up &&
+ echo two >foo && git add foo && git commit -m two &&
+ git tag -f tmaster master &&
+ git push --mirror up &&
+ git reset --hard HEAD^
+ git tag -f tmaster master &&
+ git push --mirror up
+ ) &&
+ master_master=$(cd master && git show-ref -s --verify refs/tags/tmaster) &&
+ mirror_master=$(cd mirror && git show-ref -s --verify refs/tags/tmaster) &&
+ test "$master_master" = "$mirror_master"
+
+'
+
+test_expect_success 'push mirror does not remove tags' '
+
+ mk_repo_pair &&
+ (
+ cd master &&
+ echo one >foo && git add foo && git commit -m one &&
+ git tag -f tremove master &&
+ git push --mirror up &&
+ git tag -d tremove
+ git push --mirror up
+ ) &&
+ (
+ cd mirror &&
+ invert git show-ref -s --verify refs/tags/tremove
+ )
+
+'
+
+test_expect_success 'push mirror does not add, update and remove tags together' '
+
+ mk_repo_pair &&
+ (
+ cd master &&
+ echo one >foo && git add foo && git commit -m one &&
+ git tag -f tmaster master &&
+ git tag -f tremove master &&
+ git push --mirror up &&
+ git tag -d tremove &&
+ git tag tadd master &&
+ echo two >foo && git add foo && git commit -m two &&
+ git tag -f tmaster master &&
+ git push --mirror up
+ ) &&
+ master_master=$(cd master && git show-ref -s --verify refs/tags/tmaster) &&
+ master_add=$(cd master && git show-ref -s --verify refs/tags/tadd) &&
+ mirror_master=$(cd mirror && git show-ref -s --verify refs/tags/tmaster) &&
+ mirror_add=$(cd mirror && git show-ref -s --verify refs/tags/tadd) &&
+ test "$master_master" = "$mirror_master" &&
+ test "$master_add" = "$mirror_add" &&
+ (
+ cd mirror &&
+ invert git show-ref -s --verify refs/tags/tremove
+ )
+
+'
+
test_done
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH] git-push: add documentation for the newly add --mirror mode
2007-11-09 14:45 ` [PATCH] tests: git push mirror mode tests V2 -- add tag tests Andy Whitcroft
@ 2007-11-09 15:01 ` Andy Whitcroft
0 siblings, 0 replies; 23+ messages in thread
From: Andy Whitcroft @ 2007-11-09 15:01 UTC (permalink / raw)
To: git
Add some basic documentation on the --mirror mode for git-push.
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
---
Documentation/git-push.txt | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index e5dd4c1..2403621 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -62,6 +62,14 @@ the remote repository.
\--all::
Instead of naming each ref to push, specifies that all
refs under `$GIT_DIR/refs/heads/` be pushed.
+
+\--mirror::
+ Instead of naming each ref to push, specifies that all
+ refs under `$GIT_DIR/refs/heads/` and `$GIT_DIR/refs/tags/`
+ be mirrored to the remote repository. Newly created local
+ refs will be pushed to the remote end, locally updated refs
+ will be force updated on the remote end, and deleted refs
+ will be removed from the remote end.
\--dry-run::
Do everything except actually send the updates.
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH] tests: git push mirror mode tests V2
2007-11-09 10:21 ` [PATCH] tests: git push mirror mode tests V2 Andy Whitcroft
2007-11-09 14:45 ` [PATCH] tests: git push mirror mode tests V2 -- add tag tests Andy Whitcroft
@ 2007-11-09 20:05 ` Junio C Hamano
2007-11-12 15:25 ` Andy Whitcroft
1 sibling, 1 reply; 23+ messages in thread
From: Junio C Hamano @ 2007-11-09 20:05 UTC (permalink / raw)
To: Andy Whitcroft; +Cc: git
Andy Whitcroft <apw@shadowen.org> writes:
> +test_expect_success 'push mirror does not create new branches' '
> +
> + mk_repo_pair &&
> + (
> + cd master &&
> + echo one >foo && git add foo && git commit -m one &&
> + git push --mirror up
> + ) &&
> + master_master=$(cd master && git show-ref -s --verify refs/heads/master) &&
> + mirror_master=$(cd mirror && git show-ref -s --verify refs/heads/master) &&
> + test "$master_master" = "$mirror_master"
> +
> +'
I am quite puzzled by this and many other "does not" in the test
description. The --mirror option is advertised as
- newly created will be pushed;
- locally updated will be force pushed;
- locally deleted will be removed.
which makes sense as we do want these things to happen for
"mirrors". Indeed the above updates master branch at the master
repository and makes sure that change is propagated to the
mirror repository. The description should read "push mirror
creates new branches" shouldn't it?
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH] tests: git push mirror mode tests V2
2007-11-09 20:05 ` [PATCH] tests: git push mirror mode tests V2 Junio C Hamano
@ 2007-11-12 15:25 ` Andy Whitcroft
0 siblings, 0 replies; 23+ messages in thread
From: Andy Whitcroft @ 2007-11-12 15:25 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On Fri, Nov 09, 2007 at 12:05:43PM -0800, Junio C Hamano wrote:
> Andy Whitcroft <apw@shadowen.org> writes:
>
> > +test_expect_success 'push mirror does not create new branches' '
> > +
> > + mk_repo_pair &&
> > + (
> > + cd master &&
> > + echo one >foo && git add foo && git commit -m one &&
> > + git push --mirror up
> > + ) &&
> > + master_master=$(cd master && git show-ref -s --verify refs/heads/master) &&
> > + mirror_master=$(cd mirror && git show-ref -s --verify refs/heads/master) &&
> > + test "$master_master" = "$mirror_master"
> > +
> > +'
>
> I am quite puzzled by this and many other "does not" in the test
> description. The --mirror option is advertised as
>
> - newly created will be pushed;
> - locally updated will be force pushed;
> - locally deleted will be removed.
>
> which makes sense as we do want these things to happen for
> "mirrors". Indeed the above updates master branch at the master
> repository and makes sure that change is propagated to the
> mirror repository. The description should read "push mirror
> creates new branches" shouldn't it?
Indeed, I think the problem was a miss-understanding of the example I
copied from. I think partly I thought that the message was only
displayed on failure. Which is firstly demonstrably false, and secondly
I am not consistent in applying that false knowledge.
If these are not already fixed up in pu I will check and sort them out.
-apw
^ permalink raw reply [flat|nested] 23+ messages in thread