Merge branch 'da/styles'
authorJunio C Hamano <gitster@pobox.com>
Fri, 19 Sep 2014 18:38:35 +0000 (11:38 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 19 Sep 2014 18:38:35 +0000 (11:38 -0700)
* da/styles:
stylefix: asterisks stick to the variable, not the type

1  2 
builtin/clone.c
commit.c
commit.h
refs.h
remote-curl.c
diff --combined builtin/clone.c
index dd4092b0509eb9f284118c001d8451a633f9ef7c,315969d4e75488adae20e677e6ff4038191eb7f1..3927edfb6ede269929dc704cbb928a7516a8a0a7
@@@ -685,9 -685,10 +685,10 @@@ static void write_config(struct string_
        }
  }
  
- static void write_refspec_config(const char* src_ref_prefix,
-               const struct ref* our_head_points_at,
-               const struct ref* remote_head_points_at, struct strbuf* branch_top)
+ static void write_refspec_config(const char *src_ref_prefix,
+               const struct ref *our_head_points_at,
+               const struct ref *remote_head_points_at,
+               struct strbuf *branch_top)
  {
        struct strbuf key = STRBUF_INIT;
        struct strbuf value = STRBUF_INIT;
@@@ -1004,7 -1005,5 +1005,7 @@@ int cmd_clone(int argc, const char **ar
        strbuf_release(&key);
        strbuf_release(&value);
        junk_mode = JUNK_LEAVE_ALL;
 +
 +      free(refspec);
        return err;
  }
diff --combined commit.c
index 9416d842c6e870713fb183c66a785cb887661c0a,4de6be4107c010f4bebeba5d1ce71bf269374d6d..9c4439fed61c3b26d493d0f0306b65a471da9b19
+++ b/commit.c
@@@ -584,19 -584,25 +584,19 @@@ define_commit_slab(author_date_slab, un
  static void record_author_date(struct author_date_slab *author_date,
                               struct commit *commit)
  {
 -      const char *buf, *line_end, *ident_line;
        const char *buffer = get_commit_buffer(commit, NULL);
        struct ident_split ident;
 +      const char *ident_line;
 +      size_t ident_len;
        char *date_end;
        unsigned long date;
  
 -      for (buf = buffer; buf; buf = line_end + 1) {
 -              line_end = strchrnul(buf, '\n');
 -              if (!skip_prefix(buf, "author ", &ident_line)) {
 -                      if (!line_end[0] || line_end[1] == '\n')
 -                              return; /* end of header */
 -                      continue;
 -              }
 -              if (split_ident_line(&ident,
 -                                   ident_line, line_end - ident_line) ||
 -                  !ident.date_begin || !ident.date_end)
 -                      goto fail_exit; /* malformed "author" line */
 -              break;
 -      }
 +      ident_line = find_commit_header(buffer, "author", &ident_len);
 +      if (!ident_line)
 +              goto fail_exit; /* no author line */
 +      if (split_ident_line(&ident, ident_line, ident_len) ||
 +          !ident.date_begin || !ident.date_end)
 +              goto fail_exit; /* malformed "author" line */
  
        date = strtoul(ident.date_begin, &date_end, 10);
        if (date_end != ident.date_end)
@@@ -1250,7 -1256,7 +1250,7 @@@ static void parse_gpg_output(struct sig
        }
  }
  
- void check_commit_signature(const struct commitcommit, struct signature_check *sigc)
+ void check_commit_signature(const struct commit *commit, struct signature_check *sigc)
  {
        struct strbuf payload = STRBUF_INIT;
        struct strbuf signature = STRBUF_INIT;
@@@ -1654,25 -1660,3 +1654,25 @@@ void print_commit_list(struct commit_li
                printf(format, sha1_to_hex(list->item->object.sha1));
        }
  }
 +
 +const char *find_commit_header(const char *msg, const char *key, size_t *out_len)
 +{
 +      int key_len = strlen(key);
 +      const char *line = msg;
 +
 +      while (line) {
 +              const char *eol = strchrnul(line, '\n');
 +
 +              if (line == eol)
 +                      return NULL;
 +
 +              if (eol - line > key_len &&
 +                  !strncmp(line, key, key_len) &&
 +                  line[key_len] == ' ') {
 +                      *out_len = eol - line - key_len - 1;
 +                      return line + key_len + 1;
 +              }
 +              line = *eol ? eol + 1 : NULL;
 +      }
 +      return NULL;
 +}
diff --combined commit.h
index 470c74569fc64bc879955362b8996c6f4d616b31,268c9d7cac9729486f06721676a749b82176da6e..bc68ccbe691a28ed9b22fa935c78d2e9640347ea
+++ b/commit.h
@@@ -26,25 -26,13 +26,25 @@@ extern int save_commit_buffer
  extern const char *commit_type;
  
  /* While we can decorate any object with a name, it's only used for commits.. */
 -extern struct decoration name_decoration;
  struct name_decoration {
        struct name_decoration *next;
        int type;
 -      char name[1];
 +      char name[FLEX_ARRAY];
  };
  
 +enum decoration_type {
 +      DECORATION_NONE = 0,
 +      DECORATION_REF_LOCAL,
 +      DECORATION_REF_REMOTE,
 +      DECORATION_REF_TAG,
 +      DECORATION_REF_STASH,
 +      DECORATION_REF_HEAD,
 +      DECORATION_GRAFTED,
 +};
 +
 +void add_name_decoration(enum decoration_type type, const char *name, struct object *obj);
 +const struct name_decoration *get_name_decoration(const struct object *obj);
 +
  struct commit *lookup_commit(const unsigned char *sha1);
  struct commit *lookup_commit_reference(const unsigned char *sha1);
  struct commit *lookup_commit_reference_gently(const unsigned char *sha1,
@@@ -171,7 -159,6 +171,7 @@@ extern void get_commit_format(const cha
  extern const char *format_subject(struct strbuf *sb, const char *msg,
                                  const char *line_separator);
  extern void userformat_find_requirements(const char *fmt, struct userformat_want *w);
 +extern int commit_format_is_empty(enum cmit_fmt);
  extern void format_commit_message(const struct commit *commit,
                                  const char *format, struct strbuf *sb,
                                  const struct pretty_print_context *context);
@@@ -326,17 -313,6 +326,17 @@@ extern struct commit_extra_header *read
  
  extern void free_commit_extra_headers(struct commit_extra_header *extra);
  
 +/*
 + * Search the commit object contents given by "msg" for the header "key".
 + * Returns a pointer to the start of the header contents, or NULL. The length
 + * of the header, up to the first newline, is returned via out_len.
 + *
 + * Note that some headers (like mergetag) may be multi-line. It is the caller's
 + * responsibility to parse further in this case!
 + */
 +extern const char *find_commit_header(const char *msg, const char *key,
 +                                    size_t *out_len);
 +
  typedef void (*each_mergetag_fn)(struct commit *commit, struct commit_extra_header *extra,
                                 void *cb_data);
  
@@@ -370,7 -346,7 +370,7 @@@ extern void print_commit_list(struct co
   * at all.  This may allocate memory for sig->gpg_output, sig->gpg_status,
   * sig->signer and sig->key.
   */
- extern void check_commit_signature(const struct commitcommit, struct signature_check *sigc);
+ extern void check_commit_signature(const struct commit *commit, struct signature_check *sigc);
  
  int compare_commits_by_commit_date(const void *a_, const void *b_, void *unused);
  
diff --combined refs.h
index 68c57701646f05a44dd0da95d981787653ae032d,00f209a138f066ff1b404164ed9d754ea276f50f..10fc3a2634409571d38a1322b9853547d216945b
--- 1/refs.h
--- 2/refs.h
+++ b/refs.h
@@@ -10,38 -10,6 +10,38 @@@ struct ref_lock 
        int force_write;
  };
  
 +/*
 + * A ref_transaction represents a collection of ref updates
 + * that should succeed or fail together.
 + *
 + * Calling sequence
 + * ----------------
 + * - Allocate and initialize a `struct ref_transaction` by calling
 + *   `ref_transaction_begin()`.
 + *
 + * - List intended ref updates by calling functions like
 + *   `ref_transaction_update()` and `ref_transaction_create()`.
 + *
 + * - Call `ref_transaction_commit()` to execute the transaction.
 + *   If this succeeds, the ref updates will have taken place and
 + *   the transaction cannot be rolled back.
 + *
 + * - At any time call `ref_transaction_free()` to discard the
 + *   transaction and free associated resources.  In particular,
 + *   this rolls back the transaction if it has not been
 + *   successfully committed.
 + *
 + * Error handling
 + * --------------
 + *
 + * On error, transaction functions append a message about what
 + * went wrong to the 'err' argument.  The message mentions what
 + * ref was being updated (if any) when the error occurred so it
 + * can be passed to 'die' or 'error' as-is.
 + *
 + * The message is appended to err without first clearing err.
 + * err will not be '\n' terminated.
 + */
  struct ref_transaction;
  
  /*
@@@ -109,7 -77,7 +109,7 @@@ static inline const char *has_glob_spec
  extern int for_each_rawref(each_ref_fn, void *);
  
  extern void warn_dangling_symref(FILE *fp, const char *msg_fmt, const char *refname);
- extern void warn_dangling_symrefs(FILE *fp, const char *msg_fmt, const struct string_listrefnames);
+ extern void warn_dangling_symrefs(FILE *fp, const char *msg_fmt, const struct string_list *refnames);
  
  /*
   * Lock the packed-refs file for writing.  Flags is passed to
@@@ -173,17 -141,14 +173,17 @@@ extern int is_branch(const char *refnam
  extern int peel_ref(const char *refname, unsigned char *sha1);
  
  /*
 - * Locks a "refs/" ref returning the lock on success and NULL on failure.
 - * On failure errno is set to something meaningful.
 + * Flags controlling lock_any_ref_for_update(), ref_transaction_update(),
 + * ref_transaction_create(), etc.
 + * REF_NODEREF: act on the ref directly, instead of dereferencing
 + *              symbolic references.
 + *
 + * Flags >= 0x100 are reserved for internal use.
   */
 -extern struct ref_lock *lock_ref_sha1(const char *refname, const unsigned char *old_sha1);
 -
 -/** Locks any ref (for 'HEAD' type refs). */
  #define REF_NODEREF   0x01
 -/* errno is set to something meaningful on failure */
 +/*
 + * This function sets errno to something meaningful on failure.
 + */
  extern struct ref_lock *lock_any_ref_for_update(const char *refname,
                                                const unsigned char *old_sha1,
                                                int flags, int *type_p);
@@@ -267,7 -232,7 +267,7 @@@ enum action_on_err 
   * Begin a reference transaction.  The reference transaction must
   * be freed by calling ref_transaction_free().
   */
 -struct ref_transaction *ref_transaction_begin(void);
 +struct ref_transaction *ref_transaction_begin(struct strbuf *err);
  
  /*
   * The following functions add a reference check or update to a
   * it must not have existed beforehand.
   * Function returns 0 on success and non-zero on failure. A failure to update
   * means that the transaction as a whole has failed and will need to be
 - * rolled back. On failure the err buffer will be updated.
 + * rolled back.
   */
  int ref_transaction_update(struct ref_transaction *transaction,
                           const char *refname,
   * that the reference should have after the update; it must not be the
   * null SHA-1.  It is verified that the reference does not exist
   * already.
 + * Function returns 0 on success and non-zero on failure. A failure to create
 + * means that the transaction as a whole has failed and will need to be
 + * rolled back.
   */
 -void ref_transaction_create(struct ref_transaction *transaction,
 -                          const char *refname,
 -                          const unsigned char *new_sha1,
 -                          int flags);
 +int ref_transaction_create(struct ref_transaction *transaction,
 +                         const char *refname,
 +                         const unsigned char *new_sha1,
 +                         int flags,
 +                         struct strbuf *err);
  
  /*
   * Add a reference deletion to transaction.  If have_old is true, then
   * old_sha1 holds the value that the reference should have had before
   * the update (which must not be the null SHA-1).
 + * Function returns 0 on success and non-zero on failure. A failure to delete
 + * means that the transaction as a whole has failed and will need to be
 + * rolled back.
   */
 -void ref_transaction_delete(struct ref_transaction *transaction,
 -                          const char *refname,
 -                          const unsigned char *old_sha1,
 -                          int flags, int have_old);
 +int ref_transaction_delete(struct ref_transaction *transaction,
 +                         const char *refname,
 +                         const unsigned char *old_sha1,
 +                         int flags, int have_old,
 +                         struct strbuf *err);
  
  /*
   * Commit all of the changes that have been queued in transaction, as
   * atomically as possible.  Return a nonzero value if there is a
   * problem.
 - * If err is non-NULL we will add an error string to it to explain why
 - * the transaction failed. The string does not end in newline.
   */
  int ref_transaction_commit(struct ref_transaction *transaction,
                           const char *msg, struct strbuf *err);
diff --combined remote-curl.c
index 645872a4f204a51e915eecdf951613ac09277e8b,d2229e0efd2a3d7236a24a2a948be87ad09ee5ae..cd626d15e59832e6fee74b2ca845a23a5fce77ee
@@@ -221,7 -221,7 +221,7 @@@ static int show_http_message(struct str
        return 0;
  }
  
- static struct discoverydiscover_refs(const char *service, int for_push)
+ static struct discovery *discover_refs(const char *service, int for_push)
  {
        struct strbuf exp = STRBUF_INIT;
        struct strbuf type = STRBUF_INIT;
@@@ -623,9 -623,10 +623,9 @@@ static int rpc_service(struct rpc_stat
        const char *svc = rpc->service_name;
        struct strbuf buf = STRBUF_INIT;
        struct strbuf *preamble = rpc->stdin_preamble;
 -      struct child_process client;
 +      struct child_process client = CHILD_PROCESS_INIT;
        int err = 0;
  
 -      memset(&client, 0, sizeof(client));
        client.in = -1;
        client.out = -1;
        client.git_cmd = 1;
@@@ -862,7 -863,6 +862,7 @@@ static int push_git(struct discovery *h
        int i, err;
        struct argv_array args;
        struct string_list_item *cas_option;
 +      struct strbuf preamble = STRBUF_INIT;
  
        argv_array_init(&args);
        argv_array_pushl(&args, "send-pack", "--stateless-rpc", "--helper-status",
        for_each_string_list_item(cas_option, &cas_options)
                argv_array_push(&args, cas_option->string);
        argv_array_push(&args, url.buf);
 +
 +      argv_array_push(&args, "--stdin");
        for (i = 0; i < nr_spec; i++)
 -              argv_array_push(&args, specs[i]);
 +              packet_buf_write(&preamble, "%s\n", specs[i]);
 +      packet_buf_flush(&preamble);
  
        memset(&rpc, 0, sizeof(rpc));
        rpc.service_name = "git-receive-pack",
        rpc.argv = args.argv;
 +      rpc.stdin_preamble = &preamble;
  
        err = rpc_service(&rpc, heads);
        if (rpc.result.len)
                write_or_die(1, rpc.result.buf, rpc.result.len);
        strbuf_release(&rpc.result);
 +      strbuf_release(&preamble);
        argv_array_clear(&args);
        return err;
  }