Merge branch 'nd/traces'
authorJunio C Hamano <gitster@pobox.com>
Thu, 20 Jun 2013 23:02:28 +0000 (16:02 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 20 Jun 2013 23:02:28 +0000 (16:02 -0700)
* nd/traces:
git.txt: document GIT_TRACE_PACKET
core: use env variable instead of config var to turn on logging pack access

Documentation/git.txt
cache.h
config.c
environment.c
sha1_file.c
index 2e23cbb224854c3090ecd73cb36e437978d0d063..894454609fab8f3773afff7e1e3fc4aadfb825f0 100644 (file)
@@ -837,6 +837,19 @@ for further details.
        as a file path and will try to write the trace messages
        into it.
 
+'GIT_TRACE_PACK_ACCESS'::
+       If this variable is set to a path, a file will be created at
+       the given path logging all accesses to any packs. For each
+       access, the pack file name and an offset in the pack is
+       recorded. This may be helpful for troubleshooting some
+       pack-related performance problems.
+
+'GIT_TRACE_PACKET'::
+       If this variable is set, it shows a trace of all packets
+       coming in or out of a given program. This can help with
+       debugging object negotiation or other protocol issues. Tracing
+       is turned off at a packet starting with "PACK".
+
 GIT_LITERAL_PATHSPECS::
        Setting this variable to `1` will cause Git to treat all
        pathspecs literally, rather than as glob patterns. For example,
diff --git a/cache.h b/cache.h
index 820aa05c7a6f42aa3a3599c48f560a1074132596..ec8240f62a77cf718436d3de62f8ab7f66d4a322 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -774,9 +774,6 @@ extern int parse_sha1_header(const char *hdr, unsigned long *sizep);
 /* global flag to enable extra checks when accessing packed objects */
 extern int do_check_packed_object_crc;
 
-/* for development: log offset of pack access */
-extern const char *log_pack_access;
-
 extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned long size, const char *type);
 
 extern int move_temp_to_file(const char *tmpfile, const char *filename);
index 7a85ebdbae79cf13305ebc821fafcd21a67c16d4..d04e8157abc415c6956bb8a237c8a17bd9624f8c 100644 (file)
--- a/config.c
+++ b/config.c
@@ -688,9 +688,6 @@ static int git_default_core_config(const char *var, const char *value)
                return 0;
        }
 
-       if (!strcmp(var, "core.logpackaccess"))
-               return git_config_string(&log_pack_access, var, value);
-
        if (!strcmp(var, "core.autocrlf")) {
                if (value && !strcasecmp(value, "input")) {
                        if (core_eol == EOL_CRLF)
index e2e75c16602d8e5841c2461defaba7b9866115d8..0cb67b22cf5a8754daf429b3dbe45ef3e663650b 100644 (file)
@@ -37,7 +37,6 @@ size_t packed_git_window_size = DEFAULT_PACKED_GIT_WINDOW_SIZE;
 size_t packed_git_limit = DEFAULT_PACKED_GIT_LIMIT;
 size_t delta_base_cache_limit = 16 * 1024 * 1024;
 unsigned long big_file_threshold = 512 * 1024 * 1024;
-const char *log_pack_access;
 const char *pager_program;
 int pager_use_color = 1;
 const char *editor_program;
index 5c08701ae85d7bc5a4465ed138fd80b3f3480052..16f08d475cde5e96282aa830dd3373277c2b898f 100644 (file)
@@ -36,6 +36,9 @@ static inline uintmax_t sz_fmt(size_t s) { return s; }
 
 const unsigned char null_sha1[20];
 
+static const char *no_log_pack_access = "no_log_pack_access";
+static const char *log_pack_access;
+
 /*
  * This is meant to hold a *small* number of objects that you would
  * want read_sha1_file() to be able to return, but yet you do not want
@@ -1956,12 +1959,19 @@ static void write_pack_access_log(struct packed_git *p, off_t obj_offset)
 {
        static FILE *log_file;
 
+       if (!log_pack_access)
+               log_pack_access = getenv("GIT_TRACE_PACK_ACCESS");
+       if (!log_pack_access)
+               log_pack_access = no_log_pack_access;
+       if (log_pack_access == no_log_pack_access)
+               return;
+
        if (!log_file) {
                log_file = fopen(log_pack_access, "w");
                if (!log_file) {
                        error("cannot open pack access log '%s' for writing: %s",
                              log_pack_access, strerror(errno));
-                       log_pack_access = NULL;
+                       log_pack_access = no_log_pack_access;
                        return;
                }
        }
@@ -1992,7 +2002,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
        int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC;
        int base_from_cache = 0;
 
-       if (log_pack_access)
+       if (log_pack_access != no_log_pack_access)
                write_pack_access_log(p, obj_offset);
 
        /* PHASE 1: drill down to the innermost base object */