Merge branch 'gb/split-cmdline-errmsg'
authorJunio C Hamano <gitster@pobox.com>
Sun, 22 Aug 2010 06:28:55 +0000 (23:28 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 22 Aug 2010 06:28:55 +0000 (23:28 -0700)
* gb/split-cmdline-errmsg:
split_cmdline: Allow caller to access error string

1  2 
builtin/merge.c
cache.h
git.c
diff --combined builtin/merge.c
index 1bcf7fd9d54c2d65cb27a675c061dc23a16112fa,b48826372f94e8dc48a37c3ff5ea4c727788f92e..47e705ba9b6bb043b28183422d518b65cf513478
@@@ -486,7 -486,8 +486,8 @@@ static int git_merge_config(const char 
                buf = xstrdup(v);
                argc = split_cmdline(buf, &argv);
                if (argc < 0)
-                       die("Bad branch.%s.mergeoptions string", branch);
+                       die("Bad branch.%s.mergeoptions string: %s", branch,
+                           split_cmdline_strerror(argc));
                argv = xrealloc(argv, sizeof(*argv) * (argc + 2));
                memmove(argv + 1, argv, sizeof(*argv) * (argc + 1));
                argc++;
@@@ -704,8 -705,7 +705,8 @@@ int checkout_fast_forward(const unsigne
        opts.verbose_update = 1;
        opts.merge = 1;
        opts.fn = twoway_merge;
 -      opts.msgs = get_porcelain_error_msgs();
 +      opts.show_all_errors = 1;
 +      set_porcelain_error_msgs(opts.msgs, "merge");
  
        trees[nr_trees] = parse_tree_indirect(head);
        if (!trees[nr_trees++])
diff --combined cache.h
index 61a563150f1a6e59d8246e0f613cf5bd8d39a8d4,7466ad04fac5efdfb179177f55e6be3f5cacb466..eb77e1df48814b92e76436ca3184319147192f7d
+++ b/cache.h
@@@ -179,7 -179,8 +179,7 @@@ struct cache_entry 
  #define CE_UNHASHED  (0x200000)
  #define CE_CONFLICTED (0x800000)
  
 -/* Only remove in work directory, not index */
 -#define CE_WT_REMOVE (0x400000)
 +#define CE_WT_REMOVE (0x400000) /* remove in work directory */
  
  #define CE_UNPACKED  (0x1000000)
  
@@@ -448,7 -449,7 +448,7 @@@ extern int init_db(const char *template
                                alloc = alloc_nr(alloc); \
                        x = xrealloc((x), alloc * sizeof(*(x))); \
                } \
 -      } while(0)
 +      } while (0)
  
  /* Initialize and use the cache information */
  extern int read_index(struct index_state *);
@@@ -640,9 -641,6 +640,9 @@@ extern char *git_pathdup(const char *fm
  /* Return a statically allocated filename matching the sha1 signature */
  extern char *mkpath(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
  extern char *git_path(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
 +extern char *git_path_submodule(const char *path, const char *fmt, ...)
 +      __attribute__((format (printf, 2, 3)));
 +
  extern char *sha1_file_name(const unsigned char *sha1);
  extern char *sha1_pack_name(const unsigned char *sha1);
  extern char *sha1_pack_index_name(const unsigned char *sha1);
@@@ -813,7 -811,6 +813,7 @@@ const char *show_date_relative(unsigne
                               char *timebuf,
                               size_t timebuf_size);
  int parse_date(const char *date, char *buf, int bufsize);
 +int parse_date_basic(const char *date, unsigned long *timestamp, int *offset);
  void datestamp(char *buf, int bufsize);
  #define approxidate(s) approxidate_careful((s), NULL)
  unsigned long approxidate_careful(const char *, int *);
@@@ -1099,6 -1096,8 +1099,8 @@@ void overlay_tree_on_cache(const char *
  
  char *alias_lookup(const char *alias);
  int split_cmdline(char *cmdline, const char ***argv);
+ /* Takes a negative value returned by split_cmdline */
+ const char *split_cmdline_strerror(int cmdline_errno);
  
  /* builtin/merge.c */
  int checkout_fast_forward(const unsigned char *from, const unsigned char *to);
diff --combined git.c
index f37028b3b722e6203ae8dac1ccf40a94421597d2,da56f31a673121f2d45806dd089e633d0aa6a462..6fc07a568d34d50745cca26fcaf46bc99bbfceba
--- 1/git.c
--- 2/git.c
+++ b/git.c
@@@ -8,8 -8,8 +8,8 @@@ const char git_usage_string[] 
        "git [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path]\n"
        "           [-p|--paginate|--no-pager] [--no-replace-objects]\n"
        "           [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE]\n"
 -      "           [-c name=value\n"
 -      "           [--help] COMMAND [ARGS]";
 +      "           [-c name=value] [--help]\n"
 +      "           COMMAND [ARGS]";
  
  const char git_more_info_string[] =
        "See 'git help COMMAND' for more information on a specific command.";
@@@ -188,7 -188,8 +188,8 @@@ static int handle_alias(int *argcp, con
                }
                count = split_cmdline(alias_string, &new_argv);
                if (count < 0)
-                       die("Bad alias.%s string", alias_command);
+                       die("Bad alias.%s string: %s", alias_command,
+                           split_cmdline_strerror(count));
                option_count = handle_options(&new_argv, &count, &envchanged);
                if (envchanged)
                        die("alias '%s' changes environment variables\n"