Merge branch 'jk/maint-pass-c-config-in-env'
authorJunio C Hamano <gitster@pobox.com>
Wed, 8 Sep 2010 16:17:00 +0000 (09:17 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 8 Sep 2010 16:17:00 +0000 (09:17 -0700)
* jk/maint-pass-c-config-in-env:
do not pass "git -c foo=bar" params to transport helpers
pass "git -c foo=bar" params through environment

1  2 
cache.h
environment.c
git.c
diff --combined cache.h
index be02a422d199b8269771ddedb4f13378f082e003,016cbe931bf64dea7c1bc6c79078be73265aeafb..abbe08303ec24c07051c5e4f789ba85393868b94
+++ 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)
  
@@@ -378,6 -379,7 +378,7 @@@ static inline enum object_type object_t
  #define GRAFT_ENVIRONMENT "GIT_GRAFT_FILE"
  #define TEMPLATE_DIR_ENVIRONMENT "GIT_TEMPLATE_DIR"
  #define CONFIG_ENVIRONMENT "GIT_CONFIG"
+ #define CONFIG_DATA_ENVIRONMENT "GIT_CONFIG_PARAMETERS"
  #define EXEC_PATH_ENVIRONMENT "GIT_EXEC_PATH"
  #define CEILING_DIRECTORIES_ENVIRONMENT "GIT_CEILING_DIRECTORIES"
  #define NO_REPLACE_OBJECTS_ENVIRONMENT "GIT_NO_REPLACE_OBJECTS"
   * environment creation or simple walk of the list.
   * The number of non-NULL entries is available as a macro.
   */
- #define LOCAL_REPO_ENV_SIZE 8
+ #define LOCAL_REPO_ENV_SIZE 9
  extern const char *const local_repo_env[LOCAL_REPO_ENV_SIZE + 1];
  
  extern int is_bare_repository_cfg;
@@@ -448,7 -450,7 +449,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 -642,6 +641,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 -812,6 +814,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 *);
@@@ -973,7 -971,9 +974,9 @@@ extern int update_server_info(int)
  typedef int (*config_fn_t)(const char *, const char *, void *);
  extern int git_default_config(const char *, const char *, void *);
  extern int git_config_from_file(config_fn_t fn, const char *, void *);
+ extern void git_config_push_parameter(const char *text);
  extern int git_config_parse_parameter(const char *text);
+ extern int git_config_parse_environment(void);
  extern int git_config_from_parameters(config_fn_t fn, void *data);
  extern int git_config(config_fn_t fn, void *);
  extern int git_parse_ulong(const char *, unsigned long *);
