Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Wed, 12 Aug 2009 23:36:04 +0000 (16:36 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 12 Aug 2009 23:36:04 +0000 (16:36 -0700)
* maint:
push: point to 'git pull' and 'git push --force' in case of non-fast forward
Documentation: add: <filepattern>... is optional
Change mentions of "git programs" to "git commands"
Documentation: merge: one <remote> is required
help.c: give correct structure's size to memset()

1  2 
Documentation/config.txt
Documentation/git-rev-list.txt
builtin-push.c
transport.c
transport.h
diff --combined Documentation/config.txt
index 7791c32bc3461d7fcc73001165492b84c0997f06,e94a8ab746293f47046babe4ed48201e8016f0ee..2632c5149e380dd9d07b38803614b42db99f2658
@@@ -605,7 -605,7 +605,7 @@@ color.interactive.<slot>:
        Use customized color for 'git-add --interactive'
        output. `<slot>` may be `prompt`, `header`, `help` or `error`, for
        four distinct types of normal output from interactive
-       programs.  The values of these variables may be specified as
+       commands.  The values of these variables may be specified as
        in color.branch.<slot>.
  
  color.pager::
@@@ -1113,7 -1113,7 +1113,7 @@@ instaweb.port:
        linkgit:git-instaweb[1].
  
  interactive.singlekey::
-       In interactive programs, allow the user to provide one-letter
+       In interactive commands, allow the user to provide one-letter
        input with a single key (i.e., without hitting enter).
        Currently this is used only by the `\--patch` mode of
        linkgit:git-add[1].  Note that this setting is silently
@@@ -1218,20 -1218,12 +1218,20 @@@ pack.compression:
  
  pack.deltaCacheSize::
        The maximum memory in bytes used for caching deltas in
 -      linkgit:git-pack-objects[1].
 -      A value of 0 means no limit. Defaults to 0.
 +      linkgit:git-pack-objects[1] before writing them out to a pack.
 +      This cache is used to speed up the writing object phase by not
 +      having to recompute the final delta result once the best match
 +      for all objects is found.  Repacking large repositories on machines
 +      which are tight with memory might be badly impacted by this though,
 +      especially if this cache pushes the system into swapping.
 +      A value of 0 means no limit. The smallest size of 1 byte may be
 +      used to virtually disable this cache. Defaults to 256 MiB.
  
  pack.deltaCacheLimit::
        The maximum size of a delta, that is cached in
 -      linkgit:git-pack-objects[1]. Defaults to 1000.
 +      linkgit:git-pack-objects[1]. This cache is used to speed up the
 +      writing object phase by not having to recompute the final delta
 +      result once the best match for all objects is found. Defaults to 1000.
  
  pack.threads::
        Specifies the number of threads to spawn when searching for best
index bf98c8449c2cf2d7adef849f0f4fda08427c0487,974d9f527f2efb78c435689d7f8bf2bdc807e88d..3341d1b62f34fa99afcdab91da1191ceacc2c24f
@@@ -51,26 -51,20 +51,26 @@@ SYNOPSI
  DESCRIPTION
  -----------
  
 -Lists commit objects in reverse chronological order starting at the
 -given commit(s), taking ancestry relationship into account.  This is
 -useful to produce human-readable log output.
 +List commits that are reachable by following the `parent` links from the
 +given commit(s), but exclude commits that are reachable from the one(s)
 +given with a '{caret}' in front of them.  The output is given in reverse
 +chronological order by default.
  
 -Commits which are stated with a preceding '{caret}' cause listing to
 -stop at that point. Their parents are implied. Thus the following
 -command:
 +You can think of this as a set operation.  Commits given on the command
 +line form a set of commits that are reachable from any of them, and then
 +commits reachable from any of the ones given with '{caret}' in front are
 +subtracted from that set.  The remaining commits are what comes out in the
 +command's output.  Various other options and paths parameters can be used
 +to further limit the result.
 +
 +Thus, the following command:
  
  -----------------------------------------------------------------------
        $ git rev-list foo bar ^baz
  -----------------------------------------------------------------------
  
 -means "list all the commits which are included in 'foo' and 'bar', but
 -not in 'baz'".
 +means "list all the commits which are reachable from 'foo' or 'bar', but
 +not from 'baz'".
  
  A special notation "'<commit1>'..'<commit2>'" can be used as a
  short-hand for "{caret}'<commit1>' '<commit2>'". For example, either of
@@@ -90,7 -84,7 +90,7 @@@ between the two operands.  The followin
        $ git rev-list A...B
  -----------------------------------------------------------------------
  
- 'git-rev-list' is a very essential git program, since it
+ 'rev-list' is a very essential git command, since it
  provides the ability to build and traverse commit ancestry graphs. For
  this reason, it has a lot of different options that enables it to be
  used by commands as different as 'git-bisect' and
diff --combined builtin-push.c
index bc0c91aa4e4e15a5a88f988d0cea5312bb60e7cd,50328f4b08e6fc69bb80a9649df2065efb0a9b2c..67f6d96fbeb180b6438172207ff5290c7344cc67
@@@ -140,6 -140,7 +140,7 @@@ static int do_push(const char *repo, in
                struct transport *transport =
                        transport_get(remote, url[i]);
                int err;
+               int nonfastforward;
                if (receivepack)
                        transport_set_option(transport,
                                             TRANS_OPT_RECEIVEPACK, receivepack);
  
                if (flags & TRANSPORT_PUSH_VERBOSE)
                        fprintf(stderr, "Pushing to %s\n", url[i]);
-               err = transport_push(transport, refspec_nr, refspec, flags);
+               err = transport_push(transport, refspec_nr, refspec, flags,
+                                    &nonfastforward);
                err |= transport_disconnect(transport);
  
                if (!err)
                        continue;
  
                error("failed to push some refs to '%s'", url[i]);
+               if (nonfastforward) {
+                       printf("To prevent you from losing history, non-fast-forward updates were rejected.\n"
+                              "Merge the remote changes before pushing again.\n"
+                              "See 'non-fast forward' section of 'git push --help' for details.\n");
+               }
                errs++;
        }
        return !!errs;
@@@ -168,7 -175,6 +175,7 @@@ int cmd_push(int argc, const char **arg
        const char *repo = NULL;        /* default repository */
  
        struct option options[] = {
 +              OPT_BIT('q', "quiet", &flags, "be quiet", TRANSPORT_PUSH_QUIET),
                OPT_BIT('v', "verbose", &flags, "be verbose", TRANSPORT_PUSH_VERBOSE),
                OPT_STRING( 0 , "repo", &repo, "repository", "repository"),
                OPT_BIT( 0 , "all", &flags, "push all refs", TRANSPORT_PUSH_ALL),
diff --combined transport.c
index afec5b731aa39f8bf9d647528c1a314bf677a26b,f231b355f24476372c9b89c35a41231a18e45719..faee154c383c9726017f1995121b510f770b655e
@@@ -396,6 -396,7 +396,6 @@@ static int curl_transport_push(struct t
  {
        const char **argv;
        int argc;
 -      int err;
  
        if (flags & TRANSPORT_PUSH_MIRROR)
                return error("http transport does not support mirror mode");
        while (refspec_nr--)
                argv[argc++] = *refspec++;
        argv[argc] = NULL;
 -      err = run_command_v_opt(argv, RUN_GIT_CMD);
 -      switch (err) {
 -      case -ERR_RUN_COMMAND_FORK:
 -              error("unable to fork for %s", argv[0]);
 -      case -ERR_RUN_COMMAND_EXEC:
 -              error("unable to exec %s", argv[0]);
 -              break;
 -      case -ERR_RUN_COMMAND_WAITPID:
 -      case -ERR_RUN_COMMAND_WAITPID_WRONG_PID:
 -      case -ERR_RUN_COMMAND_WAITPID_SIGNAL:
 -      case -ERR_RUN_COMMAND_WAITPID_NOEXIT:
 -              error("%s died with strange error", argv[0]);
 -      }
 -      return !!err;
 +      return !!run_command_v_opt(argv, RUN_GIT_CMD);
  }
  
  static struct ref *get_refs_via_curl(struct transport *transport, int for_push)
@@@ -667,21 -681,6 +667,21 @@@ static int fetch_refs_via_pack(struct t
        return (refs ? 0 : -1);
  }
  
 +static int push_had_errors(struct ref *ref)
 +{
 +      for (; ref; ref = ref->next) {
 +              switch (ref->status) {
 +              case REF_STATUS_NONE:
 +              case REF_STATUS_UPTODATE:
 +              case REF_STATUS_OK:
 +                      break;
 +              default:
 +                      return 1;
 +              }
 +      }
 +      return 0;
 +}
 +
  static int refs_pushed(struct ref *ref)
  {
        for (; ref; ref = ref->next) {
@@@ -821,7 -820,7 +821,7 @@@ static int print_one_push_status(struc
  }
  
  static void print_push_status(const char *dest, struct ref *refs,
-                                                         int verbose, int porcelain)
+                             int verbose, int porcelain, int * nonfastforward)
  {
        struct ref *ref;
        int n = 0;
                if (ref->status == REF_STATUS_OK)
                        n += print_one_push_status(ref, dest, n, porcelain);
  
+       *nonfastforward = 0;
        for (ref = refs; ref; ref = ref->next) {
                if (ref->status != REF_STATUS_NONE &&
                    ref->status != REF_STATUS_UPTODATE &&
                    ref->status != REF_STATUS_OK)
                        n += print_one_push_status(ref, dest, n, porcelain);
+               if (ref->status == REF_STATUS_REJECT_NONFASTFORWARD)
+                       *nonfastforward = 1;
        }
  }
  
@@@ -893,7 -895,6 +896,7 @@@ static int git_transport_push(struct tr
        args.force_update = !!(flags & TRANSPORT_PUSH_FORCE);
        args.use_thin_pack = data->thin;
        args.verbose = !!(flags & TRANSPORT_PUSH_VERBOSE);
 +      args.quiet = !!(flags & TRANSPORT_PUSH_QUIET);
        args.dry_run = !!(flags & TRANSPORT_PUSH_DRY_RUN);
  
        ret = send_pack(&args, data->fd, data->conn, remote_refs,
@@@ -999,7 -1000,8 +1002,8 @@@ int transport_set_option(struct transpo
  }
  
  int transport_push(struct transport *transport,
-                  int refspec_nr, const char **refspec, int flags)
+                  int refspec_nr, const char **refspec, int flags,
+                  int * nonfastforward)
  {
        verify_remote_names(refspec_nr, refspec);
  
                struct ref *local_refs = get_local_heads();
                int match_flags = MATCH_REFS_NONE;
                int verbose = flags & TRANSPORT_PUSH_VERBOSE;
 +              int quiet = flags & TRANSPORT_PUSH_QUIET;
                int porcelain = flags & TRANSPORT_PUSH_PORCELAIN;
                int ret;
  
  
                ret = transport->push_refs(transport, remote_refs, flags);
  
 -              print_push_status(transport->url, remote_refs, verbose | porcelain, porcelain, nonfastforward);
 +              if (!quiet || push_had_errors(remote_refs))
 +                      print_push_status(transport->url, remote_refs,
-                                       verbose | porcelain, porcelain);
++                                      verbose | porcelain, porcelain,
++                                      nonfastforward);
  
                if (!(flags & TRANSPORT_PUSH_DRY_RUN)) {
                        struct ref *ref;
diff --combined transport.h
index f1d3ebf67496926e0da6926e027c005d87758b0d,639f13dcfed434857c724293cf3f3f6b9d4d14ed..171a01c7a322fa2bbbd32bec1d18ab54dbcbc1bb
@@@ -36,7 -36,6 +36,7 @@@ struct transport 
  #define TRANSPORT_PUSH_MIRROR 8
  #define TRANSPORT_PUSH_VERBOSE 16
  #define TRANSPORT_PUSH_PORCELAIN 32
 +#define TRANSPORT_PUSH_QUIET 64
  
  /* Returns a transport suitable for the url */
  struct transport *transport_get(struct remote *, const char *);
@@@ -69,7 -68,8 +69,8 @@@ int transport_set_option(struct transpo
                         const char *value);
  
  int transport_push(struct transport *connection,
-                  int refspec_nr, const char **refspec, int flags);
+                  int refspec_nr, const char **refspec, int flags,
+                  int * nonfastforward);
  
  const struct ref *transport_get_remote_refs(struct transport *transport);