Staging
v0.5.1
Revision ca1b4116483b397e78483376296bcd23916ab553 authored by Johannes Schindelin on 15 February 2019, 15:17:45 UTC, committed by Junio C Hamano on 15 February 2019, 18:25:28 UTC
Running up to v2.21.0, we fixed two bugs that were made prominent by the
Windows-specific change to retain copies of only the 30 latest getenv()
calls' returned strings, invalidating any copies of previous getenv()
calls' return values.

While this really shines a light onto bugs of the form where we hold
onto getenv()'s return values without copying them, it is also a real
problem for users.

And even if Jeff King's patches merged via 773e408881 (Merge branch
'jk/save-getenv-result', 2019-01-29) provide further work on that front,
we are far from done. Just one example: on Windows, we unset environment
variables when spawning new processes, which potentially invalidates
strings that were previously obtained via getenv(), and therefore we
have to duplicate environment values that are somehow involved in
spawning new processes (e.g. GIT_MAN_VIEWER in show_man_page()).

We do not have a chance to investigate, let address, all of those issues
in time for v2.21.0, so let's at least help Windows users by increasing
the number of getenv() calls' return values that are kept valid. The
number 64 was determined by looking at the average number of getenv()
calls per process in the entire test suite run on Windows (which is
around 40) and then adding a bit for good measure. And it is a power of
two (which would have hit yesterday's theme perfectly).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 2d08f3d
Raw File
column.h
#ifndef COLUMN_H
#define COLUMN_H

#define COL_LAYOUT_MASK   0x000F
#define COL_ENABLE_MASK   0x0030   /* always, never or auto */
#define COL_PARSEOPT      0x0040   /* --column is given from cmdline */
#define COL_DENSE         0x0080   /* Shrink columns when possible,
				      making space for more columns */

#define COL_DISABLED      0x0000   /* must be zero */
#define COL_ENABLED       0x0010
#define COL_AUTO          0x0020

#define COL_LAYOUT(c) ((c) & COL_LAYOUT_MASK)
#define COL_COLUMN             0   /* Fill columns before rows */
#define COL_ROW                1   /* Fill rows before columns */
#define COL_PLAIN             15   /* one column */

#define explicitly_enable_column(c) \
	(((c) & COL_PARSEOPT) && column_active(c))

struct column_options {
	int width;
	int padding;
	const char *indent;
	const char *nl;
};

struct option;
extern int parseopt_column_callback(const struct option *, const char *, int);
extern int git_column_config(const char *var, const char *value,
			     const char *command, unsigned int *colopts);
extern int finalize_colopts(unsigned int *colopts, int stdout_is_tty);
static inline int column_active(unsigned int colopts)
{
	return (colopts & COL_ENABLE_MASK) == COL_ENABLED;
}

struct string_list;
extern void print_columns(const struct string_list *list, unsigned int colopts,
			  const struct column_options *opts);

extern int run_column_filter(int colopts, const struct column_options *);
extern int stop_column_filter(void);

#endif
back to top