@@@ -1057,7 -1057,6 +1060,7 @@@ extern void trace_argv_printf(const cha
  extern int convert_to_git(const char *path, const char *src, size_t len,
                            struct strbuf *dst, enum safe_crlf checksafe);
  extern int convert_to_working_tree(const char *path, const char *src, size_t len, struct strbuf *dst);
 +extern int renormalize_buffer(const char *path, const char *src, size_t len, struct strbuf *dst);
  
  /* add */
  /*
@@@ -1100,14 -1099,6 +1103,14 @@@ 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);
 +
 +/* git.c */
 +struct startup_info {
 +      int have_repository;
 +};
 +extern struct startup_info *startup_info;
  
  /* builtin/merge.c */
  int checkout_fast_forward(const unsigned char *from, const unsigned char *to);
diff --combined environment.c
index eeb26876a181f57fcdf5fd324c06a90c705623dc,a199f6372b286a45c24eaaee1b39cd6460f71280..9425606443241b76afd95aec02a6fa44a5a4b85d
@@@ -53,7 -53,6 +53,7 @@@ enum object_creation_mode object_creati
  char *notes_ref_name;
  int grafts_replace_parents = 1;
  int core_apply_sparse_checkout;
 +struct startup_info *startup_info;
  
  /* Parallel index stat data preload? */
  int core_preload_index = 0;
@@@ -73,6 -72,7 +73,7 @@@ static char *git_object_dir, *git_index
  const char * const local_repo_env[LOCAL_REPO_ENV_SIZE + 1] = {
        ALTERNATE_DB_ENVIRONMENT,
        CONFIG_ENVIRONMENT,
+       CONFIG_DATA_ENVIRONMENT,
        DB_ENVIRONMENT,
        GIT_DIR_ENVIRONMENT,
        GIT_WORK_TREE_ENVIRONMENT,
diff --combined git.c
index 8de48107e0dced316704c1ad78569ccb9eeebb08,e4cd01605764bb39e61e5a867dd1ff26efb05063..d64ab1a24d0c491e032860477e00eb27efc5383a
--- 1/git.c
--- 2/git.c
+++ b/git.c
@@@ -8,13 -8,12 +8,13 @@@ 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.";
  
 +static struct startup_info git_startup_info;
  static int use_pager = -1;
  struct pager_config {
        const char *cmd;
@@@ -137,7 -136,7 +137,7 @@@ static int handle_options(const char **
                                fprintf(stderr, "-c expects a configuration string\n" );
                                usage(git_usage_string);
                        }
-                       git_config_parse_parameter((*argv)[1]);
+                       git_config_push_parameter((*argv)[1]);
                        (*argv)++;
                        (*argc)--;
                } else {
@@@ -189,8 -188,7 +189,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"
  
  const char git_version_string[] = GIT_VERSION;
  
 -#define RUN_SETUP     (1<<0)
 -#define USE_PAGER     (1<<1)
 +#define RUN_SETUP             (1<<0)
 +#define RUN_SETUP_GENTLY      (1<<1)
 +#define USE_PAGER             (1<<2)
  /*
   * require working tree to be present -- anything uses this needs
   * RUN_SETUP for reading from the configuration file.
   */
 -#define NEED_WORK_TREE        (1<<2)
 +#define NEED_WORK_TREE                (1<<3)
  
  struct cmd_struct {
        const char *cmd;
@@@ -257,12 -254,8 +257,12 @@@ static int run_builtin(struct cmd_struc
        if (!help) {
                if (p->option & RUN_SETUP)
                        prefix = setup_git_directory();
 +              if (p->option & RUN_SETUP_GENTLY) {
 +                      int nongit_ok;
 +                      prefix = setup_git_directory_gently(&nongit_ok);
 +              }
  
 -              if (use_pager == -1 && p->option & RUN_SETUP)
 +              if (use_pager == -1 && p->option & (RUN_SETUP | RUN_SETUP_GENTLY))
                        use_pager = check_pager_config(p->cmd);
                if (use_pager == -1 && p->option & USE_PAGER)
                        use_pager = 1;
@@@ -302,12 -295,12 +302,12 @@@ static void handle_internal_command(in
                { "add", cmd_add, RUN_SETUP | NEED_WORK_TREE },
                { "stage", cmd_add, RUN_SETUP | NEED_WORK_TREE },
                { "annotate", cmd_annotate, RUN_SETUP },
 -              { "apply", cmd_apply },
 +              { "apply", cmd_apply, RUN_SETUP_GENTLY },
                { "archive", cmd_archive },
                { "bisect--helper", cmd_bisect__helper, RUN_SETUP | NEED_WORK_TREE },
                { "blame", cmd_blame, RUN_SETUP },
                { "branch", cmd_branch, RUN_SETUP },
 -              { "bundle", cmd_bundle },
 +              { "bundle", cmd_bundle, RUN_SETUP_GENTLY },
                { "cat-file", cmd_cat_file, RUN_SETUP },
                { "checkout", cmd_checkout, RUN_SETUP | NEED_WORK_TREE },
                { "checkout-index", cmd_checkout_index,
                { "clean", cmd_clean, RUN_SETUP | NEED_WORK_TREE },
                { "commit", cmd_commit, RUN_SETUP | NEED_WORK_TREE },
                { "commit-tree", cmd_commit_tree, RUN_SETUP },
 -              { "config", cmd_config },
 +              { "config", cmd_config, RUN_SETUP_GENTLY },
                { "count-objects", cmd_count_objects, RUN_SETUP },
                { "describe", cmd_describe, RUN_SETUP },
                { "diff", cmd_diff },
                { "fsck-objects", cmd_fsck, RUN_SETUP },
                { "gc", cmd_gc, RUN_SETUP },
                { "get-tar-commit-id", cmd_get_tar_commit_id },
 -              { "grep", cmd_grep },
 +              { "grep", cmd_grep, RUN_SETUP_GENTLY },
                { "hash-object", cmd_hash_object },
                { "help", cmd_help },
 -              { "index-pack", cmd_index_pack },
 +              { "index-pack", cmd_index_pack, RUN_SETUP_GENTLY },
                { "init", cmd_init_db },
                { "init-db", cmd_init_db },
 -              { "log", cmd_log, RUN_SETUP | USE_PAGER },
 +              { "log", cmd_log, RUN_SETUP },
                { "ls-files", cmd_ls_files, RUN_SETUP },
                { "ls-tree", cmd_ls_tree, RUN_SETUP },
 -              { "ls-remote", cmd_ls_remote },
 +              { "ls-remote", cmd_ls_remote, RUN_SETUP_GENTLY },
                { "mailinfo", cmd_mailinfo },
                { "mailsplit", cmd_mailsplit },
                { "merge", cmd_merge, RUN_SETUP | NEED_WORK_TREE },
                { "merge-base", cmd_merge_base, RUN_SETUP },
 -              { "merge-file", cmd_merge_file },
 +              { "merge-file", cmd_merge_file, RUN_SETUP_GENTLY },
                { "merge-index", cmd_merge_index, RUN_SETUP },
                { "merge-ours", cmd_merge_ours, RUN_SETUP },
                { "merge-recursive", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },
                { "pack-objects", cmd_pack_objects, RUN_SETUP },
                { "pack-redundant", cmd_pack_redundant, RUN_SETUP },
                { "patch-id", cmd_patch_id },
 -              { "peek-remote", cmd_ls_remote },
 +              { "peek-remote", cmd_ls_remote, RUN_SETUP_GENTLY },
                { "pickaxe", cmd_blame, RUN_SETUP },
                { "prune", cmd_prune, RUN_SETUP },
                { "prune-packed", cmd_prune_packed, RUN_SETUP },
                { "reflog", cmd_reflog, RUN_SETUP },
                { "remote", cmd_remote, RUN_SETUP },
                { "replace", cmd_replace, RUN_SETUP },
 -              { "repo-config", cmd_config },
 +              { "repo-config", cmd_config, RUN_SETUP_GENTLY },
                { "rerere", cmd_rerere, RUN_SETUP },
                { "reset", cmd_reset, RUN_SETUP },
                { "rev-list", cmd_rev_list, RUN_SETUP },
                { "revert", cmd_revert, RUN_SETUP | NEED_WORK_TREE },
                { "rm", cmd_rm, RUN_SETUP },
                { "send-pack", cmd_send_pack, RUN_SETUP },
 -              { "shortlog", cmd_shortlog, USE_PAGER },
 +              { "shortlog", cmd_shortlog, RUN_SETUP_GENTLY | USE_PAGER },
                { "show-branch", cmd_show_branch, RUN_SETUP },
 -              { "show", cmd_show, RUN_SETUP | USE_PAGER },
 +              { "show", cmd_show, RUN_SETUP },
                { "status", cmd_status, RUN_SETUP | NEED_WORK_TREE },
                { "stripspace", cmd_stripspace },
                { "symbolic-ref", cmd_symbolic_ref, RUN_SETUP },
                { "update-ref", cmd_update_ref, RUN_SETUP },
                { "update-server-info", cmd_update_server_info, RUN_SETUP },
                { "upload-archive", cmd_upload_archive },
 -              { "var", cmd_var },
 +              { "var", cmd_var, RUN_SETUP_GENTLY },
                { "verify-tag", cmd_verify_tag, RUN_SETUP },
                { "version", cmd_version },
 -              { "whatchanged", cmd_whatchanged, RUN_SETUP | USE_PAGER },
 +              { "whatchanged", cmd_whatchanged, RUN_SETUP },
                { "write-tree", cmd_write_tree, RUN_SETUP },
                { "verify-pack", cmd_verify_pack },
                { "show-ref", cmd_show_ref, RUN_SETUP },
@@@ -496,8 -489,6 +496,8 @@@ int main(int argc, const char **argv
  {
        const char *cmd;
  
 +      startup_info = &git_startup_info;
 +
        cmd = git_extract_argv0_path(argv[0]);
        if (!cmd)
                cmd = "git-help";