Skip to content

Commit

Permalink
Avoid C99 initializers
Browse files Browse the repository at this point in the history
In a handful places, we use C99 structure and array
initializers, which some compilers do not support.

This can be handy when you are trying to compile GIT on a
Solaris system that has an older C compiler, for example.

Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Shawn Pearce authored and Junio C Hamano committed Jul 10, 2006
1 parent 4f12d52 commit 344c52a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
18 changes: 8 additions & 10 deletions builtin-read-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ struct tree_entry_list {
const unsigned char *sha1;
};

static struct tree_entry_list df_conflict_list = {
.name = NULL,
.next = &df_conflict_list
};
static struct tree_entry_list df_conflict_list;

typedef int (*merge_fn_t)(struct cache_entry **src);

Expand Down Expand Up @@ -333,14 +330,9 @@ static void setup_progress_signal(void)
setitimer(ITIMER_REAL, &v, NULL);
}

static struct checkout state;
static void check_updates(struct cache_entry **src, int nr)
{
static struct checkout state = {
.base_dir = "",
.force = 1,
.quiet = 1,
.refresh_cache = 1,
};
unsigned short mask = htons(CE_UPDATE);
unsigned last_percent = 200, cnt = 0, total = 0;

Expand Down Expand Up @@ -884,6 +876,12 @@ int cmd_read_tree(int argc, const char **argv, char **envp)
unsigned char sha1[20];
merge_fn_t fn = NULL;

df_conflict_list.next = &df_conflict_list;
state.base_dir = "";
state.force = 1;
state.quiet = 1;
state.refresh_cache = 1;

setup_git_directory();
git_config(git_default_config);

Expand Down
10 changes: 2 additions & 8 deletions checkout-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,7 @@ static int checkout_stage; /* default to checkout stage0 */
static int to_tempfile;
static char topath[4][MAXPATHLEN+1];

static struct checkout state = {
.base_dir = "",
.base_dir_len = 0,
.force = 0,
.quiet = 0,
.not_new = 0,
.refresh_cache = 0,
};
static struct checkout state;

static void write_tempfile_record (const char *name)
{
Expand Down Expand Up @@ -177,6 +170,7 @@ int main(int argc, char **argv)
int all = 0;
int read_from_stdin = 0;

state.base_dir = "";
prefix = setup_git_directory();
git_config(git_default_config);
prefix_length = prefix ? strlen(prefix) : 0;
Expand Down
12 changes: 6 additions & 6 deletions diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ enum color_diff {
#define COLOR_WHITE "\033[37m"

static const char *diff_colors[] = {
[DIFF_RESET] = COLOR_RESET,
[DIFF_PLAIN] = COLOR_NORMAL,
[DIFF_METAINFO] = COLOR_BOLD,
[DIFF_FRAGINFO] = COLOR_CYAN,
[DIFF_FILE_OLD] = COLOR_RED,
[DIFF_FILE_NEW] = COLOR_GREEN,
COLOR_RESET,
COLOR_NORMAL,
COLOR_BOLD,
COLOR_CYAN,
COLOR_RED,
COLOR_GREEN
};

static int parse_diff_color_slot(const char *var, int ofs)
Expand Down

0 comments on commit 344c52a

Please sign in to comment.