Skip to content

Commit 8f0c843

Browse files
committed
Merge branch 'nd/traces'
* nd/traces: git.txt: document GIT_TRACE_PACKET core: use env variable instead of config var to turn on logging pack access
2 parents 01c0615 + 1dd278c commit 8f0c843

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed

Documentation/git.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,19 @@ for further details.
837837
as a file path and will try to write the trace messages
838838
into it.
839839

840+
'GIT_TRACE_PACK_ACCESS'::
841+
If this variable is set to a path, a file will be created at
842+
the given path logging all accesses to any packs. For each
843+
access, the pack file name and an offset in the pack is
844+
recorded. This may be helpful for troubleshooting some
845+
pack-related performance problems.
846+
847+
'GIT_TRACE_PACKET'::
848+
If this variable is set, it shows a trace of all packets
849+
coming in or out of a given program. This can help with
850+
debugging object negotiation or other protocol issues. Tracing
851+
is turned off at a packet starting with "PACK".
852+
840853
GIT_LITERAL_PATHSPECS::
841854
Setting this variable to `1` will cause Git to treat all
842855
pathspecs literally, rather than as glob patterns. For example,

cache.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -774,9 +774,6 @@ extern int parse_sha1_header(const char *hdr, unsigned long *sizep);
774774
/* global flag to enable extra checks when accessing packed objects */
775775
extern int do_check_packed_object_crc;
776776

777-
/* for development: log offset of pack access */
778-
extern const char *log_pack_access;
779-
780777
extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned long size, const char *type);
781778

782779
extern int move_temp_to_file(const char *tmpfile, const char *filename);

config.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -688,9 +688,6 @@ static int git_default_core_config(const char *var, const char *value)
688688
return 0;
689689
}
690690

691-
if (!strcmp(var, "core.logpackaccess"))
692-
return git_config_string(&log_pack_access, var, value);
693-
694691
if (!strcmp(var, "core.autocrlf")) {
695692
if (value && !strcasecmp(value, "input")) {
696693
if (core_eol == EOL_CRLF)

environment.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ size_t packed_git_window_size = DEFAULT_PACKED_GIT_WINDOW_SIZE;
3737
size_t packed_git_limit = DEFAULT_PACKED_GIT_LIMIT;
3838
size_t delta_base_cache_limit = 16 * 1024 * 1024;
3939
unsigned long big_file_threshold = 512 * 1024 * 1024;
40-
const char *log_pack_access;
4140
const char *pager_program;
4241
int pager_use_color = 1;
4342
const char *editor_program;

sha1_file.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ static inline uintmax_t sz_fmt(size_t s) { return s; }
3636

3737
const unsigned char null_sha1[20];
3838

39+
static const char *no_log_pack_access = "no_log_pack_access";
40+
static const char *log_pack_access;
41+
3942
/*
4043
* This is meant to hold a *small* number of objects that you would
4144
* 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)
19561959
{
19571960
static FILE *log_file;
19581961

1962+
if (!log_pack_access)
1963+
log_pack_access = getenv("GIT_TRACE_PACK_ACCESS");
1964+
if (!log_pack_access)
1965+
log_pack_access = no_log_pack_access;
1966+
if (log_pack_access == no_log_pack_access)
1967+
return;
1968+
19591969
if (!log_file) {
19601970
log_file = fopen(log_pack_access, "w");
19611971
if (!log_file) {
19621972
error("cannot open pack access log '%s' for writing: %s",
19631973
log_pack_access, strerror(errno));
1964-
log_pack_access = NULL;
1974+
log_pack_access = no_log_pack_access;
19651975
return;
19661976
}
19671977
}
@@ -1992,7 +2002,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
19922002
int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC;
19932003
int base_from_cache = 0;
19942004

1995-
if (log_pack_access)
2005+
if (log_pack_access != no_log_pack_access)
19962006
write_pack_access_log(p, obj_offset);
19972007

19982008
/* PHASE 1: drill down to the innermost base object */

0 commit comments

Comments
 (0)