Merge branch 'fc/trivial'
authorJunio C Hamano <gitster@pobox.com>
Tue, 17 Dec 2013 19:46:32 +0000 (11:46 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 17 Dec 2013 19:46:32 +0000 (11:46 -0800)
* fc/trivial:
remote: fix status with branch...rebase=preserve
fetch: add missing documentation
t: trivial whitespace cleanups
abspath: trivial style fix

1  2 
Documentation/git-fetch.txt
builtin/remote.c
index 10657134a80bd2cc013c34efeba0645ede368c64,a7b245d946160ab351d7a01792eac653f78643a5..5809aa4eb94e969bf700806b1ef3df504ebcfd2b
@@@ -24,19 -24,22 +24,22 @@@ The ref names and their object names o
  in `.git/FETCH_HEAD`.  This information is left for a later merge
  operation done by 'git merge'.
  
 -When <refspec> stores the fetched result in remote-tracking branches,
 -the tags that point at these branches are automatically
 -followed.  This is done by first fetching from the remote using
 -the given <refspec>s, and if the repository has objects that are
 -pointed by remote tags that it does not yet have, then fetch
 -those missing tags.  If the other end has tags that point at
 -branches you are not interested in, you will not get them.
 +By default, tags are auto-followed.  This means that when fetching
 +from a remote, any tags on the remote that point to objects that exist
 +in the local repository are fetched.  The effect is to fetch tags that
 +point at branches that you are interested in.  This default behavior
 +can be changed by using the --tags or --no-tags options, by
 +configuring remote.<name>.tagopt, or by using a refspec that fetches
 +tags explicitly.
  
  'git fetch' can fetch from either a single named repository,
  or from several repositories at once if <group> is given and
  there is a remotes.<group> entry in the configuration file.
  (See linkgit:git-config[1]).
  
+ When no remote is specified, by default the `origin` remote will be used,
+ unless there's an upstream branch configured for the current branch.
  OPTIONS
  -------
  include::fetch-options.txt[]
diff --combined builtin/remote.c
index f532f354579dc8af7905295a1f3c499e4c18fe11,5e4ab66c26a0a59a7df28fad0d08a3d04368c11a..119e9151ad7fb2a9bcc52d5673a7d51c8d24aacf
@@@ -6,7 -6,6 +6,7 @@@
  #include "strbuf.h"
  #include "run-command.h"
  #include "refs.h"
 +#include "argv-array.h"
  
  static const char * const builtin_remote_usage[] = {
        N_("git remote [-v | --verbose]"),
@@@ -78,6 -77,9 +78,6 @@@ static const char * const builtin_remot
  
  static int verbose;
  
 -static int show_all(void);
 -static int prune_remote(const char *remote, int dry_run);
 -
  static inline int postfixcmp(const char *string, const char *postfix)
  {
        int len1 = strlen(string), len2 = strlen(postfix);
@@@ -307,8 -309,13 +307,13 @@@ static int config_read_branches(const c
                                space = strchr(value, ' ');
                        }
                        string_list_append(&info->merge, xstrdup(value));
-               } else
-                       info->rebase = git_config_bool(orig_key, value);
+               } else {
+                       int v = git_config_maybe_bool(orig_key, value);
+                       if (v >= 0)
+                               info->rebase = v;
+                       else if (!strcmp(value, "preserve"))
+                               info->rebase = 1;
+               }
        }
        return 0;
  }
