Code

Merge branch 'jk/trace-sifter'
authorJunio C Hamano <gitster@pobox.com>
Sun, 20 Mar 2011 06:24:12 +0000 (23:24 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 20 Mar 2011 06:24:12 +0000 (23:24 -0700)
* jk/trace-sifter:
  trace: give repo_setup trace its own key
  add packet tracing debug code
  trace: add trace_strbuf
  trace: factor out "do we want to trace" logic
  trace: refactor to support multiple env variables
  trace: add trace_vprintf

1  2 
builtin/clone.c
builtin/fetch.c
builtin/push.c
builtin/receive-pack.c
cache.h

diff --combined builtin/clone.c
index 404f589680151c69a57f746eb5b225e54aa8d8a0,38b4b71cd28065d5eea2443745d20343b93324e8..02547adba5d841c066ed7e9c93247b509b2b9c44
@@@ -100,7 -100,7 +100,7 @@@ static char *get_repo_path(const char *
                path = mkpath("%s%s", repo, suffix[i]);
                if (is_directory(path)) {
                        *is_bundle = 0;
 -                      return xstrdup(make_nonrelative_path(path));
 +                      return xstrdup(absolute_path(path));
                }
        }
  
                path = mkpath("%s%s", repo, bundle_suffix[i]);
                if (!stat(path, &st) && S_ISREG(st.st_mode)) {
                        *is_bundle = 1;
 -                      return xstrdup(make_nonrelative_path(path));
 +                      return xstrdup(absolute_path(path));
                }
        }
  
