Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Fri, 22 Jul 2011 20:58:46 +0000 (13:58 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 22 Jul 2011 20:58:46 +0000 (13:58 -0700)
* maint:
doc/fast-import: clarify notemodify command
Documentation: minor grammatical fix in rev-list-options.txt
Documentation: git-filter-branch honors replacement refs
remote-curl: Add a format check to parsing of info/refs
git-config: Remove extra whitespaces

1  2 
Documentation/rev-list-options.txt
config.c
remote-curl.c
index 554ab8c88bdef6bb64ba9496295b563083657077,62340a5e4c3751000208cee289c0e4341f5c046c..39e62072691d408519ff377cb6e91e8d95175ec4
@@@ -272,7 -272,7 +272,7 @@@ Default mode:
  
  --full-history::
  
-       As the default mode but does not prune some history.
+       Same as the default mode, but does not prune some history.
  
  --dense::
  
@@@ -313,7 -313,7 +313,7 @@@ that you are filtering for a file `foo
         \   /   /   /   /
          `-------------'
  -----------------------------------------------------------------------
 -The horizontal line of history A--P is taken to be the first parent of
 +The horizontal line of history A---P is taken to be the first parent of
  each merge.  The commits are:
  
  * `I` is the initial commit, in which `foo` exists with contents
diff --combined config.c
index 6b61a849d26c7a35f57d74c9d5f0adbb1f85c72d,113723bf3b069ed907cd71831ddff91a0ed113da..e42c59b190986d28ec535861e08b843739356b9a
+++ b/config.c
  
  #define MAXNAME (256)
  
 -static FILE *config_file;
 -static const char *config_file_name;
 -static int config_linenr;
 -static int config_file_eof;
 +typedef struct config_file {
 +      struct config_file *prev;
 +      FILE *f;
 +      const char *name;
 +      int linenr;
 +      int eof;
 +      struct strbuf value;
 +      char var[MAXNAME];
 +} config_file;
 +
 +static config_file *cf;
 +
  static int zlib_compression_seen;
  
  const char *config_exclusive_filename = NULL;
@@@ -47,13 -39,13 +47,13 @@@ void git_config_push_parameter(const ch
        strbuf_release(&env);
  }
  
 -static int git_config_parse_parameter(const char *text,
 -                                    config_fn_t fn, void *data)
 +int git_config_parse_parameter(const char *text,
 +                             config_fn_t fn, void *data)
  {
 -      struct strbuf tmp = STRBUF_INIT;
        struct strbuf **pair;
 -      strbuf_addstr(&tmp, text);
 -      pair = strbuf_split(&tmp, '=');
 +      pair = strbuf_split_str(text, '=', 2);
 +      if (!pair[0])
 +              return error("bogus config parameter: %s", text);
        if (pair[0]->len && pair[0]->buf[pair[0]->len - 1] == '=')
                strbuf_setlen(pair[0], pair[0]->len - 1);
        strbuf_trim(pair[0]);
@@@ -107,7 -99,7 +107,7 @@@ static int get_next_char(void
        FILE *f;
  
        c = '\n';
 -      if ((f = config_file) != NULL) {
 +      if (cf && ((f = cf->f) != NULL)) {
                c = fgetc(f);
                if (c == '\r') {
                        /* DOS like systems */
                        }
                }
                if (c == '\n')
 -                      config_linenr++;
 +                      cf->linenr++;
                if (c == EOF) {
 -                      config_file_eof = 1;
 +                      cf->eof = 1;
                        c = '\n';
                }
        }
  
  static char *parse_value(void)
  {
 -      static struct strbuf value = STRBUF_INIT;
        int quote = 0, comment = 0, space = 0;
  
 -      strbuf_reset(&value);
 +      strbuf_reset(&cf->value);
        for (;;) {
                int c = get_next_char();
                if (c == '\n') {
                        if (quote)
                                return NULL;
 -                      return value.buf;
 +                      return cf->value.buf;
                }
                if (comment)
                        continue;
                if (isspace(c) && !quote) {
 -                      if (value.len)
 +                      if (cf->value.len)
                                space++;
                        continue;
                }
                        }
                }
                for (; space; space--)
 -                      strbuf_addch(&value, ' ');
 +                      strbuf_addch(&cf->value, ' ');
                if (c == '\\') {
                        c = get_next_char();
                        switch (c) {
                        default:
                                return NULL;
                        }
 -                      strbuf_addch(&value, c);
 +                      strbuf_addch(&cf->value, c);
                        continue;
                }
                if (c == '"') {
                        quote = 1-quote;
                        continue;
                }
 -              strbuf_addch(&value, c);
 +              strbuf_addch(&cf->value, c);
        }
  }
  
@@@ -199,7 -192,7 +199,7 @@@ static int get_value(config_fn_t fn, vo
        /* Get the full name */
        for (;;) {
                c = get_next_char();
 -              if (config_file_eof)
 +              if (cf->eof)
                        break;
                if (!iskeychar(c))
                        break;
@@@ -263,7 -256,7 +263,7 @@@ static int get_base_var(char *name
  
        for (;;) {
                int c = get_next_char();
 -              if (config_file_eof)
 +              if (cf->eof)
                        return -1;
                if (c == ']')
                        return baselen;
@@@ -281,7 -274,7 +281,7 @@@ static int git_parse_file(config_fn_t f
  {
        int comment = 0;
        int baselen = 0;
 -      static char var[MAXNAME];
 +      char *var = cf->var;
  
        /* U+FEFF Byte Order Mark in UTF8 */
        static const unsigned char *utf8_bom = (unsigned char *) "\xef\xbb\xbf";
                        }
                }
                if (c == '\n') {
 -                      if (config_file_eof)
 +                      if (cf->eof)
                                return 0;
                        comment = 0;
                        continue;
                if (get_value(fn, data, var, baselen+1) < 0)
                        break;
        }
 -      die("bad config file line %d in %s", config_linenr, config_file_name);
 +      die("bad config file line %d in %s", cf->linenr, cf->name);
  }
  
  static int parse_unit_factor(const char *end, unsigned long *val)
@@@ -381,8 -374,8 +381,8 @@@ int git_parse_ulong(const char *value, 
  
  static void die_bad_config(const char *name)
  {
 -      if (config_file_name)
 -              die("bad config value for '%s' in %s", name, config_file_name);
 +      if (cf && cf->name)
 +              die("bad config value for '%s' in %s", name, cf->name);
        die("bad config value for '%s'", name);
  }
  
@@@ -802,24 -795,13 +802,24 @@@ int git_config_from_file(config_fn_t fn
  
        ret = -1;
        if (f) {
 -              config_file = f;
 -              config_file_name = filename;
 -              config_linenr = 1;
 -              config_file_eof = 0;
 +              config_file top;
 +
 +              /* push config-file parsing state stack */
 +              top.prev = cf;
 +              top.f = f;
 +              top.name = filename;
 +              top.linenr = 1;
 +              top.eof = 0;
 +              strbuf_init(&top.value, 1024);
 +              cf = &top;
 +
                ret = git_parse_file(fn, data);
 +
 +              /* pop config-file parsing state stack */
 +              strbuf_release(&top.value);
 +              cf = top.prev;
 +
                fclose(f);
 -              config_file_name = NULL;
        }
        return ret;
  }
@@@ -874,7 -856,7 +874,7 @@@ int git_config_early(config_fn_t fn, vo
  
        switch (git_config_from_parameters(fn, data)) {
        case -1: /* error */
 -              ret--;
 +              die("unable to parse command-line config");
                break;
        case 0: /* found nothing */
                break;
@@@ -927,7 -909,6 +927,7 @@@ static int store_aux(const char *key, c
  {
        const char *ep;
        size_t section_len;
 +      FILE *f = cf->f;
  
        switch (store.state) {
        case KEY_SEEN:
                                return 1;
                        }
  
 -                      store.offset[store.seen] = ftell(config_file);
 +                      store.offset[store.seen] = ftell(f);
                        store.seen++;
                }
                break;
                 * Do not increment matches: this is no match, but we
                 * just made sure we are in the desired section.
                 */
 -              store.offset[store.seen] = ftell(config_file);
 +              store.offset[store.seen] = ftell(f);
                /* fallthru */
        case SECTION_END_SEEN:
        case START:
                if (matches(key, value)) {
 -                      store.offset[store.seen] = ftell(config_file);
 +                      store.offset[store.seen] = ftell(f);
                        store.state = KEY_SEEN;
                        store.seen++;
                } else {
                        if (strrchr(key, '.') - key == store.baselen &&
                              !strncmp(key, store.key, store.baselen)) {
                                        store.state = SECTION_SEEN;
 -                                      store.offset[store.seen] = ftell(config_file);
 +                                      store.offset[store.seen] = ftell(f);
                        }
                }
        }
@@@ -1434,7 -1415,6 +1434,7 @@@ int git_config_rename_section(const cha
        struct lock_file *lock = xcalloc(sizeof(struct lock_file), 1);
        int out_fd;
        char buf[1024];
 +      FILE *config_file;
  
        if (config_exclusive_filename)
                config_filename = xstrdup(config_exclusive_filename);
                }
        }
        fclose(config_file);
 unlock_and_out:
+ unlock_and_out:
        if (commit_lock_file(lock) < 0)
                ret = error("could not commit config file %s", config_filename);
 out:
+ out:
        free(config_filename);
        return ret;
  }
diff --combined remote-curl.c
index faaeda44a9225ff56d45e9566cccf1a2278abb27,8ac5028343320b44b75c6945318fe5b328af81fd..69831e931af1fe2a3e668239e8c4bb73a7bfb936
@@@ -227,6 -227,8 +227,8 @@@ static struct ref *parse_info_refs(stru
                if (data[i] == '\t')
                        mid = &data[i];
                if (data[i] == '\n') {
+                       if (mid - start != 40)
+                               die("%sinfo/refs not valid: is this a git repository?", url);
                        data[i] = 0;
                        ref_name = mid + 1;
                        ref = xmalloc(sizeof(struct ref) +
@@@ -471,12 -473,16 +473,12 @@@ static int post_rpc(struct rpc_state *r
                 * the transfer time.
                 */
                size_t size;
 -              z_stream stream;
 +              git_zstream stream;
                int ret;
  
                memset(&stream, 0, sizeof(stream));
 -              ret = deflateInit2(&stream, Z_BEST_COMPRESSION,
 -                              Z_DEFLATED, (15 + 16),
 -                              8, Z_DEFAULT_STRATEGY);
 -              if (ret != Z_OK)
 -                      die("cannot deflate request; zlib init error %d", ret);
 -              size = deflateBound(&stream, rpc->len);
 +              git_deflate_init_gzip(&stream, Z_BEST_COMPRESSION);
 +              size = git_deflate_bound(&stream, rpc->len);
                gzip_body = xmalloc(size);
  
                stream.next_in = (unsigned char *)rpc->buf;
                stream.next_out = (unsigned char *)gzip_body;
                stream.avail_out = size;
  
 -              ret = deflate(&stream, Z_FINISH);
 +              ret = git_deflate(&stream, Z_FINISH);
                if (ret != Z_STREAM_END)
                        die("cannot deflate request; zlib deflate error %d", ret);
  
 -              ret = deflateEnd(&stream);
 +              ret = git_deflate_end_gently(&stream);
                if (ret != Z_OK)
                        die("cannot deflate request; zlib end error %d", ret);