@@@ -1082,64 -1089,6 +1087,64 @@@ static int show_push_info_item(struct s
        return 0;
  }
  
 +static int get_one_entry(struct remote *remote, void *priv)
 +{
 +      struct string_list *list = priv;
 +      struct strbuf url_buf = STRBUF_INIT;
 +      const char **url;
 +      int i, url_nr;
 +
 +      if (remote->url_nr > 0) {
 +              strbuf_addf(&url_buf, "%s (fetch)", remote->url[0]);
 +              string_list_append(list, remote->name)->util =
 +                              strbuf_detach(&url_buf, NULL);
 +      } else
 +              string_list_append(list, remote->name)->util = NULL;
 +      if (remote->pushurl_nr) {
 +              url = remote->pushurl;
 +              url_nr = remote->pushurl_nr;
 +      } else {
 +              url = remote->url;
 +              url_nr = remote->url_nr;
 +      }
 +      for (i = 0; i < url_nr; i++)
 +      {
 +              strbuf_addf(&url_buf, "%s (push)", url[i]);
 +              string_list_append(list, remote->name)->util =
 +                              strbuf_detach(&url_buf, NULL);
 +      }
 +
 +      return 0;
 +}
 +
 +static int show_all(void)
 +{
 +      struct string_list list = STRING_LIST_INIT_NODUP;
 +      int result;
 +
 +      list.strdup_strings = 1;
 +      result = for_each_remote(get_one_entry, &list);
 +
 +      if (!result) {
 +              int i;
 +
 +              sort_string_list(&list);
 +              for (i = 0; i < list.nr; i++) {
 +                      struct string_list_item *item = list.items + i;
 +                      if (verbose)
 +                              printf("%s\t%s\n", item->string,
 +                                      item->util ? (const char *)item->util : "");
 +                      else {
 +                              if (i && !strcmp((item - 1)->string, item->string))
 +                                      continue;
 +                              printf("%s\n", item->string);
 +                      }
 +              }
 +      }
 +      string_list_clear(&list, 1);
 +      return result;
 +}
 +
  static int show(int argc, const char **argv)
  {
        int no_query = 0, result = 0, query_flag = 0;
@@@ -1302,6 -1251,26 +1307,6 @@@ static int set_head(int argc, const cha
        return result;
  }
  
 -static int prune(int argc, const char **argv)
 -{
 -      int dry_run = 0, result = 0;
 -      struct option options[] = {
 -              OPT__DRY_RUN(&dry_run, N_("dry run")),
 -              OPT_END()
 -      };
 -
 -      argc = parse_options(argc, argv, NULL, options, builtin_remote_prune_usage,
 -                           0);
 -
 -      if (argc < 1)
 -              usage_with_options(builtin_remote_prune_usage, options);
 -
 -      for (; argc; argc--, argv++)
 -              result |= prune_remote(*argv, dry_run);
 -
 -      return result;
 -}
 -
  static int prune_remote(const char *remote, int dry_run)
  {
        int result = 0, i;
        return result;
  }
  
 +static int prune(int argc, const char **argv)
 +{
 +      int dry_run = 0, result = 0;
 +      struct option options[] = {
 +              OPT__DRY_RUN(&dry_run, N_("dry run")),
 +              OPT_END()
 +      };
 +
 +      argc = parse_options(argc, argv, NULL, options, builtin_remote_prune_usage,
 +                           0);
 +
 +      if (argc < 1)
 +              usage_with_options(builtin_remote_prune_usage, options);
 +
 +      for (; argc; argc--, argv++)
 +              result |= prune_remote(*argv, dry_run);
 +
 +      return result;
 +}
 +
  static int get_remote_default(const char *key, const char *value, void *priv)
  {
        if (strcmp(key, "remotes.default") == 0) {
  
  static int update(int argc, const char **argv)
  {
 -      int i, prune = 0;
 +      int i, prune = -1;
        struct option options[] = {
                OPT_BOOL('p', "prune", &prune,
                         N_("prune remotes after fetching")),
                OPT_END()
        };
 -      const char **fetch_argv;
 -      int fetch_argc = 0;
 +      struct argv_array fetch_argv = ARGV_ARRAY_INIT;
        int default_defined = 0;
 -
 -      fetch_argv = xmalloc(sizeof(char *) * (argc+5));
 +      int retval;
  
        argc = parse_options(argc, argv, NULL, options, builtin_remote_update_usage,
                             PARSE_OPT_KEEP_ARGV0);
  
 -      fetch_argv[fetch_argc++] = "fetch";
 +      argv_array_push(&fetch_argv, "fetch");
  
 -      if (prune)
 -              fetch_argv[fetch_argc++] = "--prune";
 +      if (prune != -1)
 +              argv_array_push(&fetch_argv, prune ? "--prune" : "--no-prune");
        if (verbose)
 -              fetch_argv[fetch_argc++] = "-v";
 -      fetch_argv[fetch_argc++] = "--multiple";
 +              argv_array_push(&fetch_argv, "-v");
 +      argv_array_push(&fetch_argv, "--multiple");
        if (argc < 2)
 -              fetch_argv[fetch_argc++] = "default";
 +              argv_array_push(&fetch_argv, "default");
        for (i = 1; i < argc; i++)
 -              fetch_argv[fetch_argc++] = argv[i];
 +              argv_array_push(&fetch_argv, argv[i]);
  
 -      if (strcmp(fetch_argv[fetch_argc-1], "default") == 0) {
 +      if (strcmp(fetch_argv.argv[fetch_argv.argc-1], "default") == 0) {
                git_config(get_remote_default, &default_defined);
 -              if (!default_defined)
 -                      fetch_argv[fetch_argc-1] = "--all";
 +              if (!default_defined) {
 +                      argv_array_pop(&fetch_argv);
 +                      argv_array_push(&fetch_argv, "--all");
 +              }
        }
  
 -      fetch_argv[fetch_argc] = NULL;
 -
 -      return run_command_v_opt(fetch_argv, RUN_GIT_CMD);
 +      retval = run_command_v_opt(fetch_argv.argv, RUN_GIT_CMD);
 +      argv_array_clear(&fetch_argv);
 +      return retval;
  }
  
  static int remove_all_fetch_refspecs(const char *remote, const char *key)
@@@ -1561,6 -1510,64 +1566,6 @@@ static int set_url(int argc, const cha
        return 0;
  }
  
 -static int get_one_entry(struct remote *remote, void *priv)
 -{
 -      struct string_list *list = priv;
 -      struct strbuf url_buf = STRBUF_INIT;
 -      const char **url;
 -      int i, url_nr;
 -
 -      if (remote->url_nr > 0) {
 -              strbuf_addf(&url_buf, "%s (fetch)", remote->url[0]);
 -              string_list_append(list, remote->name)->util =
 -                              strbuf_detach(&url_buf, NULL);
 -      } else
 -              string_list_append(list, remote->name)->util = NULL;
 -      if (remote->pushurl_nr) {
 -              url = remote->pushurl;
 -              url_nr = remote->pushurl_nr;
 -      } else {
 -              url = remote->url;
 -              url_nr = remote->url_nr;
 -      }
 -      for (i = 0; i < url_nr; i++)
 -      {
 -              strbuf_addf(&url_buf, "%s (push)", url[i]);
 -              string_list_append(list, remote->name)->util =
 -                              strbuf_detach(&url_buf, NULL);
 -      }
 -
 -      return 0;
 -}
 -
 -static int show_all(void)
 -{
 -      struct string_list list = STRING_LIST_INIT_NODUP;
 -      int result;
 -
 -      list.strdup_strings = 1;
 -      result = for_each_remote(get_one_entry, &list);
 -
 -      if (!result) {
 -              int i;
 -
 -              sort_string_list(&list);
 -              for (i = 0; i < list.nr; i++) {
 -                      struct string_list_item *item = list.items + i;
 -                      if (verbose)
 -                              printf("%s\t%s\n", item->string,
 -                                      item->util ? (const char *)item->util : "");
 -                      else {
 -                              if (i && !strcmp((item - 1)->string, item->string))
 -                                      continue;
 -                              printf("%s\n", item->string);
 -                      }
 -              }
 -      }
 -      string_list_clear(&list, 1);
 -      return result;
 -}
 -
  int cmd_remote(int argc, const char **argv, const char *prefix)
  {
        struct option options[] = {