@@@ -203,7 -203,7 +203,7 @@@ static void setup_reference(const char 
        struct transport *transport;
        const struct ref *extra;
  
 -      ref_git = make_absolute_path(option_reference);
 +      ref_git = real_path(option_reference);
  
        if (is_directory(mkpath("%s/.git/objects", ref_git)))
                ref_git = mkpath("%s/.git", ref_git);
@@@ -383,6 -383,7 +383,7 @@@ int cmd_clone(int argc, const char **ar
  
        junk_pid = getpid();
  
+       packet_trace_identity("clone");
        argc = parse_options(argc, argv, prefix, builtin_clone_options,
                             builtin_clone_usage, 0);
  
  
        path = get_repo_path(repo_name, &is_bundle);
        if (path)
 -              repo = xstrdup(make_nonrelative_path(repo_name));
 +              repo = xstrdup(absolute_path(repo_name));
        else if (!strchr(repo_name, ':'))
 -              repo = xstrdup(make_absolute_path(repo_name));
 +              die("repository '%s' does not exist", repo_name);
        else
                repo = repo_name;
        is_local = path && !is_bundle;
  
        if (safe_create_leading_directories_const(git_dir) < 0)
                die("could not create leading directories of '%s'", git_dir);
 -      set_git_dir(make_absolute_path(git_dir));
 +      set_git_dir(real_path(git_dir));
  
        if (0 <= option_verbosity)
                printf("Cloning into %s%s...\n",
diff --combined builtin/fetch.c
index 7efecfe1cf6b14a53d619b4bcc4760c81a492747,e94e0015c9c3ae2f638cad686d78b3fa16be2231..1b6d4be00207576f612b8d2cf1f5979656a63da7
@@@ -49,7 -49,7 +49,7 @@@ static struct option builtin_fetch_opti
                    "fetch from all remotes"),
        OPT_BOOLEAN('a', "append", &append,
                    "append to .git/FETCH_HEAD instead of overwriting"),
 -      OPT_STRING(0, "upload-pack", &upload_pack, "PATH",
 +      OPT_STRING(0, "upload-pack", &upload_pack, "path",
                   "path to upload pack on remote end"),
        OPT__FORCE(&force, "force overwrite of local branch"),
        OPT_BOOLEAN('m', "multiple", &multiple,
@@@ -69,9 -69,9 +69,9 @@@
        OPT_BOOLEAN('u', "update-head-ok", &update_head_ok,
                    "allow updating of HEAD ref"),
        OPT_BOOLEAN(0, "progress", &progress, "force progress reporting"),
 -      OPT_STRING(0, "depth", &depth, "DEPTH",
 +      OPT_STRING(0, "depth", &depth, "depth",
                   "deepen history of shallow clone"),
 -      { OPTION_STRING, 0, "submodule-prefix", &submodule_prefix, "DIR",
 +      { OPTION_STRING, 0, "submodule-prefix", &submodule_prefix, "dir",
                   "prepend this to submodule path output", PARSE_OPT_HIDDEN },
        OPT_END()
  };
@@@ -906,6 -906,8 +906,8 @@@ int cmd_fetch(int argc, const char **ar
        struct remote *remote;
        int result = 0;
  
+       packet_trace_identity("fetch");
        /* Record the command line for the reflog */
        strbuf_addstr(&default_rla, "fetch");
        for (i = 1; i < argc; i++)
diff --combined builtin/push.c
index c3c2feb9449b5cd3539c18b58ce0fb2886a623b9,26171ff50fa91eb57594004d5dc55670f08a6257..6f6a66f9862d5ee5eaf4a4ce07934832569eacf9
@@@ -64,33 -64,23 +64,33 @@@ static void set_refspecs(const char **r
        }
  }
  
 -static void setup_push_tracking(void)
 +static void setup_push_upstream(struct remote *remote)
  {
        struct strbuf refspec = STRBUF_INIT;
        struct branch *branch = branch_get(NULL);
        if (!branch)
 -              die("You are not currently on a branch.");
 +              die("You are not currently on a branch.\n"
 +                  "To push the history leading to the current (detached HEAD)\n"
 +                  "state now, use\n"
 +                  "\n"
 +                  "    git push %s HEAD:<name-of-remote-branch>\n",
 +                  remote->name);
        if (!branch->merge_nr || !branch->merge)
 -              die("The current branch %s is not tracking anything.",
 +              die("The current branch %s has no upstream branch.\n"
 +                  "To push the current branch and set the remote as upstream, use\n"
 +                  "\n"
 +                  "    git push --set-upstream %s %s\n",
 +                  branch->name,
 +                  remote->name,
                    branch->name);
        if (branch->merge_nr != 1)
 -              die("The current branch %s is tracking multiple branches, "
 +              die("The current branch %s has multiple upstream branches, "
                    "refusing to push.", branch->name);
        strbuf_addf(&refspec, "%s:%s", branch->name, branch->merge[0]->src);
        add_refspec(refspec.buf);
  }
  
 -static void setup_default_push_refspecs(void)
 +static void setup_default_push_refspecs(struct remote *remote)
  {
        switch (push_default) {
        default:
@@@ -98,8 -88,8 +98,8 @@@
                add_refspec(":");
                break;
  
 -      case PUSH_DEFAULT_TRACKING:
 -              setup_push_tracking();
 +      case PUSH_DEFAULT_UPSTREAM:
 +              setup_push_upstream(remote);
                break;
  
        case PUSH_DEFAULT_CURRENT:
@@@ -157,14 -147,7 +157,14 @@@ static int do_push(const char *repo, in
        if (!remote) {
                if (repo)
                        die("bad repository '%s'", repo);
 -              die("No destination configured to push to.");
 +              die("No configured push destination.\n"
 +                  "Either specify the URL from the command-line or configure a remote repository using\n"
 +                  "\n"
 +                  "    git remote add <name> <url>\n"
 +                  "\n"
 +                  "and then push using the remote name\n"
 +                  "\n"
 +                  "    git push <name>\n");
        }
  
        if (remote->mirror)
                        refspec = remote->push_refspec;
                        refspec_nr = remote->push_refspec_nr;
                } else if (!(flags & TRANSPORT_PUSH_MIRROR))
 -                      setup_default_push_refspecs();
 +                      setup_default_push_refspecs(remote);
        }
        errs = 0;
        if (remote->pushurl_nr) {
@@@ -245,6 -228,7 +245,7 @@@ int cmd_push(int argc, const char **arg
                OPT_END()
        };
  
+       packet_trace_identity("push");
        git_config(git_default_config, NULL);
        argc = parse_options(argc, argv, prefix, options, push_usage, 0);
  
diff --combined builtin/receive-pack.c
index d883585804224d3c1bbc2699da94b2632dcf8064,5fa4be8fb4265d903903fbf19dc6c7ce19a8eed4..d8e2c5fca7902d6d9a9e8300e129d58ad7a98192
@@@ -740,7 -740,7 +740,7 @@@ static int add_refs_from_alternate(stru
        const struct ref *extra;
  
        e->name[-1] = '\0';
 -      other = xstrdup(make_absolute_path(e->base));
 +      other = xstrdup(real_path(e->base));
        e->name[-1] = '/';
        len = strlen(other);
  
@@@ -778,6 -778,8 +778,8 @@@ int cmd_receive_pack(int argc, const ch
        char *dir = NULL;
        struct command *commands;
  
+       packet_trace_identity("receive-pack");
        argv++;
        for (i = 1; i < argc; i++) {
                const char *arg = *argv++;
diff --combined cache.h
index a99fd560e97193a1750433be8c674cbc4eb73e19,2e59aae179ec4b19b9773bcafc5eb021568c0f00..fad2117bf910a95f610f3f94f6f4f8a95ce8fa03
+++ b/cache.h
@@@ -500,23 -500,8 +500,23 @@@ extern int index_name_is_other(const st
  extern int ie_match_stat(const struct index_state *, struct cache_entry *, struct stat *, unsigned int);
  extern int ie_modified(const struct index_state *, struct cache_entry *, struct stat *, unsigned int);
  
 -extern int ce_path_match(const struct cache_entry *ce, const char **pathspec);
 -extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, enum object_type type, const char *path);
 +struct pathspec {
 +      const char **raw; /* get_pathspec() result, not freed by free_pathspec() */
 +      int nr;
 +      unsigned int has_wildcard:1;
 +      unsigned int recursive:1;
 +      int max_depth;
 +      struct pathspec_item {
 +              const char *match;
 +              int len;
 +              unsigned int has_wildcard:1;
 +      } *items;
 +};
 +
 +extern int init_pathspec(struct pathspec *, const char **);
 +extern void free_pathspec(struct pathspec *);
 +extern int ce_path_match(const struct cache_entry *ce, const struct pathspec *pathspec);
 +extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, enum object_type type, const char *path, int format_check);
  extern int index_path(unsigned char *sha1, const char *path, struct stat *st, int write_object);
  extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st);
  
@@@ -560,6 -545,7 +560,6 @@@ extern int assume_unchanged
  extern int prefer_symlink_refs;
  extern int log_all_ref_updates;
  extern int warn_ambiguous_refs;
 -extern int unique_abbrev_extra_length;
  extern int shared_repository;
  extern const char *apply_default_whitespace;
  extern const char *apply_default_ignorewhitespace;
@@@ -585,7 -571,7 +585,7 @@@ extern enum safe_crlf safe_crlf
  enum auto_crlf {
        AUTO_CRLF_FALSE = 0,
        AUTO_CRLF_TRUE = 1,
 -      AUTO_CRLF_INPUT = -1,
 +      AUTO_CRLF_INPUT = -1
  };
  
  extern enum auto_crlf auto_crlf;
@@@ -622,7 -608,7 +622,7 @@@ enum rebase_setup_type 
  enum push_default_type {
        PUSH_DEFAULT_NOTHING = 0,
        PUSH_DEFAULT_MATCHING,
 -      PUSH_DEFAULT_TRACKING,
 +      PUSH_DEFAULT_UPSTREAM,
        PUSH_DEFAULT_CURRENT
  };
  
@@@ -731,9 -717,9 +731,9 @@@ static inline int is_absolute_path(cons
        return path[0] == '/' || has_dos_drive_prefix(path);
  }
  int is_directory(const char *);
 -const char *make_absolute_path(const char *path);
 -const char *make_nonrelative_path(const char *path);
 -const char *make_relative_path(const char *abs, const char *base);
 +const char *real_path(const char *path);
 +const char *absolute_path(const char *path);
 +const char *relative_path(const char *abs, const char *base);
  int normalize_path_copy(char *dst, const char *src);
  int longest_ancestor_length(const char *path, const char *prefix_list);
  char *strip_path_suffix(const char *path, const char *suffix);
@@@ -913,8 -899,7 +913,8 @@@ extern struct packed_git 
        time_t mtime;
        int pack_fd;
        unsigned pack_local:1,
 -               pack_keep:1;
 +               pack_keep:1,
 +               do_not_close:1;
        unsigned char sha1[20];
        /* something like ".git/objects/pack/xxxxx.pack" */
        char pack_name[FLEX_ARRAY]; /* more */
@@@ -1014,7 -999,6 +1014,7 @@@ extern int git_config_maybe_bool(const 
  extern int git_config_string(const char **, const char *, const char *);
  extern int git_config_pathname(const char **, const char *, const char *);
  extern int git_config_set(const char *, const char *);
 +extern int git_config_parse_key(const char *, char **, int *);
  extern int git_config_set_multivar(const char *, const char *, const char *, int);
  extern int git_config_rename_section(const char *, const char *);
  extern const char *git_etc_gitconfig(void);
@@@ -1083,9 -1067,14 +1083,14 @@@ extern void alloc_report(void)
  /* trace.c */
  __attribute__((format (printf, 1, 2)))
  extern void trace_printf(const char *format, ...);
+ extern void trace_vprintf(const char *key, const char *format, va_list ap);
  __attribute__((format (printf, 2, 3)))
  extern void trace_argv_printf(const char **argv, const char *format, ...);
  extern void trace_repo_setup(const char *prefix);
+ extern int trace_want(const char *key);
+ extern void trace_strbuf(const char *key, const struct strbuf *buf);
+ void packet_trace_identity(const char *prog);
  
  /* convert.c */
  /* returns 1 if *dst was used */