Skip to content

Commit

Permalink
Merge branch 'jk/send-pack'
Browse files Browse the repository at this point in the history
* jk/send-pack: (24 commits)
  send-pack: cluster ref status reporting
  send-pack: fix "everything up-to-date" message
  send-pack: tighten remote error reporting
  make "find_ref_by_name" a public function
  Fix warning about bitfield in struct ref
  send-pack: assign remote errors to each ref
  send-pack: check ref->status before updating tracking refs
  send-pack: track errors for each ref
  git-push: add documentation for the newly added --mirror mode
  Add tests for git push'es mirror mode
  Update the tracking references only if they were succesfully updated on remote
  Add a test checking if send-pack updated local tracking branches correctly
  git-push: plumb in --mirror mode
  Teach send-pack a mirror mode
  send-pack: segfault fix on forced push
  Reteach builtin-ls-remote to understand remotes
  send-pack: require --verbose to show update of tracking refs
  receive-pack: don't mention successful updates
  more terse push output
  Build in ls-remote
  ...
  • Loading branch information
gitster committed Nov 25, 2007
2 parents 6c6ea38 + 07f5071 commit fd20079
Show file tree
Hide file tree
Showing 26 changed files with 1,285 additions and 631 deletions.
8 changes: 8 additions & 0 deletions Documentation/git-push.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ the remote repository.
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.

Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ BASIC_LDFLAGS =
SCRIPT_SH = \
git-bisect.sh git-checkout.sh \
git-clone.sh git-commit.sh \
git-ls-remote.sh \
git-merge-one-file.sh git-mergetool.sh git-parse-remote.sh \
git-pull.sh git-rebase.sh git-rebase--interactive.sh \
git-repack.sh git-request-pull.sh \
Expand Down Expand Up @@ -243,7 +242,7 @@ PROGRAMS = \
git-fast-import$X \
git-daemon$X \
git-merge-index$X git-mktag$X git-mktree$X git-patch-id$X \
git-peek-remote$X git-receive-pack$X \
git-receive-pack$X \
git-send-pack$X git-shell$X \
git-show-index$X \
git-unpack-file$X \
Expand Down Expand Up @@ -350,6 +349,7 @@ BUILTIN_OBJS = \
builtin-log.o \
builtin-ls-files.o \
builtin-ls-tree.o \
builtin-ls-remote.o \
builtin-mailinfo.o \
builtin-mailsplit.o \
builtin-merge-base.o \
Expand All @@ -363,6 +363,7 @@ BUILTIN_OBJS = \
builtin-push.o \
builtin-read-tree.o \
builtin-reflog.o \
builtin-send-pack.o \
builtin-config.o \
builtin-rerere.o \
builtin-reset.o \
Expand Down
10 changes: 5 additions & 5 deletions builtin-fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static void unlock_pack_on_signal(int signo)
}

static void add_merge_config(struct ref **head,
struct ref *remote_refs,
const struct ref *remote_refs,
struct branch *branch,
struct ref ***tail)
{
Expand Down Expand Up @@ -79,7 +79,7 @@ static struct ref *get_ref_map(struct transport *transport,
struct ref *ref_map = NULL;
struct ref **tail = &ref_map;

struct ref *remote_refs = transport_get_remote_refs(transport);
const struct ref *remote_refs = transport_get_remote_refs(transport);

if (ref_count || tags) {
for (i = 0; i < ref_count; i++) {
Expand Down Expand Up @@ -424,12 +424,12 @@ static struct ref *find_non_local_tags(struct transport *transport,
struct path_list new_refs = { NULL, 0, 0, 1 };
char *ref_name;
int ref_name_len;
unsigned char *ref_sha1;
struct ref *tag_ref;
const unsigned char *ref_sha1;
const struct ref *tag_ref;
struct ref *rm = NULL;
struct ref *ref_map = NULL;
struct ref **tail = &ref_map;
struct ref *ref;
const struct ref *ref;

for_each_ref(add_existing, &existing_refs);
for (ref = transport_get_remote_refs(transport); ref; ref = ref->next) {
Expand Down
74 changes: 74 additions & 0 deletions builtin-ls-remote.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#include "builtin.h"
#include "cache.h"
#include "transport.h"
#include "remote.h"

static const char ls_remote_usage[] =
"git-ls-remote [--upload-pack=<git-upload-pack>] [<host>:]<directory>";

int cmd_ls_remote(int argc, const char **argv, const char *prefix)
{
int i;
const char *dest = NULL;
int nongit = 0;
unsigned flags = 0;
const char *uploadpack = NULL;

struct remote *remote;
struct transport *transport;
const struct ref *ref;

setup_git_directory_gently(&nongit);

for (i = 1; i < argc; i++) {
const char *arg = argv[i];

if (*arg == '-') {
if (!prefixcmp(arg, "--upload-pack=")) {
uploadpack = arg + 14;
continue;
}
if (!prefixcmp(arg, "--exec=")) {
uploadpack = arg + 7;
continue;
}
if (!strcmp("--tags", arg)) {
flags |= REF_TAGS;
continue;
}
if (!strcmp("--heads", arg)) {
flags |= REF_HEADS;
continue;
}
if (!strcmp("--refs", arg)) {
flags |= REF_NORMAL;
continue;
}
usage(ls_remote_usage);
}
dest = arg;
break;
}

if (!dest || i != argc - 1)
usage(ls_remote_usage);

remote = nongit ? NULL : remote_get(dest);
if (remote && !remote->url_nr)
die("remote %s has no configured URL", dest);
transport = transport_get(remote, remote ? remote->url[0] : dest);
if (uploadpack != NULL)
transport_set_option(transport, TRANS_OPT_UPLOADPACK, uploadpack);

ref = transport_get_remote_refs(transport);

if (!ref)
return 1;

while (ref) {
if (check_ref_type(ref, flags))
printf("%s %s\n", sha1_to_hex(ref->old_sha1), ref->name);
ref = ref->next;
}
return 0;
}
14 changes: 12 additions & 2 deletions builtin-push.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down Expand Up @@ -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;
Expand All @@ -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"),
Expand All @@ -121,13 +123,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);
}
Loading

0 comments on commit fd20079

Please sign in to comment.