From ebef82776512f56eec4b6ac98b076369eb5a93fa Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Fri, 14 May 2010 09:31:32 +0000 Subject: Makefile: pass CPPFLAGS through to fllow customization Without this patch there is no straight forward way to pass additional CPPFLAGS at configure-time. At TWW, everything non-vendor package is installed to its own subdirectory, so we need the following to show the preprocessor where the headers for the libraries we will link later can be found: $SHELL ./configure \ CPPFLAGS="-I${SB_VAR_CURL_INC}\ -I${SB_VAR_LIBEXPAT_INC}\ -I${SB_VAR_LIBZ_INC}\ ${CPPFLAGS+ $CPPFLAGS}" <<...>> Signed-off-by: Gary V. Vaughan Signed-off-by: Junio C Hamano --- Makefile | 2 +- config.mak.in | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 910f4713ef..da0cfda3e8 100644 --- a/Makefile +++ b/Makefile @@ -246,7 +246,7 @@ endif CFLAGS = -g -O2 -Wall LDFLAGS = -ALL_CFLAGS = $(CFLAGS) +ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS) ALL_LDFLAGS = $(LDFLAGS) STRIP ?= strip diff --git a/config.mak.in b/config.mak.in index 6008ac9f1b..7eb6f59eb1 100644 --- a/config.mak.in +++ b/config.mak.in @@ -3,6 +3,7 @@ CC = @CC@ CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ CC_LD_DYNPATH = @CC_LD_DYNPATH@ AR = @AR@ -- cgit v1.2.3 From 66dbfd55e38128db02eb340fcd89f54b734d4c6e Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Fri, 14 May 2010 09:31:33 +0000 Subject: Rewrite dynamic structure initializations to runtime assignment Unfortunately, there are still plenty of production systems with vendor compilers that choke unless all compound declarations can be determined statically at compile time, for example hpux10.20 (I can provide a comprehensive list of our supported platforms that exhibit this problem if necessary). This patch simply breaks apart any compound declarations with dynamic initialisation expressions, and moves the initialisation until after the last declaration in the same block, in all the places necessary to have the offending compilers accept the code. Signed-off-by: Gary V. Vaughan Signed-off-by: Junio C Hamano --- builtin/add.c | 4 +++- builtin/blame.c | 10 ++++++---- builtin/cat-file.c | 4 +++- builtin/checkout.c | 3 ++- builtin/commit.c | 3 ++- builtin/fetch.c | 6 ++++-- builtin/remote.c | 9 ++++++--- convert.c | 4 +++- daemon.c | 21 +++++++++++---------- ll-merge.c | 14 +++++++------- refs.c | 6 +++++- remote.c | 3 +-- unpack-trees.c | 4 +++- wt-status.c | 23 ++++++++++++----------- 14 files changed, 68 insertions(+), 46 deletions(-) diff --git a/builtin/add.c b/builtin/add.c index 87d2980313..17149cfeed 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -261,12 +261,14 @@ static int edit_patch(int argc, const char **argv, const char *prefix) { char *file = xstrdup(git_path("ADD_EDIT.patch")); const char *apply_argv[] = { "apply", "--recount", "--cached", - file, NULL }; + NULL, NULL }; struct child_process child; struct rev_info rev; int out; struct stat st; + apply_argv[3] = file; + git_config(git_diff_basic_config, NULL); /* no "diff" UI options */ if (read_cache() < 0) diff --git a/builtin/blame.c b/builtin/blame.c index fc1586350f..1a42e2b77e 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -733,10 +733,11 @@ static int pass_blame_to_parent(struct scoreboard *sb, { int last_in_target; mmfile_t file_p, file_o; - struct blame_chunk_cb_data d = { sb, target, parent, 0, 0 }; + struct blame_chunk_cb_data d; xpparam_t xpp; xdemitconf_t xecfg; - + memset(&d, 0, sizeof(d)); + d.sb = sb; d.target = target; d.parent = parent; last_in_target = find_last_in_target(sb, target); if (last_in_target < 0) return 1; /* nothing remains for this target */ @@ -875,10 +876,11 @@ static void find_copy_in_blob(struct scoreboard *sb, const char *cp; int cnt; mmfile_t file_o; - struct handle_split_cb_data d = { sb, ent, parent, split, 0, 0 }; + struct handle_split_cb_data d; xpparam_t xpp; xdemitconf_t xecfg; - + memset(&d, 0, sizeof(d)); + d.sb = sb; d.ent = ent; d.parent = parent; d.split = split; /* * Prepare mmfile that contains only the lines in ent. */ diff --git a/builtin/cat-file.c b/builtin/cat-file.c index a933eaa043..e5118c57da 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -118,7 +118,9 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name) /* custom pretty-print here */ if (type == OBJ_TREE) { - const char *ls_args[3] = {"ls-tree", obj_name, NULL}; + const char *ls_args[3] = { NULL }; + ls_args[0] = "ls-tree"; + ls_args[1] = obj_name; return cmd_ls_tree(2, ls_args, NULL); } diff --git a/builtin/checkout.c b/builtin/checkout.c index 88b1f43e05..9820351a30 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -609,7 +609,8 @@ static int check_tracking_name(const char *refname, const unsigned char *sha1, static const char *unique_tracking_name(const char *name) { - struct tracking_name_data cb_data = { name, NULL, 1 }; + struct tracking_name_data cb_data = { NULL, NULL, 1 }; + cb_data.name = name; for_each_ref(check_tracking_name, &cb_data); if (cb_data.unique) return cb_data.remote; diff --git a/builtin/commit.c b/builtin/commit.c index c5ab683d5b..eb06945ae3 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -717,7 +717,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix, if (use_editor) { char index[PATH_MAX]; - const char *env[2] = { index, NULL }; + const char *env[2] = { NULL }; + env[0] = index; snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file); if (launch_editor(git_path(commit_editmsg), NULL, env)) { fprintf(stderr, diff --git a/builtin/fetch.c b/builtin/fetch.c index 8470850415..5cb369cfd1 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -574,9 +574,10 @@ static void find_non_local_tags(struct transport *transport, { struct string_list existing_refs = { NULL, 0, 0, 0 }; struct string_list remote_refs = { NULL, 0, 0, 0 }; - struct tag_data data = {head, tail}; + struct tag_data data; const struct ref *ref; struct string_list_item *item = NULL; + data.head = head; data.tail = tail; for_each_ref(add_existing, &existing_refs); for (ref = transport_get_remote_refs(transport); ref; ref = ref->next) { @@ -778,7 +779,8 @@ static int get_remote_group(const char *key, const char *value, void *priv) static int add_remote_or_group(const char *name, struct string_list *list) { int prev_nr = list->nr; - struct remote_group_data g = { name, list }; + struct remote_group_data g; + g.name = name; g.list = list; git_config(get_remote_group, &g); if (list->nr == prev_nr) { diff --git a/builtin/remote.c b/builtin/remote.c index 277765b864..23ece02aad 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -705,11 +705,14 @@ static int rm(int argc, const char **argv) struct known_remotes known_remotes = { NULL, NULL }; struct string_list branches = { NULL, 0, 0, 1 }; struct string_list skipped = { NULL, 0, 0, 1 }; - struct branches_for_remote cb_data = { - NULL, &branches, &skipped, &known_remotes - }; + struct branches_for_remote cb_data; int i, result; + memset(&cb_data, 0, sizeof(cb_data)); + cb_data.branches = &branches; + cb_data.skipped = &skipped; + cb_data.keep = &known_remotes; + if (argc != 2) usage_with_options(builtin_remote_rm_usage, options); diff --git a/convert.c b/convert.c index 4f8fcb7bbb..3fea3e9509 100644 --- a/convert.c +++ b/convert.c @@ -249,7 +249,9 @@ static int filter_buffer(int in, int out, void *data) struct child_process child_process; struct filter_params *params = (struct filter_params *)data; int write_err, status; - const char *argv[] = { params->cmd, NULL }; + const char *argv[] = { NULL, NULL }; + + argv[0] = params->cmd; memset(&child_process, 0, sizeof(child_process)); child_process.argv = argv; diff --git a/daemon.c b/daemon.c index a90ab10505..e22a2b7fa5 100644 --- a/daemon.c +++ b/daemon.c @@ -141,15 +141,14 @@ static char *path_ok(char *directory) } else if (interpolated_path && saw_extended_args) { struct strbuf expanded_path = STRBUF_INIT; - struct strbuf_expand_dict_entry dict[] = { - { "H", hostname }, - { "CH", canon_hostname }, - { "IP", ip_address }, - { "P", tcp_port }, - { "D", directory }, - { NULL } - }; - + struct strbuf_expand_dict_entry dict[6]; + + dict[0].placeholder = "H"; dict[0].value = hostname; + dict[1].placeholder = "CH"; dict[1].value = canon_hostname; + dict[2].placeholder = "IP"; dict[2].value = ip_address; + dict[3].placeholder = "P"; dict[3].value = tcp_port; + dict[4].placeholder = "D"; dict[4].value = directory; + dict[5].placeholder = NULL; dict[5].value = NULL; if (*dir != '/') { /* Allow only absolute */ logerror("'%s': Non-absolute path denied (interpolated-path active)", dir); @@ -343,7 +342,9 @@ static int upload_pack(void) { /* Timeout as string */ char timeout_buf[64]; - const char *argv[] = { "upload-pack", "--strict", timeout_buf, ".", NULL }; + const char *argv[] = { "upload-pack", "--strict", NULL, ".", NULL }; + + argv[2] = timeout_buf; snprintf(timeout_buf, sizeof timeout_buf, "--timeout=%u", timeout); return run_service_command(argv); diff --git a/ll-merge.c b/ll-merge.c index f9b3d854a9..3764a1ab72 100644 --- a/ll-merge.c +++ b/ll-merge.c @@ -139,17 +139,17 @@ static int ll_ext_merge(const struct ll_merge_driver *fn, { char temp[4][50]; struct strbuf cmd = STRBUF_INIT; - struct strbuf_expand_dict_entry dict[] = { - { "O", temp[0] }, - { "A", temp[1] }, - { "B", temp[2] }, - { "L", temp[3] }, - { NULL } - }; + struct strbuf_expand_dict_entry dict[5]; const char *args[] = { NULL, NULL }; int status, fd, i; struct stat st; + dict[0].placeholder = "O"; dict[0].value = temp[0]; + dict[1].placeholder = "A"; dict[1].value = temp[1]; + dict[2].placeholder = "B"; dict[2].value = temp[2]; + dict[3].placeholder = "L"; dict[3].value = temp[3]; + dict[4].placeholder = NULL; dict[4].value = NULL; + if (fn->cmdline == NULL) die("custom merge driver %s lacks command line.", fn->name); diff --git a/refs.c b/refs.c index d3db15a76c..a7ad3fd8fa 100644 --- a/refs.c +++ b/refs.c @@ -314,7 +314,11 @@ static int warn_if_dangling_symref(const char *refname, const unsigned char *sha void warn_dangling_symref(FILE *fp, const char *msg_fmt, const char *refname) { - struct warn_if_dangling_data data = { fp, refname, msg_fmt }; + struct warn_if_dangling_data data; + + data.fp = fp; + data.refname = refname; + data.msg_fmt = msg_fmt; for_each_rawref(warn_if_dangling_symref, &data); } diff --git a/remote.c b/remote.c index c70181cdc6..ade04246e0 100644 --- a/remote.c +++ b/remote.c @@ -657,10 +657,9 @@ static struct refspec *parse_refspec_internal(int nr_refspec, const char **refsp int valid_fetch_refspec(const char *fetch_refspec_str) { - const char *fetch_refspec[] = { fetch_refspec_str }; struct refspec *refspec; - refspec = parse_refspec_internal(1, fetch_refspec, 1, 1); + refspec = parse_refspec_internal(1, &fetch_refspec_str, 1, 1); free_refspecs(refspec, 1); return !!refspec; } diff --git a/unpack-trees.c b/unpack-trees.c index 75f54cac97..69782b1cc2 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -287,9 +287,11 @@ static void add_same_unmerged(struct cache_entry *ce, static int unpack_index_entry(struct cache_entry *ce, struct unpack_trees_options *o) { - struct cache_entry *src[5] = { ce, NULL, }; + struct cache_entry *src[5] = { NULL }; int ret; + src[0] = ce; + mark_ce_used(ce, o); if (ce_stage(ce)) { if (o->skip_unmerged) { diff --git a/wt-status.c b/wt-status.c index 8ca59a2d2a..24bbd8b915 100644 --- a/wt-status.c +++ b/wt-status.c @@ -498,17 +498,18 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt struct child_process sm_summary; char summary_limit[64]; char index[PATH_MAX]; - const char *env[] = { index, NULL }; - const char *argv[] = { - "submodule", - "summary", - uncommitted ? "--files" : "--cached", - "--for-status", - "--summary-limit", - summary_limit, - uncommitted ? NULL : (s->amend ? "HEAD^" : "HEAD"), - NULL - }; + const char *env[] = { NULL, NULL }; + const char *argv[8]; + + env[0] = index; + argv[0] = "submodule"; + argv[1] = "summary"; + argv[2] = uncommitted ? "--files" : "--cached"; + argv[3] = "--for-status"; + argv[4] = "--summary-limit"; + argv[5] = summary_limit; + argv[6] = uncommitted ? NULL : (s->amend ? "HEAD^" : "HEAD"); + argv[7] = NULL; sprintf(summary_limit, "%d", s->submodule_summary); snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", s->index_file); -- cgit v1.2.3 From 48793cf46a286a21df420fdd7fc4b0c91c60a0c8 Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Fri, 14 May 2010 09:31:34 +0000 Subject: Makefile: -lpthread may still be necessary when libc has only pthread stubs Without this patch, systems that provide stubs for pthread functions in libc, but which still require libpthread for full the pthread implementation are not detected correctly. Also, some systems require -pthread in CFLAGS for each compilation unit for a successful link of an mt binary, which is also addressed by this patch. Signed-off-by: Gary V. Vaughan Signed-off-by: Junio C Hamano --- Makefile | 4 ++++ config.mak.in | 1 + configure.ac | 17 +++++++++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index da0cfda3e8..f6085a5240 100644 --- a/Makefile +++ b/Makefile @@ -294,6 +294,7 @@ RPMBUILD = rpmbuild TCL_PATH = tclsh TCLTK_PATH = wish PTHREAD_LIBS = -lpthread +PTHREAD_CFLAGS = export TCL_PATH TCLTK_PATH @@ -898,6 +899,8 @@ ifeq ($(uname_S),AIX) BASIC_CFLAGS += -D_LARGE_FILES ifeq ($(shell expr "$(uname_V)" : '[1234]'),1) NO_PTHREADS = YesPlease + else + PTHREAD_LIBS = -lpthread endif endif ifeq ($(uname_S),GNU) @@ -1349,6 +1352,7 @@ endif ifdef NO_PTHREADS BASIC_CFLAGS += -DNO_PTHREADS else + BASIC_CFLAGS += $(PTHREAD_CFLAGS) EXTLIBS += $(PTHREAD_LIBS) LIB_OBJS += thread-utils.o endif diff --git a/config.mak.in b/config.mak.in index 7eb6f59eb1..d35f639d4c 100644 --- a/config.mak.in +++ b/config.mak.in @@ -57,4 +57,5 @@ NO_DEFLATE_BOUND=@NO_DEFLATE_BOUND@ FREAD_READS_DIRECTORIES=@FREAD_READS_DIRECTORIES@ SNPRINTF_RETURNS_BOGUS=@SNPRINTF_RETURNS_BOGUS@ NO_PTHREADS=@NO_PTHREADS@ +PTHREAD_CFLAGS=@PTHREAD_CFLAGS@ PTHREAD_LIBS=@PTHREAD_LIBS@ diff --git a/configure.ac b/configure.ac index f4d7372ef8..ad380b83d1 100644 --- a/configure.ac +++ b/configure.ac @@ -802,7 +802,11 @@ AC_DEFUN([PTHREADTEST_SRC], [ int main(void) { pthread_mutex_t test_mutex; - return (0); + int retcode = 0; + retcode |= pthread_mutex_init(&test_mutex,(void *)0); + retcode |= pthread_mutex_lock(&test_mutex); + retcode |= pthread_mutex_unlock(&test_mutex); + return retcode; } ]) @@ -819,7 +823,8 @@ if test -n "$USER_NOPTHREAD"; then # handle these separately since PTHREAD_CFLAGS could be '-lpthreads # -D_REENTRANT' or some such. elif test -z "$PTHREAD_CFLAGS"; then - for opt in -pthread -lpthread; do + threads_found=no + for opt in -mt -pthread -lpthread; do old_CFLAGS="$CFLAGS" CFLAGS="$opt $CFLAGS" AC_MSG_CHECKING([Checking for POSIX Threads with '$opt']) @@ -827,11 +832,18 @@ elif test -z "$PTHREAD_CFLAGS"; then [AC_MSG_RESULT([yes]) NO_PTHREADS= PTHREAD_LIBS="$opt" + PTHREAD_CFLAGS="$opt" + threads_found=yes break ], [AC_MSG_RESULT([no])]) CFLAGS="$old_CFLAGS" done + if test $threads_found != yes; then + AC_CHECK_LIB([pthread], [pthread_create], + [PTHREAD_LIBS="-lpthread"], + [NO_PTHREADS=UnfortunatelyYes]) + fi else old_CFLAGS="$CFLAGS" CFLAGS="$PTHREAD_CFLAGS $CFLAGS" @@ -848,6 +860,7 @@ fi CFLAGS="$old_CFLAGS" +AC_SUBST(PTHREAD_CFLAGS) AC_SUBST(PTHREAD_LIBS) AC_SUBST(NO_PTHREADS) -- cgit v1.2.3 From 4b05548fc0523744b7a1276cfa0f4aae19d6d9c9 Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Fri, 14 May 2010 09:31:35 +0000 Subject: enums: omit trailing comma for portability Without this patch at least IBM VisualAge C 5.0 (I have 5.0.2) on AIX 5.1 fails to compile git. enum style is inconsistent already, with some enums declared on one line, some over 3 lines with the enum values all on the middle line, sometimes with 1 enum value per line... and independently of that the trailing comma is sometimes present and other times absent, often mixing with/without trailing comma styles in a single file, and sometimes in consecutive enum declarations. Clearly, omitting the comma is the more portable style, and this patch changes all enum declarations to use the portable omitted dangling comma style consistently. Signed-off-by: Gary V. Vaughan Signed-off-by: Junio C Hamano --- attr.h | 2 +- builtin/apply.c | 4 ++-- builtin/branch.c | 4 ++-- builtin/commit.c | 6 +++--- builtin/help.c | 2 +- builtin/mailinfo.c | 4 ++-- builtin/receive-pack.c | 2 +- builtin/remote.c | 2 +- cache.h | 16 ++++++++-------- commit.h | 2 +- connect.c | 2 +- ctype.c | 2 +- diff.h | 2 +- dir.c | 6 +++--- fast-import.c | 2 +- grep.h | 8 ++++---- http-push.c | 2 +- http-walker.c | 2 +- imap-send.c | 2 +- merge-recursive.h | 2 +- parse-options.h | 6 +++--- pretty.c | 2 +- remote.h | 2 +- rerere.c | 2 +- revision.c | 2 +- wt-status.h | 2 +- 26 files changed, 45 insertions(+), 45 deletions(-) diff --git a/attr.h b/attr.h index 450f49d648..8b3f19be67 100644 --- a/attr.h +++ b/attr.h @@ -34,7 +34,7 @@ int git_checkattr(const char *path, int, struct git_attr_check *); enum git_attr_direction { GIT_ATTR_CHECKIN, GIT_ATTR_CHECKOUT, - GIT_ATTR_INDEX, + GIT_ATTR_INDEX }; void git_attr_set_direction(enum git_attr_direction, struct index_state *); diff --git a/builtin/apply.c b/builtin/apply.c index 771c972c55..83b8ad9e0b 100644 --- a/builtin/apply.c +++ b/builtin/apply.c @@ -56,7 +56,7 @@ static enum ws_error_action { nowarn_ws_error, warn_on_ws_error, die_on_ws_error, - correct_ws_error, + correct_ws_error } ws_error_action = warn_on_ws_error; static int whitespace_error; static int squelch_whitespace_errors = 5; @@ -64,7 +64,7 @@ static int applied_after_fixing_ws; static enum ws_ignore { ignore_ws_none, - ignore_ws_change, + ignore_ws_change } ws_ignore_action = ignore_ws_none; diff --git a/builtin/branch.c b/builtin/branch.c index 6cf7e721e6..f594af0b3b 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -43,13 +43,13 @@ enum color_branch { BRANCH_COLOR_PLAIN = 1, BRANCH_COLOR_REMOTE = 2, BRANCH_COLOR_LOCAL = 3, - BRANCH_COLOR_CURRENT = 4, + BRANCH_COLOR_CURRENT = 4 }; static enum merge_filter { NO_FILTER = 0, SHOW_NOT_MERGED, - SHOW_MERGED, + SHOW_MERGED } merge_filter; static unsigned char merge_filter_ref[20]; diff --git a/builtin/commit.c b/builtin/commit.c index eb06945ae3..30a00e0b63 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -57,7 +57,7 @@ static struct lock_file false_lock; /* used only for partial commits */ static enum { COMMIT_AS_IS = 1, COMMIT_NORMAL, - COMMIT_PARTIAL, + COMMIT_PARTIAL } commit_style; static const char *logfile, *force_author; @@ -78,7 +78,7 @@ static char *untracked_files_arg, *force_date; static enum { CLEANUP_SPACE, CLEANUP_NONE, - CLEANUP_ALL, + CLEANUP_ALL } cleanup_mode; static char *cleanup_arg; @@ -90,7 +90,7 @@ static int null_termination; static enum { STATUS_FORMAT_LONG, STATUS_FORMAT_SHORT, - STATUS_FORMAT_PORCELAIN, + STATUS_FORMAT_PORCELAIN } status_format = STATUS_FORMAT_LONG; static int opt_parse_m(const struct option *opt, const char *arg, int unset) diff --git a/builtin/help.c b/builtin/help.c index 3182a2bec4..a9836b00ae 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -26,7 +26,7 @@ enum help_format { HELP_FORMAT_NONE, HELP_FORMAT_MAN, HELP_FORMAT_INFO, - HELP_FORMAT_WEB, + HELP_FORMAT_WEB }; static int show_all = 0; diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c index 4a9729b9b3..2320d981ce 100644 --- a/builtin/mailinfo.c +++ b/builtin/mailinfo.c @@ -17,10 +17,10 @@ static struct strbuf name = STRBUF_INIT; static struct strbuf email = STRBUF_INIT; static enum { - TE_DONTCARE, TE_QP, TE_BASE64, + TE_DONTCARE, TE_QP, TE_BASE64 } transfer_encoding; static enum { - TYPE_TEXT, TYPE_OTHER, + TYPE_TEXT, TYPE_OTHER } message_type; static struct strbuf charset = STRBUF_INIT; diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index 0559fcc871..9225dae183 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -16,7 +16,7 @@ enum deny_action { DENY_UNCONFIGURED, DENY_IGNORE, DENY_WARN, - DENY_REFUSE, + DENY_REFUSE }; static int deny_deletes; diff --git a/builtin/remote.c b/builtin/remote.c index 23ece02aad..bd08c0dd89 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -317,7 +317,7 @@ struct push_info { PUSH_STATUS_UPTODATE, PUSH_STATUS_FASTFORWARD, PUSH_STATUS_OUTOFDATE, - PUSH_STATUS_NOTQUERIED, + PUSH_STATUS_NOTQUERIED } status; }; diff --git a/cache.h b/cache.h index 5eb0573bcc..2e9409cc96 100644 --- a/cache.h +++ b/cache.h @@ -361,7 +361,7 @@ enum object_type { OBJ_OFS_DELTA = 6, OBJ_REF_DELTA = 7, OBJ_ANY, - OBJ_MAX, + OBJ_MAX }; static inline enum object_type object_type(unsigned int mode) @@ -556,7 +556,7 @@ extern int core_apply_sparse_checkout; enum safe_crlf { SAFE_CRLF_FALSE = 0, SAFE_CRLF_FAIL = 1, - SAFE_CRLF_WARN = 2, + SAFE_CRLF_WARN = 2 }; extern enum safe_crlf safe_crlf; @@ -567,21 +567,21 @@ enum branch_track { BRANCH_TRACK_REMOTE, BRANCH_TRACK_ALWAYS, BRANCH_TRACK_EXPLICIT, - BRANCH_TRACK_OVERRIDE, + BRANCH_TRACK_OVERRIDE }; enum rebase_setup_type { AUTOREBASE_NEVER = 0, AUTOREBASE_LOCAL, AUTOREBASE_REMOTE, - AUTOREBASE_ALWAYS, + AUTOREBASE_ALWAYS }; enum push_default_type { PUSH_DEFAULT_NOTHING = 0, PUSH_DEFAULT_MATCHING, PUSH_DEFAULT_TRACKING, - PUSH_DEFAULT_CURRENT, + PUSH_DEFAULT_CURRENT }; extern enum branch_track git_branch_track; @@ -590,7 +590,7 @@ extern enum push_default_type push_default; enum object_creation_mode { OBJECT_CREATION_USES_HARDLINKS = 0, - OBJECT_CREATION_USES_RENAMES = 1, + OBJECT_CREATION_USES_RENAMES = 1 }; extern enum object_creation_mode object_creation_mode; @@ -670,7 +670,7 @@ enum sharedrepo { OLD_PERM_GROUP = 1, OLD_PERM_EVERYBODY = 2, PERM_GROUP = 0660, - PERM_EVERYBODY = 0664, + PERM_EVERYBODY = 0664 }; int git_config_perm(const char *var, const char *value); int set_shared_perm(const char *path, int mode); @@ -880,7 +880,7 @@ struct ref { REF_STATUS_REJECT_NODELETE, REF_STATUS_UPTODATE, REF_STATUS_REMOTE_REJECT, - REF_STATUS_EXPECTING_REPORT, + REF_STATUS_EXPECTING_REPORT } status; char *remote_status; struct ref *peer_ref; /* when renaming */ diff --git a/commit.h b/commit.h index 26ec8c0d1c..95de81439e 100644 --- a/commit.h +++ b/commit.h @@ -60,7 +60,7 @@ enum cmit_fmt { CMIT_FMT_EMAIL, CMIT_FMT_USERFORMAT, - CMIT_FMT_UNSPECIFIED, + CMIT_FMT_UNSPECIFIED }; struct pretty_print_context diff --git a/connect.c b/connect.c index 9ae991ac42..fc8f155028 100644 --- a/connect.c +++ b/connect.c @@ -131,7 +131,7 @@ int path_match(const char *path, int nr, char **match) enum protocol { PROTO_LOCAL = 1, PROTO_SSH, - PROTO_GIT, + PROTO_GIT }; static enum protocol get_protocol(const char *name) diff --git a/ctype.c b/ctype.c index 7ee64c7d77..de600279ee 100644 --- a/ctype.c +++ b/ctype.c @@ -10,7 +10,7 @@ enum { A = GIT_ALPHA, D = GIT_DIGIT, G = GIT_GLOB_SPECIAL, /* *, ?, [, \\ */ - R = GIT_REGEX_SPECIAL, /* $, (, ), +, ., ^, {, | */ + R = GIT_REGEX_SPECIAL /* $, (, ), +, ., ^, {, | */ }; unsigned char sane_ctype[256] = { diff --git a/diff.h b/diff.h index 6a71013dc6..965b6c2617 100644 --- a/diff.h +++ b/diff.h @@ -133,7 +133,7 @@ enum color_diff { DIFF_FILE_NEW = 5, DIFF_COMMIT = 6, DIFF_WHITESPACE = 7, - DIFF_FUNCINFO = 8, + DIFF_FUNCINFO = 8 }; const char *diff_get_color(int diff_use_color, enum color_diff ix); #define diff_get_color_opt(o, ix) \ diff --git a/dir.c b/dir.c index cb83332a26..a4bb0a3d07 100644 --- a/dir.c +++ b/dir.c @@ -465,7 +465,7 @@ static struct dir_entry *dir_add_ignored(struct dir_struct *dir, const char *pat enum exist_status { index_nonexistent = 0, index_directory, - index_gitdir, + index_gitdir }; /* @@ -533,7 +533,7 @@ static enum exist_status directory_exists_in_index(const char *dirname, int len) enum directory_treatment { show_directory, ignore_directory, - recurse_into_directory, + recurse_into_directory }; static enum directory_treatment treat_directory(struct dir_struct *dir, @@ -684,7 +684,7 @@ static int get_dtype(struct dirent *de, const char *path, int len) enum path_treatment { path_ignored, path_handled, - path_recurse, + path_recurse }; static enum path_treatment treat_one_path(struct dir_struct *dir, diff --git a/fast-import.c b/fast-import.c index 309f2c58a2..faa51a9734 100644 --- a/fast-import.c +++ b/fast-import.c @@ -267,7 +267,7 @@ struct hash_list typedef enum { WHENSPEC_RAW = 1, WHENSPEC_RFC2822, - WHENSPEC_NOW, + WHENSPEC_NOW } whenspec_type; struct recent_command diff --git a/grep.h b/grep.h index 89342e5b47..062ef8dc28 100644 --- a/grep.h +++ b/grep.h @@ -10,17 +10,17 @@ enum grep_pat_token { GREP_OPEN_PAREN, GREP_CLOSE_PAREN, GREP_NOT, - GREP_OR, + GREP_OR }; enum grep_context { GREP_CONTEXT_HEAD, - GREP_CONTEXT_BODY, + GREP_CONTEXT_BODY }; enum grep_header_field { GREP_HEADER_AUTHOR = 0, - GREP_HEADER_COMMITTER, + GREP_HEADER_COMMITTER }; struct grep_pat { @@ -40,7 +40,7 @@ enum grep_expr_node { GREP_NODE_ATOM, GREP_NODE_NOT, GREP_NODE_AND, - GREP_NODE_OR, + GREP_NODE_OR }; struct grep_expr { diff --git a/http-push.c b/http-push.c index 415b1ab0a7..c9bcd11697 100644 --- a/http-push.c +++ b/http-push.c @@ -105,7 +105,7 @@ enum transfer_state { RUN_PUT, RUN_MOVE, ABORTED, - COMPLETE, + COMPLETE }; struct transfer_request diff --git a/http-walker.c b/http-walker.c index ef99ae647a..cabac48eee 100644 --- a/http-walker.c +++ b/http-walker.c @@ -15,7 +15,7 @@ enum object_request_state { WAITING, ABORTED, ACTIVE, - COMPLETE, + COMPLETE }; struct object_request diff --git a/imap-send.c b/imap-send.c index 9d0097ca02..1a577a0a09 100644 --- a/imap-send.c +++ b/imap-send.c @@ -230,7 +230,7 @@ enum CAPABILITY { LITERALPLUS, NAMESPACE, STARTTLS, - AUTH_CRAM_MD5, + AUTH_CRAM_MD5 }; static const char *cap_list[] = { diff --git a/merge-recursive.h b/merge-recursive.h index d1192f56d7..344e47694c 100644 --- a/merge-recursive.h +++ b/merge-recursive.h @@ -10,7 +10,7 @@ struct merge_options { enum { MERGE_RECURSIVE_NORMAL = 0, MERGE_RECURSIVE_OURS, - MERGE_RECURSIVE_THEIRS, + MERGE_RECURSIVE_THEIRS } recursive_variant; const char *subtree_shift; unsigned buffer_output : 1; diff --git a/parse-options.h b/parse-options.h index 7581e931da..678b58db8e 100644 --- a/parse-options.h +++ b/parse-options.h @@ -25,7 +25,7 @@ enum parse_opt_flags { PARSE_OPT_STOP_AT_NON_OPTION = 2, PARSE_OPT_KEEP_ARGV0 = 4, PARSE_OPT_KEEP_UNKNOWN = 8, - PARSE_OPT_NO_INTERNAL_HELP = 16, + PARSE_OPT_NO_INTERNAL_HELP = 16 }; enum parse_opt_option_flags { @@ -36,7 +36,7 @@ enum parse_opt_option_flags { PARSE_OPT_LASTARG_DEFAULT = 16, PARSE_OPT_NODASH = 32, PARSE_OPT_LITERAL_ARGHELP = 64, - PARSE_OPT_NEGHELP = 128, + PARSE_OPT_NEGHELP = 128 }; struct option; @@ -160,7 +160,7 @@ extern NORETURN void usage_msg_opt(const char *msg, enum { PARSE_OPT_HELP = -1, PARSE_OPT_DONE, - PARSE_OPT_UNKNOWN, + PARSE_OPT_UNKNOWN }; /* diff --git a/pretty.c b/pretty.c index 7cb3a2af50..9a704ec41e 100644 --- a/pretty.c +++ b/pretty.c @@ -828,7 +828,7 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder, enum { NO_MAGIC, ADD_LF_BEFORE_NON_EMPTY, - DEL_LF_BEFORE_EMPTY, + DEL_LF_BEFORE_EMPTY } magic = NO_MAGIC; switch (placeholder[0]) { diff --git a/remote.h b/remote.h index 6e13643cab..888d7c15de 100644 --- a/remote.h +++ b/remote.h @@ -145,7 +145,7 @@ int branch_merge_matches(struct branch *, int n, const char *); enum match_refs_flags { MATCH_REFS_NONE = 0, MATCH_REFS_ALL = (1 << 0), - MATCH_REFS_MIRROR = (1 << 1), + MATCH_REFS_MIRROR = (1 << 1) }; /* Reporting of tracking info */ diff --git a/rerere.c b/rerere.c index f221bed1e9..2197890982 100644 --- a/rerere.c +++ b/rerere.c @@ -153,7 +153,7 @@ static int handle_path(unsigned char *sha1, struct rerere_io *io, int marker_siz git_SHA_CTX ctx; int hunk_no = 0; enum { - RR_CONTEXT = 0, RR_SIDE_1, RR_SIDE_2, RR_ORIGINAL, + RR_CONTEXT = 0, RR_SIDE_1, RR_SIDE_2, RR_ORIGINAL } hunk = RR_CONTEXT; struct strbuf one = STRBUF_INIT, two = STRBUF_INIT; struct strbuf buf = STRBUF_INIT; diff --git a/revision.c b/revision.c index f4b8b38315..b209d493e1 100644 --- a/revision.c +++ b/revision.c @@ -1781,7 +1781,7 @@ int prepare_revision_walk(struct rev_info *revs) enum rewrite_result { rewrite_one_ok, rewrite_one_noparents, - rewrite_one_error, + rewrite_one_error }; static enum rewrite_result rewrite_one(struct rev_info *revs, struct commit **pp) diff --git a/wt-status.h b/wt-status.h index 91206739f3..389e65f68a 100644 --- a/wt-status.h +++ b/wt-status.h @@ -11,7 +11,7 @@ enum color_wt_status { WT_STATUS_CHANGED, WT_STATUS_UNTRACKED, WT_STATUS_NOBRANCH, - WT_STATUS_UNMERGED, + WT_STATUS_UNMERGED }; enum untracked_status_type { -- cgit v1.2.3 From d1b1a919461c2f00d4e10f5ba227b13f800a6ac3 Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Fri, 14 May 2010 09:31:36 +0000 Subject: Do not use "diff" found on PATH while building and installing Some of the flags used with the first diff found in PATH cause the vendor diff to choke. Signed-off-by: Gary V. Vaughan Signed-off-by: Junio C Hamano --- Documentation/install-webdoc.sh | 2 +- Makefile | 4 +++- config.mak.in | 1 + configure.ac | 1 + git-merge-one-file.sh | 2 +- 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Documentation/install-webdoc.sh b/Documentation/install-webdoc.sh index 2135a8ee1f..34d02a2418 100755 --- a/Documentation/install-webdoc.sh +++ b/Documentation/install-webdoc.sh @@ -12,7 +12,7 @@ do then : did not match elif test -f "$T/$h" && - diff -u -I'Last updated [0-9][0-9]-[A-Z][a-z][a-z]-' "$T/$h" "$h" + $DIFF -u -I'Last updated [0-9][0-9]-[A-Z][a-z][a-z]-' "$T/$h" "$h" then :; # up to date else diff --git a/Makefile b/Makefile index f6085a5240..668dbc96ca 100644 --- a/Makefile +++ b/Makefile @@ -287,6 +287,7 @@ export prefix bindir sharedir sysconfdir CC = gcc AR = ar RM = rm -f +DIFF = diff TAR = tar FIND = find INSTALL = install @@ -1460,7 +1461,7 @@ endif ALL_CFLAGS += $(BASIC_CFLAGS) ALL_LDFLAGS += $(BASIC_LDFLAGS) -export TAR INSTALL DESTDIR SHELL_PATH +export DIFF TAR INSTALL DESTDIR SHELL_PATH ### Build rules @@ -1877,6 +1878,7 @@ GIT-CFLAGS: FORCE GIT-BUILD-OPTIONS: FORCE @echo SHELL_PATH=\''$(subst ','\'',$(SHELL_PATH_SQ))'\' >$@ @echo PERL_PATH=\''$(subst ','\'',$(PERL_PATH_SQ))'\' >>$@ + @echo DIFF=\''$(subst ','\'',$(subst ','\'',$(DIFF)))'\' >>$@ @echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@ @echo NO_CURL=\''$(subst ','\'',$(subst ','\'',$(NO_CURL)))'\' >>$@ @echo NO_PERL=\''$(subst ','\'',$(subst ','\'',$(NO_PERL)))'\' >>$@ diff --git a/config.mak.in b/config.mak.in index d35f639d4c..09bd5d417d 100644 --- a/config.mak.in +++ b/config.mak.in @@ -8,6 +8,7 @@ LDFLAGS = @LDFLAGS@ CC_LD_DYNPATH = @CC_LD_DYNPATH@ AR = @AR@ TAR = @TAR@ +DIFF = @DIFF@ #INSTALL = @INSTALL@ # needs install-sh or install.sh in sources TCLTK_PATH = @TCLTK_PATH@ diff --git a/configure.ac b/configure.ac index ad380b83d1..d8aab9a277 100644 --- a/configure.ac +++ b/configure.ac @@ -362,6 +362,7 @@ fi #AC_PROG_INSTALL # needs install-sh or install.sh in sources AC_CHECK_TOOLS(AR, [gar ar], :) AC_CHECK_PROGS(TAR, [gtar tar]) +AC_CHECK_PROGS(DIFF, [gnudiff gdiff diff]) # TCLTK_PATH will be set to some value if we want Tcl/Tk # or will be empty otherwise. if test -z "$NO_TCLTK"; then diff --git a/git-merge-one-file.sh b/git-merge-one-file.sh index d067894bf4..3145009f4b 100755 --- a/git-merge-one-file.sh +++ b/git-merge-one-file.sh @@ -107,7 +107,7 @@ case "${1:-.}${2:-.}${3:-.}" in # remove lines that are unique to ours. orig=`git-unpack-file $2` sz0=`wc -c <"$orig"` - diff -u -La/$orig -Lb/$orig $orig $src2 | git apply --no-add + $DIFF -u -La/$orig -Lb/$orig $orig $src2 | git apply --no-add sz1=`wc -c <"$orig"` # If we do not have enough common material, it is not -- cgit v1.2.3 From 4fdf71be1ca3a817851a14f91b75e7d30f885a48 Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Fri, 14 May 2010 09:31:37 +0000 Subject: tests: use "test_cmp", not "diff", when verifying the result In tests, call test_cmp rather than raw diff where possible (i.e. if the output does not go to a pipe), to allow the use of, say, 'cmp' when the default 'diff -u' is not compatible with a vendor diff. When that is not possible, use $DIFF, as set in GIT-BUILD-OPTIONS. Signed-off-by: Gary V. Vaughan Signed-off-by: Junio C Hamano --- t/Makefile | 4 ++++ t/t0000-basic.sh | 2 +- t/t3200-branch.sh | 4 ++-- t/t3210-pack-refs.sh | 8 ++++---- t/t3903-stash.sh | 2 +- t/t4002-diff-basic.sh | 2 +- t/t4124-apply-ws-rule.sh | 10 +++++----- t/t4127-apply-same-fn.sh | 6 +++--- t/t5300-pack-object.sh | 6 +++--- t/t5510-fetch.sh | 2 +- t/t5520-pull.sh | 2 +- t/t5700-clone-reference.sh | 8 ++++---- t/t6000lib.sh | 2 +- t/t6001-rev-list-graft.sh | 2 +- t/t6022-merge-rename.sh | 4 ++-- t/t7002-grep.sh | 16 ++++++++-------- t/t7005-editor.sh | 6 +++--- t/t9200-git-cvsexportcommit.sh | 26 +++++++++++++------------- t/t9400-git-cvsserver-server.sh | 2 +- 19 files changed, 59 insertions(+), 55 deletions(-) diff --git a/t/Makefile b/t/Makefile index 25c559bb49..93a64750eb 100644 --- a/t/Makefile +++ b/t/Makefile @@ -6,10 +6,14 @@ -include ../config.mak #GIT_TEST_OPTS=--verbose --debug +GIT_TEST_CMP ?= $(DIFF) SHELL_PATH ?= $(SHELL) TAR ?= $(TAR) RM ?= rm -f +# Make sure test-lib.sh uses make's value of GIT_TEST_CMP +export GIT_TEST_CMP + # Shell quote; SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh index f4ca4fc85c..5dd18c05ab 100755 --- a/t/t0000-basic.sh +++ b/t/t0000-basic.sh @@ -280,7 +280,7 @@ $expectfilter >expected <<\EOF EOF test_expect_success \ 'validate git diff-files output for a know cache/work tree state.' \ - 'git diff-files >current && diff >/dev/null -b current expected' + 'git diff-files >current && test_cmp current expected >/dev/null' test_expect_success \ 'git update-index --refresh should succeed.' \ diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index e0b760513c..8818d0de68 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -43,7 +43,7 @@ test_expect_success \ git branch -l d/e/f && test -f .git/refs/heads/d/e/f && test -f .git/logs/refs/heads/d/e/f && - diff expect .git/logs/refs/heads/d/e/f' + test_cmp expect .git/logs/refs/heads/d/e/f' test_expect_success \ 'git branch -d d/e/f should delete a branch and a log' \ @@ -222,7 +222,7 @@ test_expect_success \ git checkout -b g/h/i -l master && test -f .git/refs/heads/g/h/i && test -f .git/logs/refs/heads/g/h/i && - diff expect .git/logs/refs/heads/g/h/i' + test_cmp expect .git/logs/refs/heads/g/h/i' test_expect_success 'avoid ambiguous track' ' git config branch.autosetupmerge true && diff --git a/t/t3210-pack-refs.sh b/t/t3210-pack-refs.sh index 413019acaf..525174013c 100755 --- a/t/t3210-pack-refs.sh +++ b/t/t3210-pack-refs.sh @@ -28,7 +28,7 @@ test_expect_success \ SHA1=`cat .git/refs/heads/a` && echo "$SHA1 refs/heads/a" >expect && git show-ref a >result && - diff expect result' + test_cmp expect result' test_expect_success \ 'see if a branch still exists when packed' \ @@ -37,7 +37,7 @@ test_expect_success \ rm -f .git/refs/heads/b && echo "$SHA1 refs/heads/b" >expect && git show-ref b >result && - diff expect result' + test_cmp expect result' test_expect_success 'git branch c/d should barf if branch c exists' ' git branch c && @@ -52,7 +52,7 @@ test_expect_success \ git pack-refs --all --prune && echo "$SHA1 refs/heads/e" >expect && git show-ref e >result && - diff expect result' + test_cmp expect result' test_expect_success 'see if git pack-refs --prune remove ref files' ' git branch f && @@ -109,7 +109,7 @@ test_expect_success 'pack, prune and repack' ' git show-ref >all-of-them && git pack-refs && git show-ref >again && - diff all-of-them again + test_cmp all-of-them again ' test_done diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index 476e5ec038..7e47030a15 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -81,7 +81,7 @@ test_expect_success 'drop top stash' ' git stash && git stash drop && git stash list > stashlist2 && - diff stashlist1 stashlist2 && + test_cmp stashlist1 stashlist2 && git stash apply && test 3 = $(cat file) && test 1 = $(git show :file) && diff --git a/t/t4002-diff-basic.sh b/t/t4002-diff-basic.sh index 18695ce821..73441a5165 100755 --- a/t/t4002-diff-basic.sh +++ b/t/t4002-diff-basic.sh @@ -135,7 +135,7 @@ cmp_diff_files_output () { # filesystem. sed <"$2" >.test-tmp \ -e '/^:000000 /d;s/'$x40'\( [MCRNDU][0-9]*\) /'$z40'\1 /' && - diff "$1" .test-tmp + test_cmp "$1" .test-tmp } test_expect_success \ diff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh index fb9ad247bf..bef3bcb1b2 100755 --- a/t/t4124-apply-ws-rule.sh +++ b/t/t4124-apply-ws-rule.sh @@ -44,7 +44,7 @@ test_fix () { apply_patch --whitespace=fix || return 1 # find touched lines - diff file target | sed -n -e "s/^> //p" >fixed + $DIFF file target | sed -n -e "s/^> //p" >fixed # the changed lines are all expeced to change fixed_cnt=$(wc -l .gitattributes && apply_patch --whitespace=error-all && - diff file target + test_cmp file target ' diff --git a/t/t4127-apply-same-fn.sh b/t/t4127-apply-same-fn.sh index 3a8202ea93..77200c0b2d 100755 --- a/t/t4127-apply-same-fn.sh +++ b/t/t4127-apply-same-fn.sh @@ -27,7 +27,7 @@ test_expect_success 'apply same filename with independent changes' ' cp same_fn same_fn2 && git reset --hard && git apply patch0 && - diff same_fn same_fn2 + test_cmp same_fn same_fn2 ' test_expect_success 'apply same filename with overlapping changes' ' @@ -40,7 +40,7 @@ test_expect_success 'apply same filename with overlapping changes' ' cp same_fn same_fn2 && git reset --hard && git apply patch0 && - diff same_fn same_fn2 + test_cmp same_fn same_fn2 ' test_expect_success 'apply same new filename after rename' ' @@ -54,7 +54,7 @@ test_expect_success 'apply same new filename after rename' ' cp new_fn new_fn2 && git reset --hard && git apply --index patch1 && - diff new_fn new_fn2 + test_cmp new_fn new_fn2 ' test_expect_success 'apply same old filename after rename -- should fail.' ' diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh index 7649b810b1..bbb9c1251d 100755 --- a/t/t5300-pack-object.sh +++ b/t/t5300-pack-object.sh @@ -147,7 +147,7 @@ test_expect_success \ git cat-file $t $object || return 1 done current && - diff expect current' + test_cmp expect current' test_expect_success \ 'use packed deltified (REF_DELTA) objects' \ @@ -162,7 +162,7 @@ test_expect_success \ git cat-file $t $object || return 1 done current && - diff expect current' + test_cmp expect current' test_expect_success \ 'use packed deltified (OFS_DELTA) objects' \ @@ -177,7 +177,7 @@ test_expect_success \ git cat-file $t $object || return 1 done current && - diff expect current' + test_cmp expect current' unset GIT_OBJECT_DIRECTORY diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh index 721821ec92..4eb10f602f 100755 --- a/t/t5510-fetch.sh +++ b/t/t5510-fetch.sh @@ -71,7 +71,7 @@ test_expect_success "fetch test for-merge" ' echo "$one_in_two " } >expected && cut -f -2 .git/FETCH_HEAD >actual && - diff expected actual' + test_cmp expected actual' test_expect_success 'fetch tags when there is no tags' ' diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh index dd2ee842e0..319e389ed0 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -26,7 +26,7 @@ cd "$D" test_expect_success 'checking the results' ' test -f file && test -f cloned/file && - diff file cloned/file + test_cmp file cloned/file ' test_expect_success 'pulling into void using master:master' ' diff --git a/t/t5700-clone-reference.sh b/t/t5700-clone-reference.sh index 1c10916069..895f5595ae 100755 --- a/t/t5700-clone-reference.sh +++ b/t/t5700-clone-reference.sh @@ -48,7 +48,7 @@ test_expect_success 'that reference gets used' \ 'cd C && echo "0 objects, 0 kilobytes" > expected && git count-objects > current && -diff expected current' +test_cmp expected current' cd "$base_dir" @@ -75,7 +75,7 @@ cd "$base_dir" test_expect_success 'that reference gets used' \ 'cd D && echo "0 objects, 0 kilobytes" > expected && git count-objects > current && -diff expected current' +test_cmp expected current' cd "$base_dir" @@ -100,7 +100,7 @@ test_expect_success 'that alternate to origin gets used' \ 'cd C && echo "2 objects" > expected && git count-objects | cut -d, -f1 > current && -diff expected current' +test_cmp expected current' cd "$base_dir" @@ -116,7 +116,7 @@ test_expect_success 'check objects expected to exist locally' \ 'cd D && echo "5 objects" > expected && git count-objects | cut -d, -f1 > current && -diff expected current' +test_cmp expected current' cd "$base_dir" diff --git a/t/t6000lib.sh b/t/t6000lib.sh index 985d517a1c..ea25dd89e5 100644 --- a/t/t6000lib.sh +++ b/t/t6000lib.sh @@ -91,7 +91,7 @@ check_output() shift 1 if eval "$*" | entag > $_name.actual then - diff $_name.expected $_name.actual + test_cmp $_name.expected $_name.actual else return 1; fi diff --git a/t/t6001-rev-list-graft.sh b/t/t6001-rev-list-graft.sh index b2131cdacd..fc57e7d3fd 100755 --- a/t/t6001-rev-list-graft.sh +++ b/t/t6001-rev-list-graft.sh @@ -84,7 +84,7 @@ check () { git rev-list --parents --pretty=raw $arg | sed -n -e 's/^commit //p' >test.actual fi - diff test.expect test.actual + test_cmp test.expect test.actual } for type in basic parents parents-raw diff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh index e3f7ae8120..b66544b76d 100755 --- a/t/t6022-merge-rename.sh +++ b/t/t6022-merge-rename.sh @@ -280,7 +280,7 @@ test_expect_success 'updated working tree file should prevent the merge' ' echo "BAD: should have complained" return 1 } - diff M M.saved || { + test_cmp M M.saved || { echo "BAD: should have left M intact" return 1 } @@ -301,7 +301,7 @@ test_expect_success 'updated working tree file should prevent the merge' ' echo "BAD: should have complained" return 1 } - diff M M.saved || { + test_cmp M M.saved || { echo "BAD: should have left M intact" return 1 } diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh index e249c3ed41..8a6322765c 100755 --- a/t/t7002-grep.sh +++ b/t/t7002-grep.sh @@ -60,7 +60,7 @@ do echo ${HC}file:5:foo_mmap bar mmap baz } >expected && git grep -n -w -e mmap $H >actual && - diff expected actual + test_cmp expected actual ' test_expect_success "grep -w $L (w)" ' @@ -74,7 +74,7 @@ do echo ${HC}x:1:x x xx x } >expected && git grep -n -w -e "x xx* x" $H >actual && - diff expected actual + test_cmp expected actual ' test_expect_success "grep -w $L (y-1)" ' @@ -82,7 +82,7 @@ do echo ${HC}y:1:y yy } >expected && git grep -n -w -e "^y" $H >actual && - diff expected actual + test_cmp expected actual ' test_expect_success "grep -w $L (y-2)" ' @@ -93,7 +93,7 @@ do cat actual false else - diff expected actual + test_cmp expected actual fi ' @@ -105,14 +105,14 @@ do cat actual false else - diff expected actual + test_cmp expected actual fi ' test_expect_success "grep $L (t-1)" ' echo "${HC}t/t:1:test" >expected && git grep -n -e test $H >actual && - diff expected actual + test_cmp expected actual ' test_expect_success "grep $L (t-2)" ' @@ -121,7 +121,7 @@ do cd t && git grep -n -e test $H ) >actual && - diff expected actual + test_cmp expected actual ' test_expect_success "grep $L (t-3)" ' @@ -130,7 +130,7 @@ do cd t && git grep --full-name -n -e test $H ) >actual && - diff expected actual + test_cmp expected actual ' test_expect_success "grep -c $L (no /dev/null)" ' diff --git a/t/t7005-editor.sh b/t/t7005-editor.sh index 5257f4d261..25b6d2e67c 100755 --- a/t/t7005-editor.sh +++ b/t/t7005-editor.sh @@ -38,7 +38,7 @@ test_expect_success setup ' test_commit "$msg" && echo "$msg" >expect && git show -s --format=%s > actual && - diff actual expect + test_cmp actual expect ' @@ -85,7 +85,7 @@ do git --exec-path=. commit --amend && git show -s --pretty=oneline | sed -e "s/^[0-9a-f]* //" >actual && - diff actual expect + test_cmp actual expect ' done @@ -107,7 +107,7 @@ do git --exec-path=. commit --amend && git show -s --pretty=oneline | sed -e "s/^[0-9a-f]* //" >actual && - diff actual expect + test_cmp actual expect ' done diff --git a/t/t9200-git-cvsexportcommit.sh b/t/t9200-git-cvsexportcommit.sh index fc3795dc98..61bcb8fc86 100755 --- a/t/t9200-git-cvsexportcommit.sh +++ b/t/t9200-git-cvsexportcommit.sh @@ -63,10 +63,10 @@ test_expect_success \ check_entries B "newfile2.txt/1.1/" && check_entries C "newfile3.png/1.1/-kb" && check_entries D "newfile4.png/1.1/-kb" && - diff A/newfile1.txt ../A/newfile1.txt && - diff B/newfile2.txt ../B/newfile2.txt && - diff C/newfile3.png ../C/newfile3.png && - diff D/newfile4.png ../D/newfile4.png + test_cmp A/newfile1.txt ../A/newfile1.txt && + test_cmp B/newfile2.txt ../B/newfile2.txt && + test_cmp C/newfile3.png ../C/newfile3.png && + test_cmp D/newfile4.png ../D/newfile4.png )' test_expect_success \ @@ -89,10 +89,10 @@ test_expect_success \ check_entries D "newfile4.png/1.2/-kb" && check_entries E "newfile5.txt/1.1/" && check_entries F "newfile6.png/1.1/-kb" && - diff A/newfile1.txt ../A/newfile1.txt && - diff D/newfile4.png ../D/newfile4.png && - diff E/newfile5.txt ../E/newfile5.txt && - diff F/newfile6.png ../F/newfile6.png + test_cmp A/newfile1.txt ../A/newfile1.txt && + test_cmp D/newfile4.png ../D/newfile4.png && + test_cmp E/newfile5.txt ../E/newfile5.txt && + test_cmp F/newfile6.png ../F/newfile6.png )' # Should fail (but only on the git cvsexportcommit stage) @@ -137,9 +137,9 @@ test_expect_success \ check_entries D "" && check_entries E "newfile5.txt/1.1/" && check_entries F "newfile6.png/1.1/-kb" && - diff A/newfile1.txt ../A/newfile1.txt && - diff E/newfile5.txt ../E/newfile5.txt && - diff F/newfile6.png ../F/newfile6.png + test_cmp A/newfile1.txt ../A/newfile1.txt && + test_cmp E/newfile5.txt ../E/newfile5.txt && + test_cmp F/newfile6.png ../F/newfile6.png )' test_expect_success \ @@ -155,8 +155,8 @@ test_expect_success \ check_entries D "" && check_entries E "newfile5.txt/1.1/" && check_entries F "newfile6.png/1.1/-kb" && - diff E/newfile5.txt ../E/newfile5.txt && - diff F/newfile6.png ../F/newfile6.png + test_cmp E/newfile5.txt ../E/newfile5.txt && + test_cmp F/newfile6.png ../F/newfile6.png )' test_expect_success \ diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh index daef2d6c23..e4ee0782b4 100755 --- a/t/t9400-git-cvsserver-server.sh +++ b/t/t9400-git-cvsserver-server.sh @@ -435,7 +435,7 @@ test_expect_success 'cvs update (-p)' ' rm -f failures && for i in merge no-lf empty really-empty; do GIT_CONFIG="$git_config" cvs update -p "$i" >$i.out - diff $i.out ../$i >>failures 2>&1 + test_cmp $i.out ../$i >>failures 2>&1 done && test -z "$(cat failures)" ' -- cgit v1.2.3 From 7b3bdbb335b6be938b4748e86a41357e51c97804 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 31 May 2010 17:35:20 -0700 Subject: fixup: do not unconditionally disable "diff -u" Signed-off-by: Junio C Hamano --- Makefile | 4 ++++ t/Makefile | 4 ---- t/test-lib.sh | 11 ++++++++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 668dbc96ca..c8cc9e280a 100644 --- a/Makefile +++ b/Makefile @@ -1374,6 +1374,10 @@ ifdef USE_NED_ALLOCATOR COMPAT_OBJS += compat/nedmalloc/nedmalloc.o endif +ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT + export GIT_TEST_CMP_USE_COPIED_CONTEXT +endif + ifeq ($(TCLTK_PATH),) NO_TCLTK=NoThanks endif diff --git a/t/Makefile b/t/Makefile index 93a64750eb..25c559bb49 100644 --- a/t/Makefile +++ b/t/Makefile @@ -6,14 +6,10 @@ -include ../config.mak #GIT_TEST_OPTS=--verbose --debug -GIT_TEST_CMP ?= $(DIFF) SHELL_PATH ?= $(SHELL) TAR ?= $(TAR) RM ?= rm -f -# Make sure test-lib.sh uses make's value of GIT_TEST_CMP -export GIT_TEST_CMP - # Shell quote; SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) diff --git a/t/test-lib.sh b/t/test-lib.sh index c582964b0d..a290011fa7 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -63,7 +63,16 @@ export GIT_MERGE_VERBOSITY export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME export EDITOR -GIT_TEST_CMP=${GIT_TEST_CMP:-diff -u} + +if test -z "$GIT_TEST_CMP" +then + if test -n "$GIT_TEST_CMP_USE_COPIED_CONTEXT" + then + GIT_TEST_CMP="$DIFF -c" + else + GIT_TEST_CMP="$DIFF -u" + fi +fi # Protect ourselves from common misconfiguration to export # CDPATH into the environment -- cgit v1.2.3 From b2b0026eede10894d3317920a277b2a579cd86c5 Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Fri, 14 May 2010 09:31:38 +0000 Subject: test_cmp: do not use "diff -u" on platforms that lack one By default the testsuite calls 'diff -u' whenever a file comparison is called for. Unfortunately that throws a "diff: unknown option '-u'" error for most non-GNU diffs. This patch sets GIT_TEST_CMP to 'cmp' on all the architectures where that happens. The previous version of this patch forgot to export GIT_TEST_CMP from t/Makefile, which is why 'make test' continued to fail most tests on most architectures - test-lib.sh was falling back on its default of `diff -u' for GIT_TEST_CMP. This version of this patch shows a vast improvement in testsuite results where either GNU diff is in the path at configure time, or where Makefile knows that GIT_TEST_CMP=cmp is required. Signed-off-by: Gary V. Vaughan Signed-off-by: Junio C Hamano --- Makefile | 5 +++++ t/Makefile | 1 + 2 files changed, 6 insertions(+) diff --git a/Makefile b/Makefile index c8cc9e280a..c7e7577203 100644 --- a/Makefile +++ b/Makefile @@ -815,18 +815,21 @@ ifeq ($(uname_S),SunOS) NO_STRLCPY = YesPlease NO_C99_FORMAT = YesPlease NO_STRTOUMAX = YesPlease + GIT_TEST_CMP = cmp endif ifeq ($(uname_R),5.8) NO_UNSETENV = YesPlease NO_SETENV = YesPlease NO_C99_FORMAT = YesPlease NO_STRTOUMAX = YesPlease + GIT_TEST_CMP = cmp endif ifeq ($(uname_R),5.9) NO_UNSETENV = YesPlease NO_SETENV = YesPlease NO_C99_FORMAT = YesPlease NO_STRTOUMAX = YesPlease + GIT_TEST_CMP = cmp endif INSTALL = /usr/ucb/install TAR = gtar @@ -903,6 +906,7 @@ ifeq ($(uname_S),AIX) else PTHREAD_LIBS = -lpthread endif + GIT_TEST_CMP = cmp endif ifeq ($(uname_S),GNU) # GNU/Hurd @@ -957,6 +961,7 @@ ifeq ($(uname_S),HP-UX) NO_HSTRERROR = YesPlease NO_SYS_SELECT_H = YesPlease SNPRINTF_RETURNS_BOGUS = YesPlease + GIT_TEST_CMP = cmp endif ifeq ($(uname_S),Windows) GIT_VERSION := $(GIT_VERSION).MSVC diff --git a/t/Makefile b/t/Makefile index 25c559bb49..1729485865 100644 --- a/t/Makefile +++ b/t/Makefile @@ -3,6 +3,7 @@ # Copyright (c) 2005 Junio C Hamano # +-include ../config.mak.autogen -include ../config.mak #GIT_TEST_OPTS=--verbose --debug -- cgit v1.2.3 From fcf3a21acce45aa73001ee1d3ae119f653294def Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Fri, 14 May 2010 09:31:39 +0000 Subject: git-compat-util.h: some platforms with mmap() lack MAP_FAILED definition Some platforms with mmap() lack MAP_FAILED definition. Signed-off-by: Gary V. Vaughan Signed-off-by: Junio C Hamano --- git-compat-util.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/git-compat-util.h b/git-compat-util.h index 7e62b55270..cd3022e99f 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -217,7 +217,6 @@ static inline const char *skip_prefix(const char *str, const char *prefix) #define PROT_READ 1 #define PROT_WRITE 2 #define MAP_PRIVATE 1 -#define MAP_FAILED ((void*)-1) #endif #define mmap git_mmap @@ -246,6 +245,10 @@ extern int git_munmap(void *start, size_t length); #endif /* NO_MMAP */ +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif + #ifdef NO_ST_BLOCKS_IN_STRUCT_STAT #define on_disk_bytes(st) ((st).st_size) #else -- cgit v1.2.3 From 0a9b167ede027c09eca7aa2ea7522f058e153a13 Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Fri, 14 May 2010 09:31:40 +0000 Subject: Makefile: some platforms do not have hstrerror anywhere This patch improves the logic of the test for hstrerror, not to blindly assume that if there is no hstrerror in libc that it must exist in libresolv. Signed-off-by: Gary V. Vaughan Signed-off-by: Junio C Hamano --- config.mak.in | 1 + configure.ac | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/config.mak.in b/config.mak.in index 09bd5d417d..9a0d8deacd 100644 --- a/config.mak.in +++ b/config.mak.in @@ -43,6 +43,7 @@ NO_D_TYPE_IN_DIRENT=@NO_D_TYPE_IN_DIRENT@ NO_SOCKADDR_STORAGE=@NO_SOCKADDR_STORAGE@ NO_IPV6=@NO_IPV6@ NO_C99_FORMAT=@NO_C99_FORMAT@ +NO_HSTRERROR=@NO_HSTRERROR@ NO_STRCASESTR=@NO_STRCASESTR@ NO_MEMMEM=@NO_MEMMEM@ NO_STRLCPY=@NO_STRLCPY@ diff --git a/configure.ac b/configure.ac index d8aab9a277..fbe5035c46 100644 --- a/configure.ac +++ b/configure.ac @@ -546,11 +546,22 @@ test -n "$NEEDS_SOCKET" && LIBS="$LIBS -lsocket" # # Define NEEDS_RESOLV if linking with -lnsl and/or -lsocket is not enough. -# Notably on Solaris hstrerror resides in libresolv and on Solaris 7 -# inet_ntop and inet_pton additionally reside there. -AC_CHECK_LIB([c], [hstrerror], +# Notably on Solaris 7 inet_ntop and inet_pton additionally reside there. +AC_CHECK_LIB([c], [inet_ntop], [NEEDS_RESOLV=], [NEEDS_RESOLV=YesPlease]) +# +# Define NO_HSTRERROR if linking with -lresolv is not enough. +# Solaris 2.6 in particular has no hstrerror, even in -lresolv. +NO_HSTRERROR= +AC_CHECK_FUNC([hstrerror], + [], + [AC_CHECK_LIB([resolv], [hstrerror], + [NEEDS_RESOLV=YesPlease], + [NO_HSTRERROR=YesPlease]) +]) +AC_SUBST(NO_HSTRERROR) + AC_SUBST(NEEDS_RESOLV) test -n "$NEEDS_RESOLV" && LIBS="$LIBS -lresolv" -- cgit v1.2.3 From 5a857c74baa96c4b20cdf9cab83a77972e6560de Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Fri, 14 May 2010 09:31:41 +0000 Subject: Make NO_{INET_NTOP,INET_PTON} configured independently Being careful not to overwrite the results of testing for hstrerror in libresolv, also test whether inet_ntop/inet_pton are available from that library. Signed-off-by: Gary V. Vaughan Signed-off-by: Junio C Hamano --- config.mak.in | 2 ++ configure.ac | 37 ++++++++++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/config.mak.in b/config.mak.in index 9a0d8deacd..8667ac5b55 100644 --- a/config.mak.in +++ b/config.mak.in @@ -53,6 +53,8 @@ NO_SETENV=@NO_SETENV@ NO_UNSETENV=@NO_UNSETENV@ NO_MKDTEMP=@NO_MKDTEMP@ NO_MKSTEMPS=@NO_MKSTEMPS@ +NO_INET_NTOP=@NO_INET_NTOP@ +NO_INET_PTON=@NO_INET_PTON@ NO_ICONV=@NO_ICONV@ OLD_ICONV=@OLD_ICONV@ NO_DEFLATE_BOUND=@NO_DEFLATE_BOUND@ diff --git a/configure.ac b/configure.ac index fbe5035c46..b97ee6dbb9 100644 --- a/configure.ac +++ b/configure.ac @@ -545,11 +545,33 @@ AC_SUBST(NEEDS_SOCKET) test -n "$NEEDS_SOCKET" && LIBS="$LIBS -lsocket" # -# Define NEEDS_RESOLV if linking with -lnsl and/or -lsocket is not enough. -# Notably on Solaris 7 inet_ntop and inet_pton additionally reside there. -AC_CHECK_LIB([c], [inet_ntop], -[NEEDS_RESOLV=], -[NEEDS_RESOLV=YesPlease]) +# The next few tests will define NEEDS_RESOLV if linking with +# libresolv provides some of the functions we would normally get +# from libc. +NEEDS_RESOLV= +AC_SUBST(NEEDS_RESOLV) +# +# Define NO_INET_NTOP if linking with -lresolv is not enough. +# Solaris 2.7 in particular hos inet_ntop in -lresolv. +NO_INET_NTOP= +AC_SUBST(NO_INET_NTOP) +AC_CHECK_FUNC([inet_ntop], + [], + [AC_CHECK_LIB([resolv], [inet_ntop], + [NEEDS_RESOLV=YesPlease], + [NO_INET_NTOP=YesPlease]) +]) +# +# Define NO_INET_PTON if linking with -lresolv is not enough. +# Solaris 2.7 in particular hos inet_pton in -lresolv. +NO_INET_PTON= +AC_SUBST(NO_INET_PTON) +AC_CHECK_FUNC([inet_pton], + [], + [AC_CHECK_LIB([resolv], [inet_pton], + [NEEDS_RESOLV=YesPlease], + [NO_INET_PTON=YesPlease]) +]) # # Define NO_HSTRERROR if linking with -lresolv is not enough. # Solaris 2.6 in particular has no hstrerror, even in -lresolv. @@ -561,8 +583,9 @@ AC_CHECK_FUNC([hstrerror], [NO_HSTRERROR=YesPlease]) ]) AC_SUBST(NO_HSTRERROR) - -AC_SUBST(NEEDS_RESOLV) +# +# If any of the above tests determined that -lresolv is needed at +# build-time, also set it here for remaining configure-time checks. test -n "$NEEDS_RESOLV" && LIBS="$LIBS -lresolv" AC_CHECK_LIB([c], [basename], -- cgit v1.2.3 From e88a135bc55a974ea04576ccc014c5e2bdc4b892 Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Fri, 14 May 2010 09:31:42 +0000 Subject: Some platforms lack socklen_t type Some platforms do not have a socklen_t type declaration. Signed-off-by: Gary V. Vaughan Signed-off-by: Junio C Hamano --- Makefile | 7 +++++++ aclocal.m4 | 40 ++++++++++++++++++++++++++++++++++++++++ config.mak.in | 1 + configure.ac | 6 ++++++ 4 files changed, 54 insertions(+) create mode 100644 aclocal.m4 diff --git a/Makefile b/Makefile index c7e7577203..f3717f1e45 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,9 @@ all:: # Define SANE_TOOL_PATH to a colon-separated list of paths to prepend # to PATH if your tools in /usr/bin are broken. # +# Define SOCKLEN_T to a suitable type (such as 'size_t') if your +# system headers do not define a socklen_t type. +# # Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf() # or vsnprintf() return -1 instead of number of characters which would # have been written to the final string if enough space had been available. @@ -1087,6 +1090,10 @@ else BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d' endif +ifneq (,$(SOCKLEN_T)) + BASIC_CFLAGS += -Dsocklen_t=$(SOCKLEN_T) +endif + ifeq ($(uname_S),Darwin) ifndef NO_FINK ifeq ($(shell test -d /sw/lib && echo y),y) diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 0000000000..d399de2671 --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,40 @@ +dnl Check for socklen_t: historically on BSD it is an int, and in +dnl POSIX 1g it is a type of its own, but some platforms use different +dnl types for the argument to getsockopt, getpeername, etc. So we +dnl have to test to find something that will work. +AC_DEFUN([TYPE_SOCKLEN_T], +[ + AC_CHECK_TYPE([socklen_t], ,[ + AC_MSG_CHECKING([for socklen_t equivalent]) + AC_CACHE_VAL([git_cv_socklen_t_equiv], + [ + # Systems have either "struct sockaddr *" or + # "void *" as the second argument to getpeername + git_cv_socklen_t_equiv= + for arg2 in "struct sockaddr" void; do + for t in int size_t unsigned long "unsigned long"; do + AC_TRY_COMPILE([ + #include + #include + + int getpeername (int, $arg2 *, $t *); + ],[ + $t len; + getpeername(0,0,&len); + ],[ + git_cv_socklen_t_equiv="$t" + break 2 + ]) + done + done + + if test "x$git_cv_socklen_t_equiv" = x; then + AC_MSG_ERROR([Cannot find a type to use in place of socklen_t]) + fi + ]) + AC_MSG_RESULT($git_cv_socklen_t_equiv) + AC_DEFINE_UNQUOTED(socklen_t, $git_cv_socklen_t_equiv, + [type to use in place of socklen_t if not defined])], + [#include +#include ]) +]) diff --git a/config.mak.in b/config.mak.in index 8667ac5b55..ed0f8f57de 100644 --- a/config.mak.in +++ b/config.mak.in @@ -58,6 +58,7 @@ NO_INET_PTON=@NO_INET_PTON@ NO_ICONV=@NO_ICONV@ OLD_ICONV=@OLD_ICONV@ NO_DEFLATE_BOUND=@NO_DEFLATE_BOUND@ +SOCKLEN_T=@SOCKLEN_T@ FREAD_READS_DIRECTORIES=@FREAD_READS_DIRECTORIES@ SNPRINTF_RETURNS_BOGUS=@SNPRINTF_RETURNS_BOGUS@ NO_PTHREADS=@NO_PTHREADS@ diff --git a/configure.ac b/configure.ac index b97ee6dbb9..df831c35d4 100644 --- a/configure.ac +++ b/configure.ac @@ -633,6 +633,12 @@ AC_SUBST(OLD_ICONV) ## Checks for typedefs, structures, and compiler characteristics. AC_MSG_NOTICE([CHECKS for typedefs, structures, and compiler characteristics]) # +TYPE_SOCKLEN_T +case $ac_cv_type_socklen_t in + yes) ;; + *) AC_SUBST([SOCKLEN_T], [$git_cv_socklen_t_equiv]) ;; +esac + # Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent. AC_CHECK_MEMBER(struct dirent.d_ino, [NO_D_INO_IN_DIRENT=], -- cgit v1.2.3 From f9f33cdc78b5893a4764b1437b59536f399a50d1 Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Fri, 14 May 2010 09:31:43 +0000 Subject: Allow disabling "inline" Compiler support for inline is sometimes buggy, and occasionally missing entirely. This patch adds a test for inline support, and redefines the keyword with the preprocessor if necessary at compile time. Signed-off-by: Gary V. Vaughan Signed-off-by: Junio C Hamano --- Makefile | 7 +++++++ config.mak.in | 1 + configure.ac | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/Makefile b/Makefile index f3717f1e45..7f6299650d 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,9 @@ all:: # Define SOCKLEN_T to a suitable type (such as 'size_t') if your # system headers do not define a socklen_t type. # +# Define INLINE to a suitable substitute (such as '__inline' or '') if git +# fails to compile with errors about undefined inline functions or similar. +# # Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf() # or vsnprintf() return -1 instead of number of characters which would # have been written to the final string if enough space had been available. @@ -1090,6 +1093,10 @@ else BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d' endif +ifneq (,$(INLINE)) + BASIC_CFLAGS += -Dinline=$(INLINE) +endif + ifneq (,$(SOCKLEN_T)) BASIC_CFLAGS += -Dsocklen_t=$(SOCKLEN_T) endif diff --git a/config.mak.in b/config.mak.in index ed0f8f57de..e2dbd1c0bb 100644 --- a/config.mak.in +++ b/config.mak.in @@ -58,6 +58,7 @@ NO_INET_PTON=@NO_INET_PTON@ NO_ICONV=@NO_ICONV@ OLD_ICONV=@OLD_ICONV@ NO_DEFLATE_BOUND=@NO_DEFLATE_BOUND@ +INLINE=@INLINE@ SOCKLEN_T=@SOCKLEN_T@ FREAD_READS_DIRECTORIES=@FREAD_READS_DIRECTORIES@ SNPRINTF_RETURNS_BOGUS=@SNPRINTF_RETURNS_BOGUS@ diff --git a/configure.ac b/configure.ac index df831c35d4..b33cc6a316 100644 --- a/configure.ac +++ b/configure.ac @@ -327,6 +327,12 @@ GIT_PARSE_WITH(tcltk)) AC_MSG_NOTICE([CHECKS for programs]) # AC_PROG_CC([cc gcc]) +AC_C_INLINE +case $ac_cv_c_inline in + inline | yes | no) ;; + *) AC_SUBST([INLINE], [$ac_cv_c_inline]) ;; +esac + # which switch to pass runtime path to dynamic libraries to the linker AC_CACHE_CHECK([if linker supports -R], git_cv_ld_dashr, [ SAVE_LDFLAGS="${LDFLAGS}" -- cgit v1.2.3 From 520fbc2a0da2ba830a54b9e1992a3f658c3ae1db Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Fri, 14 May 2010 09:31:44 +0000 Subject: inline declaration does not work on AIX Define away inline declaration on AIX. Signed-off-by: Gary V. Vaughan Signed-off-by: Junio C Hamano --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 7f6299650d..c23ac13290 100644 --- a/Makefile +++ b/Makefile @@ -912,6 +912,9 @@ ifeq ($(uname_S),AIX) else PTHREAD_LIBS = -lpthread endif + ifeq ($(shell expr "$(uname_V).$(uname_R)" : '5\.1'),3) + INLINE='' + endif GIT_TEST_CMP = cmp endif ifeq ($(uname_S),GNU) -- cgit v1.2.3 From 614dd90506476f82ab2595da384f71e78254f33e Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Fri, 14 May 2010 09:31:45 +0000 Subject: Makefile: SunOS 5.6 portability fix Although configure takes care of most of this, set some default values for Solaris 2.6 (aka SunOS-5.6) to ensure git compiles even when configure is not used to build it. Signed-off-by: Gary V. Vaughan Signed-off-by: Junio C Hamano --- Makefile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Makefile b/Makefile index c23ac13290..f29ff85991 100644 --- a/Makefile +++ b/Makefile @@ -812,6 +812,18 @@ ifeq ($(uname_S),SunOS) NO_MKDTEMP = YesPlease NO_MKSTEMPS = YesPlease NO_REGEX = YesPlease + ifeq ($(uname_R),5.6) + SOCKLEN_T = int + NO_HSTRERROR = YesPlease + NO_IPV6 = YesPlease + NO_SOCKADDR_STORAGE = YesPlease + NO_UNSETENV = YesPlease + NO_SETENV = YesPlease + NO_STRLCPY = YesPlease + NO_C99_FORMAT = YesPlease + NO_STRTOUMAX = YesPlease + GIT_TEST_CMP = cmp + endif ifeq ($(uname_R),5.7) NEEDS_RESOLV = YesPlease NO_IPV6 = YesPlease -- cgit v1.2.3 From 176959d7423988183ffbe1b35fc1de7f786bb596 Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Fri, 14 May 2010 09:31:47 +0000 Subject: Makefile: HPUX11 portability fixes There is no nanosecond field on HPUX, the inline keyword is spelled "__inline", and there are no inet_ntop/inet_pton definitions on HP-UX 11.00 Signed-off-by: Gary V. Vaughan Signed-off-by: Junio C Hamano --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index f29ff85991..638ca2f8aa 100644 --- a/Makefile +++ b/Makefile @@ -971,6 +971,7 @@ ifeq ($(uname_S),IRIX64) NEEDS_LIBGEN = YesPlease endif ifeq ($(uname_S),HP-UX) + INLINE = __inline NO_IPV6=YesPlease NO_SETENV=YesPlease NO_STRCASESTR=YesPlease @@ -982,6 +983,11 @@ ifeq ($(uname_S),HP-UX) NO_HSTRERROR = YesPlease NO_SYS_SELECT_H = YesPlease SNPRINTF_RETURNS_BOGUS = YesPlease + NO_NSEC = YesPlease + ifeq ($(uname_R),B.11.00) + NO_INET_NTOP = YesPlease + NO_INET_PTON = YesPlease + endif GIT_TEST_CMP = cmp endif ifeq ($(uname_S),Windows) -- cgit v1.2.3 From e78673ff0bef100535cc2ed146e4a59929c7b4fd Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Fri, 14 May 2010 09:31:48 +0000 Subject: Makefile: HP-UX 10.20 portability fixes HP-UX 10.20 has no pread definition, the inline keyword doesn't work, and has no inet_ntop/inet_pton definitions. Signed-off-by: Gary V. Vaughan Signed-off-by: Junio C Hamano --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index 638ca2f8aa..3368cceba6 100644 --- a/Makefile +++ b/Makefile @@ -988,6 +988,14 @@ ifeq ($(uname_S),HP-UX) NO_INET_NTOP = YesPlease NO_INET_PTON = YesPlease endif + ifeq ($(uname_R),B.10.20) + # Override HP-UX 11.x setting: + INLINE = + SOCKLEN_T = size_t + NO_PREAD = YesPlease + NO_INET_NTOP = YesPlease + NO_INET_PTON = YesPlease + endif GIT_TEST_CMP = cmp endif ifeq ($(uname_S),Windows) -- cgit v1.2.3 From 46856f4e9d3d0fbfe1888ee19d632dfc04de8fab Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Fri, 14 May 2010 09:31:49 +0000 Subject: Makefile: Tru64 portability fix Add defaults for Tru64 Unix. Without this patch I cannot compile git on Tru64 5.1. Signed-off-by: Gary V. Vaughan Signed-off-by: Junio C Hamano --- Makefile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Makefile b/Makefile index 3368cceba6..bcb84be635 100644 --- a/Makefile +++ b/Makefile @@ -740,6 +740,13 @@ EXTLIBS = # because maintaining the nesting to match is a pain. If # we had "elif" things would have been much nicer... +ifeq ($(uname_S),OSF1) + # Need this for u_short definitions et al + BASIC_CFLAGS += -D_OSF_SOURCE + SOCKLEN_T = int + NO_STRTOULL = YesPlease + NO_NSEC = YesPlease +endif ifeq ($(uname_S),Linux) NO_STRLCPY = YesPlease NO_MKSTEMPS = YesPlease -- cgit v1.2.3 From 09ce4bb6ea7c06c1de82f042cb3ade622b0fa36c Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 5 Jun 2010 09:36:13 -0700 Subject: build: propagate $DIFF to scripts git-merge-one-file expects to run "-u" capable "diff", but using $DIFF is not the right way to do so. Signed-off-by: Junio C Hamano --- Makefile | 2 ++ git-merge-one-file.sh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bcb84be635..0367e8a958 100644 --- a/Makefile +++ b/Makefile @@ -1494,6 +1494,7 @@ SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH)) PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH)) TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH)) +DIFF_SQ = $(subst ','\'',$(DIFF)) LIBS = $(GITLIBS) $(EXTLIBS) @@ -1582,6 +1583,7 @@ define cmd_munge_script $(RM) $@ $@+ && \ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \ -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \ + -e 's|@@DIFF@@|$(DIFF_SQ)|' \ -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \ -e 's/@@NO_CURL@@/$(NO_CURL)/g' \ -e $(BROKEN_PATH_FIX) \ diff --git a/git-merge-one-file.sh b/git-merge-one-file.sh index 3145009f4b..b86402afa5 100755 --- a/git-merge-one-file.sh +++ b/git-merge-one-file.sh @@ -107,7 +107,7 @@ case "${1:-.}${2:-.}${3:-.}" in # remove lines that are unique to ours. orig=`git-unpack-file $2` sz0=`wc -c <"$orig"` - $DIFF -u -La/$orig -Lb/$orig $orig $src2 | git apply --no-add + @@DIFF@@ -u -La/$orig -Lb/$orig $orig $src2 | git apply --no-add sz1=`wc -c <"$orig"` # If we do not have enough common material, it is not -- cgit v1.2.3 From 5e87eae97df69a48a575fd79131e85067f9dbf13 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 11 Jun 2010 09:40:25 -0700 Subject: test-lib: use DIFF definition from GIT-BUILD-OPTIONS Otherwise running individual tests from t/ directory may lack the definition of $DIFF, $GIT_TEST_CMP and friends. Noticed and initial patch provided by Thomas Rast, alternative solution suggested by Brandon Casey, which this patch implements. Signed-off-by: Junio C Hamano Acked-by: Thomas Rast --- Makefile | 6 ++++++ t/test-lib.sh | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 0367e8a958..6b3b59bef5 100644 --- a/Makefile +++ b/Makefile @@ -1944,6 +1944,12 @@ GIT-BUILD-OPTIONS: FORCE @echo NO_CURL=\''$(subst ','\'',$(subst ','\'',$(NO_CURL)))'\' >>$@ @echo NO_PERL=\''$(subst ','\'',$(subst ','\'',$(NO_PERL)))'\' >>$@ @echo NO_PYTHON=\''$(subst ','\'',$(subst ','\'',$(NO_PYTHON)))'\' >>$@ +ifdef GIT_TEST_CMP + @echo GIT_TEST_CMP=\''$(subst ','\'',$(subst ','\'',$(GIT_TEST_CMP)))'\' >>$@ +endif +ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT + @echo GIT_TEST_CMP_USE_COPIED_CONTEXT=YesPlease >>$@ +endif ### Detect Tck/Tk interpreter path changes ifndef NO_TCLTK diff --git a/t/test-lib.sh b/t/test-lib.sh index a290011fa7..eafe146601 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -64,16 +64,6 @@ export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME export EDITOR -if test -z "$GIT_TEST_CMP" -then - if test -n "$GIT_TEST_CMP_USE_COPIED_CONTEXT" - then - GIT_TEST_CMP="$DIFF -c" - else - GIT_TEST_CMP="$DIFF -u" - fi -fi - # Protect ourselves from common misconfiguration to export # CDPATH into the environment unset CDPATH @@ -691,6 +681,16 @@ export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_CONFIG_NOGLOB . ../GIT-BUILD-OPTIONS +if test -z "$GIT_TEST_CMP" +then + if test -n "$GIT_TEST_CMP_USE_COPIED_CONTEXT" + then + GIT_TEST_CMP="$DIFF -c" + else + GIT_TEST_CMP="$DIFF -u" + fi +fi + GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git export GITPERLLIB test -d ../templates/blt || { -- cgit v1.2.3