threads / patch / 23037

patch, 15 partsuser-cppflags.patch

Subject: [patch 01/15] user-cppflags.patch

## tl;dr

37 messages between Mar 16, 2010 and Apr 25, 2010. Diffs are folded; open one to read it.

replies: 36people: 6as markdown or json

Gary V. Vaughan· Mar 16, 2010, 05:42 UTC · lore

[patch 00/15] Portability Patches v3

Here are the portability patches we needed at TWW to enable git-1.7.0.2 to compile and run on all of the wide range of Unix machines we support. These patches apply to the git-1.7.0.2 release, and address all of the feedback from the previous two times I posted them to this list, most particularly splitting everything into many small self-contained chunks.

Note that I have not invested the time to figure out why the testsuite is mostly useless on everything but Linux and Solaris 8+, because I'm reasonably satisfied that the build itself is working properly. Most likely, it is merely GNUisms in the way the test cases call external tools. But maybe I'm missing something, but even the 3 new patches to address test errors when diff does not support the -u option don't improve the testsuite situation on HPUX, AIX, OSF1 and Solaris 7 and older.

Cheers,
-- 
Gary V. Vaughan (gary@thewrittenword.com)
Gary V. Vaughan· Mar 16, 2010, 05:42 UTC · re: Gary V. Vaughan · lore

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}" <<...>>
---
 Makefile      |    6 ++++--
 config.mak.in |    1 +
 configure.ac  |    1 +
 3 files changed, 6 insertions(+), 2 deletions(-)
Show changes to 2 files +2 −1

Makefile, config.mak.in

Index: b/Makefile
===================================================================
--- a/Makefile
+++ b/Makefile
@@ -236,7 +236,7 @@ endif
 
 CFLAGS = -g -O2 -Wall
 LDFLAGS =
-ALL_CFLAGS = $(CFLAGS)
+ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS)
 ALL_LDFLAGS = $(LDFLAGS)
 STRIP ?= strip
 
Index: b/config.mak.in
===================================================================
--- 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@
-- 
Gary V. Vaughan (gary@thewrittenword.com)
Gary V. Vaughan· Mar 16, 2010, 05:42 UTC · re: Gary V. Vaughan · lore

[patch 02/15] const-expr.patch

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.
---
 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           |   19 ++++++++++---------
 ll-merge.c         |   14 +++++++-------
 refs.c             |    6 +++++-
 remote.c           |    3 +--
 unpack-trees.c     |    4 +++-
 wt-status.c        |   23 ++++++++++++-----------
 14 files changed, 67 insertions(+), 45 deletions(-)
Show changes to 14 files +67 −45

convert.c, remote.c, unpack-trees.c, daemon.c, wt-status.c, ll-merge.c, builtin-commit.c, builtin-remote.c, builtin-blame.c, builtin-cat-file.c, refs.c, builtin-add.c, builtin-checkout.c, builtin-fetch.c

Index: b/convert.c
===================================================================
--- a/convert.c
+++ b/convert.c
@@ -249,7 +249,9 @@ static int filter_buffer(int in, int out
 	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;
Index: b/remote.c
===================================================================
--- a/remote.c
+++ b/remote.c
@@ -657,10 +657,9 @@ static struct refspec *parse_refspec_int
 
 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;
 }
Index: b/unpack-trees.c
===================================================================
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -287,9 +287,11 @@ static void add_same_unmerged(struct cac
 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, NULL };
 	int ret;
 
+	src[0] = ce;
+
 	mark_ce_used(ce, o);
 	if (ce_stage(ce)) {
 		if (o->skip_unmerged) {
Index: b/daemon.c
===================================================================
--- 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);
Index: b/wt-status.c
===================================================================
--- a/wt-status.c
+++ b/wt-status.c
@@ -464,17 +464,18 @@ static void wt_status_print_submodule_su
 	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);
Index: b/ll-merge.c
===================================================================
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -172,17 +172,17 @@ static int ll_ext_merge(const struct ll_
 {
 	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[3].placeholder = NULL; dict[3].value = NULL;
+
 	if (fn->cmdline == NULL)
 		die("custom merge driver %s lacks command line.", fn->name);
 
Index: b/builtin-commit.c
===================================================================
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -715,7 +715,8 @@ static int prepare_to_commit(const char 
 
 	if (use_editor) {
 		char index[PATH_MAX];
-		const char *env[2] = { index, NULL };
+		const char *env[] = { NULL, 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,
Index: b/builtin-remote.c
===================================================================
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -705,11 +705,14 @@ static int rm(int argc, const char **arg
 	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);
 
Index: b/builtin-blame.c
===================================================================
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -733,10 +733,11 @@ static int pass_blame_to_parent(struct s
 {
 	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 sco
 	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.
 	 */
Index: b/builtin-cat-file.c
===================================================================
--- a/builtin-cat-file.c
+++ b/builtin-cat-file.c
@@ -118,7 +118,9 @@ static int cat_one_file(int opt, const c
 
 		/* custom pretty-print here */
 		if (type == OBJ_TREE) {
-			const char *ls_args[3] = {"ls-tree", obj_name, NULL};
+			const char *ls_args[3] = { NULL, NULL, NULL };
+			ls_args[0] =  "ls-tree";
+			ls_args[1] =  obj_name;
 			return cmd_ls_tree(2, ls_args, NULL);
 		}
 
Index: b/refs.c
===================================================================
--- a/refs.c
+++ b/refs.c
@@ -311,7 +311,11 @@ static int warn_if_dangling_symref(const
 
 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);
 }
 
Index: b/builtin-add.c
===================================================================
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -255,12 +255,14 @@ static int edit_patch(int argc, const ch
 {
 	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)
Index: b/builtin-checkout.c
===================================================================
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -612,7 +612,8 @@ static int check_tracking_name(const cha
 
 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;
Index: b/builtin-fetch.c
===================================================================
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -573,9 +573,10 @@ static void find_non_local_tags(struct t
 {
 	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) {
@@ -768,7 +769,8 @@ static int get_remote_group(const char *
 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) {
-- 
Gary V. Vaughan (gary@thewrittenword.com)
Johannes Sixt· Mar 16, 2010, 07:31 UTC · re: Gary V. Vaughan · lore

Re: [patch 02/15] const-expr.patch

Gary V. Vaughan schrieb:
Show 5 quoted lines
> 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).

Yes, a comprehensive list would be appreciated. This change is an uglification that I personally would prefer to stay out of the code base unless many consumers of git are hurt.

The problem with this non-feature is that it is all too easy that new code introduces new incompatibilities.

> Index: b/ll-merge.c
> ===================================================================
> --- a/ll-merge.c
> +++ b/ll-merge.c
BTW, did you notice that git is a version control system that hosts itself? ;)
Show 5 quoted lines
> +	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[3].placeholder = NULL; dict[3].value = NULL;
	dict[4]...
-- Hannes
Gary V. Vaughan· Mar 16, 2010, 08:23 UTC · re: Johannes Sixt · lore

Re: [patch 02/15] const-expr.patch

On Tue, Mar 16, 2010 at 08:31:40AM +0100, Johannes Sixt wrote:
Show 10 quoted lines
> Gary V. Vaughan schrieb:
> > 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).
> 
> Yes, a comprehensive list would be appreciated. This change is an
> uglification that I personally would prefer to stay out of the code base
> unless many consumers of git are hurt.

Portable code is rarely pretty... just take a look at the output of autoconf or automake.

Of the various architectures we support, the latest vendor compilers for IRIX 6.5 and older, and for HP-UX 10.20 and older do not compile dynamic compound declarations, throwing errors such as:

cc-1028 cc: ERROR File = const-expr.c, Line = 6
  The expression used must have a constant value.
      const char *array[2] = { str, NULL };
                               ^
1 error detected in the compilation of "const-expr.c".
> The problem with this non-feature is that it is all too easy that new code
> introduces new incompatibilities.

Do you mean that new code may prevent the code from compiling on those machines again? Well, that's kinda the same problem you have when you wish to support any architecture that you don't have access to... the beauty of free software is that if it bites any significant number of people you will get bug reports, and probably patches for as long as people want to use the software on those machines.

Show 6 quoted lines
> > Index: b/ll-merge.c
> > ===================================================================
> > --- a/ll-merge.c
> > +++ b/ll-merge.c
> 
> BTW, did you notice that git is a version control system that hosts itself? ;)

I did... but we use the SCM neutral quilt package to manage our local stack of per-package patches. I'm not particularly fluent with git yet, and it took only a couple of minutes to get quilt to submit a message threaded set of patch emails to the list in a git-like format.

Does git absolutely require that you clone the entire project history to your local disk? For the thousands of ports we maintain, that would fast become a giant chunk of disk!

Show 7 quoted lines
> > +	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[3].placeholder = NULL; dict[3].value = NULL;
> 
> 	dict[4]...
Oops.  Nice catch, thanks.
Cheers,
-- 
Gary V. Vaughan (gary@thewrittenword.com)
Avery Pennarun· Mar 16, 2010, 23:43 UTC · re: Johannes Sixt · lore

Re: [patch 02/15] const-expr.patch

On Tue, Mar 16, 2010 at 3:31 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:
Show 13 quoted lines
> Gary V. Vaughan schrieb:
>> 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).
>
> Yes, a comprehensive list would be appreciated. This change is an
> uglification that I personally would prefer to stay out of the code base
> unless many consumers of git are hurt.
>
> The problem with this non-feature is that it is all too easy that new code
> introduces new incompatibilities.

This is probably a stupid question, but why not just build it using gcc on systems with a broken vendor compiler? You don't have to distribute gcc just to distribute binaries built with it, so it seems like there's no downside... and less suffering for the build maintainer.

Have fun,
Avery
Gary V. Vaughan· Apr 25, 2010, 08:38 UTC · re: Avery Pennarun · lore

Re: [patch 02/15] const-expr.patch

[It seems like all my replies to this list don't make it through, even though I'm able to post a new thread. Please forward on my behalf.]

On Tue, Mar 16, 2010 at 07:43:54PM -0400, Avery Pennarun wrote:
Show 20 quoted lines
> On Tue, Mar 16, 2010 at 3:31 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:
> > Gary V. Vaughan schrieb:
> >> 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).
> >
> > Yes, a comprehensive list would be appreciated. This change is an
> > uglification that I personally would prefer to stay out of the code base
> > unless many consumers of git are hurt.
> >
> > The problem with this non-feature is that it is all too easy that new code
> > introduces new incompatibilities.
> 
> This is probably a stupid question, but why not just build it using
> gcc on systems with a broken vendor compiler?  You don't have to
> distribute gcc just to distribute binaries built with it, so it seems
> like there's no downside... and less suffering for the build
> maintainer.

More often than not the vendor compiler produces better code than gcc on any given architecture, and one of the features of the TWW package builds is that in the vast majority of cases we port the upstream code to build using the vendor compiler, because this is what our customers want.

Cheers,
-- 
Gary V. Vaughan (gary@thewrittenword.com)
Gary V. Vaughan· Mar 16, 2010, 05:42 UTC · re: Gary V. Vaughan · lore

[patch 03/15] pthread.patch

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.
---
 Makefile      |    4 ++++
 config.mak.in |    1 +
 configure.ac  |   17 +++++++++++++++--
 3 files changed, 20 insertions(+), 2 deletions(-)
Show changes to 3 files +20 −2

Makefile, configure.ac, config.mak.in

Index: b/Makefile
===================================================================
--- a/Makefile
+++ b/Makefile
@@ -287,6 +287,7 @@ RPMBUILD = rpmbuild
 TCL_PATH = tclsh
 TCLTK_PATH = wish
 PTHREAD_LIBS = -lpthread
+PTHREAD_CFLAGS =
 
 export TCL_PATH TCLTK_PATH
 
@@ -856,6 +857,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)
@@ -1297,6 +1300,7 @@ endif
 ifdef NO_PTHREADS
 	BASIC_CFLAGS += -DNO_PTHREADS
 else
+	BASIC_CFLAGS += $(PTHREAD_CFLAGS)
 	EXTLIBS += $(PTHREAD_LIBS)
 	LIB_OBJS += thread-utils.o
 endif
Index: b/configure.ac
===================================================================
--- a/configure.ac
+++ b/configure.ac
@@ -782,7 +782,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;
 }
 ])
 
@@ -799,7 +803,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'])
@@ -807,11 +812,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"
@@ -828,6 +840,7 @@ fi
 
 CFLAGS="$old_CFLAGS"
 
+AC_SUBST(PTHREAD_CFLAGS)
 AC_SUBST(PTHREAD_LIBS)
 AC_SUBST(NO_PTHREADS)
 
Index: b/config.mak.in
===================================================================
--- 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@
-- 
Gary V. Vaughan (gary@thewrittenword.com)
Gary V. Vaughan· Mar 16, 2010, 05:42 UTC · re: Gary V. Vaughan · lore

[patch 04/15] diff-export.patch

Some of the flags used with the first diff found in PATH cause the
vendor diff to choke.
---
 Documentation/install-webdoc.sh |    2 +-
 Makefile                        |    4 +++-
 config.mak.in                   |    1 +
 configure.ac                    |    1 +
 git-merge-one-file.sh           |    2 +-
 t/Makefile                      |    1 +
 6 files changed, 8 insertions(+), 3 deletions(-)
Show changes to 5 files +7 −3

Makefile, configure.ac, Documentation/install-webdoc.sh, git-merge-one-file.sh, config.mak.in

Index: b/Makefile
===================================================================
--- a/Makefile
+++ b/Makefile
@@ -280,6 +280,7 @@ export prefix bindir sharedir sysconfdir
 CC = gcc
 AR = ar
 RM = rm -f
+DIFF = diff
 TAR = tar
 FIND = find
 INSTALL = install
@@ -1408,7 +1409,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
@@ -1698,6 +1699,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)))'\' >>$@
Index: b/configure.ac
===================================================================
--- a/configure.ac
+++ b/configure.ac
@@ -342,6 +342,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
Index: b/Documentation/install-webdoc.sh
===================================================================
--- 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
Index: b/git-merge-one-file.sh
===================================================================
--- 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
Index: b/config.mak.in
===================================================================
--- 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@
 
-- 
Gary V. Vaughan (gary@thewrittenword.com)
Gary V. Vaughan· Mar 16, 2010, 05:42 UTC · re: Gary V. Vaughan · lore

[patch 05/15] diff-test_cmp.patch

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.
---
 t/Makefile                      |    1 +
 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 |   24 ++++++++++++------------
 19 files changed, 67 insertions(+), 66 deletions(-)
Show changes to 19 files +67 −66

t/t0000-basic.sh, t/t3200-branch.sh, t/t3210-pack-refs.sh, t/t4002-diff-basic.sh, t/t4124-apply-ws-rule.sh, t/t5300-pack-object.sh, t/t5510-fetch.sh, t/t5520-pull.sh, t/t5700-clone-reference.sh, t/t6000lib.sh, t/t6001-rev-list-graft.sh, t/t6022-merge-rename.sh, t/t7002-grep.sh, t/t7005-editor.sh, t/t9200-git-cvsexportcommit.sh, t/t9400-git-cvsserver-server.sh, t/t3903-stash.sh, t/t4127-apply-same-fn.sh, t/Makefile

Index: b/t/t0000-basic.sh
===================================================================
--- 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.' \
Index: b/t/t3200-branch.sh
===================================================================
--- 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 &&
Index: b/t/t3210-pack-refs.sh
===================================================================
--- 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 rep
 	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
Index: b/t/t4002-diff-basic.sh
===================================================================
--- 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 \
Index: b/t/t4124-apply-ws-rule.sh
===================================================================
--- 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 <fixed)
@@ -85,14 +85,14 @@ test_expect_success setup '
 test_expect_success 'whitespace=nowarn, default rule' '
 
 	apply_patch --whitespace=nowarn &&
-	diff file target
+	test_cmp file target
 
 '
 
 test_expect_success 'whitespace=warn, default rule' '
 
 	apply_patch --whitespace=warn &&
-	diff file target
+	test_cmp file target
 
 '
 
@@ -108,7 +108,7 @@ test_expect_success 'whitespace=error-al
 
 	git config core.whitespace -trailing,-space-before,-indent &&
 	apply_patch --whitespace=error-all &&
-	diff file target
+	test_cmp file target
 
 '
 
@@ -117,7 +117,7 @@ test_expect_success 'whitespace=error-al
 	git config --unset core.whitespace &&
 	echo "target -whitespace" >.gitattributes &&
 	apply_patch --whitespace=error-all &&
-	diff file target
+	test_cmp file target
 
 '
 
Index: b/t/t5300-pack-object.sh
===================================================================
--- 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 <obj-list
     } >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 <obj-list
     } >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 <obj-list
     } >current &&
-    diff expect current'
+    test_cmp expect current'
 
 unset GIT_OBJECT_DIRECTORY
 
Index: b/t/t5510-fetch.sh
===================================================================
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -71,7 +71,7 @@ test_expect_success "fetch test for-merg
 		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' '
 
Index: b/t/t5520-pull.sh
===================================================================
--- 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' '
Index: b/t/t5700-clone-reference.sh
===================================================================
--- a/t/t5700-clone-reference.sh
+++ b/t/t5700-clone-reference.sh
@@ -48,7 +48,7 @@ test_expect_success 'that reference gets
 '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 o
 '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 expec
 'cd D &&
 echo "5 objects" > expected &&
 git count-objects | cut -d, -f1 > current &&
-diff expected current'
+test_cmp expected current'
 
 cd "$base_dir"
 
Index: b/t/t6000lib.sh
===================================================================
--- 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
Index: b/t/t6001-rev-list-graft.sh
===================================================================
--- 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
Index: b/t/t6022-merge-rename.sh
===================================================================
--- a/t/t6022-merge-rename.sh
+++ b/t/t6022-merge-rename.sh
@@ -280,7 +280,7 @@ test_expect_success 'updated working tre
 		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 tre
 		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
 	}
Index: b/t/t7002-grep.sh
===================================================================
--- 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)" '
Index: b/t/t7005-editor.sh
===================================================================
--- 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
 
Index: b/t/t9200-git-cvsexportcommit.sh
===================================================================
--- 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 \
Index: b/t/t9400-git-cvsserver-server.sh
===================================================================
--- a/t/t9400-git-cvsserver-server.sh
+++ b/t/t9400-git-cvsserver-server.sh
@@ -226,7 +226,7 @@ test_expect_success 'gitcvs.ext.enabled 
   'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
    GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false &&
    GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
-   diff -q cvswork cvswork2'
+   test_cmp cvswork cvswork2' >/dev/null
 
 rm -fr cvswork2
 test_expect_success 'gitcvs.ext.enabled = false' \
@@ -247,7 +247,7 @@ test_expect_success 'gitcvs.dbname' \
   'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
    GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs.%a.%m.sqlite &&
    GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
-   diff -q cvswork cvswork2 &&
+   test_cmp cvswork cvswork2 >/dev/null &&
    test -f "$SERVERDIR/gitcvs.ext.master.sqlite" &&
    cmp "$SERVERDIR/gitcvs.master.sqlite" "$SERVERDIR/gitcvs.ext.master.sqlite"'
 
@@ -257,7 +257,7 @@ test_expect_success 'gitcvs.ext.dbname' 
    GIT_DIR="$SERVERDIR" git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite &&
    GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite &&
    GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
-   diff -q cvswork cvswork2 &&
+   test_cmp cvswork cvswork2 >/dev/null &&
    test -f "$SERVERDIR/gitcvs1.ext.master.sqlite" &&
    test ! -f "$SERVERDIR/gitcvs2.ext.master.sqlite" &&
    cmp "$SERVERDIR/gitcvs.master.sqlite" "$SERVERDIR/gitcvs1.ext.master.sqlite"'
@@ -282,7 +282,7 @@ test_expect_success 'cvs update (create 
    cd cvswork &&
    GIT_CONFIG="$git_config" cvs -Q update &&
    test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.1/" &&
-   diff -q testfile1 ../testfile1'
+   test_cmp testfile1 ../testfile1' >/dev/null
 
 cd "$WORKDIR"
 test_expect_success 'cvs update (update existing file)' \
@@ -293,7 +293,7 @@ test_expect_success 'cvs update (update 
    cd cvswork &&
    GIT_CONFIG="$git_config" cvs -Q update &&
    test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.2/" &&
-   diff -q testfile1 ../testfile1'
+   test_cmp testfile1 ../testfile1' >/dev/null
 
 cd "$WORKDIR"
 #TODO: cvsserver doesn't support update w/o -d
@@ -322,7 +322,7 @@ test_expect_success 'cvs update (subdire
    (for dir in A A/B A/B/C A/D E; do
       filename="file_in_$(echo $dir|sed -e "s#/# #g")" &&
       if test "$(echo $(grep -v ^D $dir/CVS/Entries|cut -d/ -f2,3,5))" = "$filename/1.1/" &&
-           diff -q "$dir/$filename" "../$dir/$filename"; then
+           test_cmp "$dir/$filename" "../$dir/$filename" >/dev/null; then
         :
       else
         echo >failure
@@ -349,7 +349,7 @@ test_expect_success 'cvs update (re-add 
    cd cvswork &&
    GIT_CONFIG="$git_config" cvs -Q update &&
    test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.4/" &&
-   diff -q testfile1 ../testfile1'
+   test_cmp testfile1 ../testfile1' >/dev/null
 
 cd "$WORKDIR"
 test_expect_success 'cvs update (merge)' \
@@ -366,7 +366,7 @@ test_expect_success 'cvs update (merge)'
    cd cvswork &&
    GIT_CONFIG="$git_config" cvs -Q update &&
    test "$(echo $(grep merge CVS/Entries|cut -d/ -f2,3,5))" = "merge/1.1/" &&
-   diff -q merge ../merge &&
+   test_cmp merge ../merge >/dev/null &&
    ( echo Line 0; cat merge ) >merge.tmp &&
    mv merge.tmp merge &&
    cd "$WORKDIR" &&
@@ -377,7 +377,7 @@ test_expect_success 'cvs update (merge)'
    cd cvswork &&
    sleep 1 && touch merge &&
    GIT_CONFIG="$git_config" cvs -Q update &&
-   diff -q merge ../expected'
+   test_cmp merge ../expected' >/dev/null
 
 cd "$WORKDIR"
 
@@ -402,13 +402,13 @@ test_expect_success 'cvs update (conflic
    git push gitcvs.git >/dev/null &&
    cd cvswork &&
    GIT_CONFIG="$git_config" cvs -Q update &&
-   diff -q merge ../expected.C'
+   test_cmp merge ../expected.C' >/dev/null
 
 cd "$WORKDIR"
 test_expect_success 'cvs update (-C)' \
   'cd cvswork &&
    GIT_CONFIG="$git_config" cvs -Q update -C &&
-   diff -q merge ../merge'
+   test_cmp merge ../merge' >/dev/null
 
 cd "$WORKDIR"
 test_expect_success 'cvs update (merge no-op)' \
@@ -420,7 +420,7 @@ test_expect_success 'cvs update (merge n
     cd cvswork &&
     sleep 1 && touch merge &&
     GIT_CONFIG="$git_config" cvs -Q update &&
-    diff -q merge ../merge'
+    test_cmp merge ../merge' >/dev/null
 
 cd "$WORKDIR"
 test_expect_success 'cvs update (-p)' '
Index: b/t/t3903-stash.sh
===================================================================
--- 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) &&
Index: b/t/t4127-apply-same-fn.sh
===================================================================
--- a/t/t4127-apply-same-fn.sh
+++ b/t/t4127-apply-same-fn.sh
@@ -27,7 +27,7 @@ test_expect_success 'apply same filename
 	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
 	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 file
 	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.' '
Index: b/t/Makefile
===================================================================
--- a/t/Makefile
+++ b/t/Makefile
@@ -6,6 +6,7 @@
 -include ../config.mak
 
 #GIT_TEST_OPTS=--verbose --debug
+GIT_TEST_CMP ?= $(DIFF)
 SHELL_PATH ?= $(SHELL)
 TAR ?= $(TAR)
 RM ?= rm -f
-- 
Gary V. Vaughan (gary@thewrittenword.com)
Junio C Hamano· Mar 16, 2010, 07:21 UTC · re: Gary V. Vaughan · lore

Re: [patch 05/15] diff-test_cmp.patch

"Gary V. Vaughan" <git@mlists.thewrittenword.com> writes:
Show 10 quoted lines
> Index: b/t/t0000-basic.sh
> ===================================================================
> --- 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'

The original says "compare ignoring whitespace changes" but the updated one says "they must match literally". Is this conversion safe?

For the purpose of debugging tests, I think it would be better to lose the redirection into /dev/null. If the test passes, we wouldn't see anything anyway, and if the test fails, we would see what's different, and that helps diagnosing the breakage. For systems with implementations of diff that is "-u" challenged, we could define test_cmp in terms of "diff -c" instead of "cmp".

Show 10 quoted lines
> Index: b/t/t9400-git-cvsserver-server.sh
> ===================================================================
> --- a/t/t9400-git-cvsserver-server.sh
> +++ b/t/t9400-git-cvsserver-server.sh
> @@ -226,7 +226,7 @@ test_expect_success 'gitcvs.ext.enabled 
>    'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
>     GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false &&
>     GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
> -   diff -q cvswork cvswork2'
> +   test_cmp cvswork cvswork2' >/dev/null

If the -q in the original really matters, then please add the redirection to /dev/null only for test_cmp; never redirect the output from the entire test_expect_success. On the other hand, if -q does not matter the outcome of the test, simply lose the "quiet". We really should not care, and make sure it is available easily to people who broke cvsserver and need to see the difference between expected and actual results while debugging.

There are similar dubious conversions in your patch to this file.
Show 9 quoted lines
> Index: b/t/Makefile
> ===================================================================
> --- a/t/Makefile
> +++ b/t/Makefile
> @@ -6,6 +6,7 @@
>  -include ../config.mak
>  
>  #GIT_TEST_OPTS=--verbose --debug
> +GIT_TEST_CMP ?= $(DIFF)

If this forces plain diff not more readable "diff -u" to everybody, that sounds like a regression to me.

Other than that, the conversion in this patch looked sane.
Thanks.
Gary V. Vaughan· Apr 25, 2010, 08:38 UTC · re: Junio C Hamano · lore

Re: [patch 05/15] diff-test_cmp.patch

Hi Junio,
Thanks for the reviews.
On Tue, Mar 16, 2010 at 12:21:01AM -0700, Junio C Hamano wrote:
Show 15 quoted lines
> "Gary V. Vaughan" <git@mlists.thewrittenword.com> writes:
> 
> > Index: b/t/t0000-basic.sh
> > ===================================================================
> > --- 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'
> 
> The original says "compare ignoring whitespace changes" but the updated
> one says "they must match literally".  Is this conversion safe?
Not all diff implementations support the '-b' option, unfortunately.

This change doesn't cause any regressions, at least the test suite continues to report success on the architectures where running it is safe (i.e. Linux and Solaris 8+).

Show 6 quoted lines
> For the purpose of debugging tests, I think it would be better to lose the
> redirection into /dev/null.  If the test passes, we wouldn't see anything
> anyway, and if the test fails, we would see what's different, and that
> helps diagnosing the breakage.  For systems with implementations of diff
> that is "-u" challenged, we could define test_cmp in terms of "diff -c"
> instead of "cmp".

Agreed. For all the hosts I have access to, diff -c is always available.

Show 14 quoted lines
> > Index: b/t/t9400-git-cvsserver-server.sh
> > ===================================================================
> > --- a/t/t9400-git-cvsserver-server.sh
> > +++ b/t/t9400-git-cvsserver-server.sh
> > @@ -226,7 +226,7 @@ test_expect_success 'gitcvs.ext.enabled 
> >    'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
> >     GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false &&
> >     GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
> > -   diff -q cvswork cvswork2'
> > +   test_cmp cvswork cvswork2' >/dev/null
> 
> If the -q in the original really matters, then please add the redirection
> to /dev/null only for test_cmp; never redirect the output from the entire
> test_expect_success.
Don't worry, I didn't do that:
 $ echo 'test_expect_success' &&
 > echo 'test_cmp' >/dev/null
 test_expect_success
Show 6 quoted lines
> On the other hand, if -q does not matter the outcome
> of the test, simply lose the "quiet".  We really should not care, and make
> sure it is available easily to people who broke cvsserver and need to see
> the difference between expected and actual results while debugging.
> 
> There are similar dubious conversions in your patch to this file.

I'd be even happier to see the >/dev/null redirections dropped if the patch is pushed. Part of the reason I didn't invest too much effort into debugging the massive testsuite failures everything but Linux and Solaris 8+ is because it's too difficult to find out why a particular test actually failed.

Show 12 quoted lines
> > Index: b/t/Makefile
> > ===================================================================
> > --- a/t/Makefile
> > +++ b/t/Makefile
> > @@ -6,6 +6,7 @@
> >  -include ../config.mak
> >  
> >  #GIT_TEST_OPTS=--verbose --debug
> > +GIT_TEST_CMP ?= $(DIFF)
> 
> If this forces plain diff not more readable "diff -u" to everybody, that
> sounds like a regression to me.
It does, because "diff -u" is not portable.

A more comprehensive patch might run a configure test to see whether -u is supported, and then fallback first to "${ac_cv_prog_DIFF} -c", or if that breaks too, finally settle on "cmp". And then we'd have to set matching defaults in Makefile.

I'm afraid I don't have time to help with that, since the testsuite is so very broken on nearly all of our architectures. I'll post some examples presently.

Cheers,
-- 
Gary V. Vaughan (gary@thewrittenword.com)
Gary V. Vaughan· Mar 16, 2010, 05:42 UTC · re: Gary V. Vaughan · lore

[patch 06/15] diff-defaults.patch

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.  As a matter of fact, the testsuite as a whole still
fails around 70% of all tests, but I'm able to clone a repository and
commit to a local branch on those machines, so I'm pretty sure that
the problem is the testsuite itself.
---
 Makefile |   15 +++++++++++++++
 1 file changed, 15 insertions(+)
Show changes to 2 files +16 −0

Makefile, t/Makefile

Index: b/Makefile
===================================================================
--- a/Makefile
+++ b/Makefile
@@ -767,6 +767,16 @@ ifeq ($(uname_S),SunOS)
 	NO_MKDTEMP = YesPlease
 	NO_MKSTEMPS = YesPlease
 	NO_REGEX = YesPlease
+	ifeq ($(uname_R),5.6)
+		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
@@ -776,18 +786,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
@@ -861,6 +874,7 @@ ifeq ($(uname_S),AIX)
 	else
 		PTHREAD_LIBS = -lpthread
 	endif
+	GIT_TEST_CMP = cmp
 endif
 ifeq ($(uname_S),GNU)
 	# GNU/Hurd
@@ -915,6 +929,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
Index: b/t/Makefile
===================================================================
--- 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
-- 
Gary V. Vaughan (gary@thewrittenword.com)
Junio C Hamano· Mar 16, 2010, 07:22 UTC · re: Gary V. Vaughan · lore

Re: [patch 06/15] diff-defaults.patch

"Gary V. Vaughan" <git@mlists.thewrittenword.com> writes:
Show 6 quoted lines
> 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.

Wouldn't most of these platforms you listed have a working "diff -c" at least? Using it would make debugging the tests easier, as it would be more readable than output from "cmp".

I also saw your patch to install-webdoc used "$DIFF -u"; as the patch series seem to assume a unified-capable diff implementation is available somewhere, perhaps you do not need this patch after all, but instead just need to default GIT_TEST_CMP to "$DIFF -u" in t/test-lib.sh, no?

Gary V. Vaughan· Apr 25, 2010, 08:38 UTC · re: Junio C Hamano · lore

Re: [patch 06/15] diff-defaults.patch

On Tue, Mar 16, 2010 at 12:22:53AM -0700, Junio C Hamano wrote:
Show 12 quoted lines
> "Gary V. Vaughan" <git@mlists.thewrittenword.com> writes:
> 
> > 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.
> 
> Wouldn't most of these platforms you listed have a working "diff -c" at
> least?  Using it would make debugging the tests easier, as it would be
> more readable than output from "cmp".

Yes, I've checked, and everything I have access to supports "diff -c" with the vendor implementation.

> I also saw your patch to install-webdoc used "$DIFF -u"; as the patch
> series seem to assume a unified-capable diff implementation is available
> somewhere, perhaps you do not need this patch after all, but instead just
> need to default GIT_TEST_CMP to "$DIFF -u" in t/test-lib.sh, no?

That is more than adequate for me, since one of our packages is GNU diffutils, and my git build recipe puts the path to our diffutils package first in PATH before launching configure and make.

However, anyone else that wants to build git on a non-"diff -u" capable machine won't necessarily have this luxury. At the moment it's hard for me to tell whether the diff changes are a net win, since I can't get the testsuite to run properly on any of the architectures that would be affected.

Cheers,
-- 
Gary V. Vaughan (gary@thewrittenword.com)
Gary V. Vaughan· Mar 16, 2010, 05:42 UTC · re: Gary V. Vaughan · lore

[patch 07/15] host-IRIX.patch

Irix 6.5 does not define 'sgi', but does define '__sgi'.
Also, Irix 6.5 requires _BSD_TYPES to be defined in order for the BSD
u_short types et. al. to be declared properly.
---
 git-compat-util.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Show changes to git-compat-util.h +2 −1
Index: b/git-compat-util.h
===================================================================
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -55,13 +55,14 @@
 # else
 # define _XOPEN_SOURCE 500
 # endif
-#elif !defined(__APPLE__) && !defined(__FreeBSD__)  && !defined(__USLC__) && !defined(_M_UNIX) && !defined(sgi)
+#elif !defined(__APPLE__) && !defined(__FreeBSD__)  && !defined(__USLC__) && !defined(_M_UNIX) && !defined(__sgi)
 #define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
 #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
 #endif
 #define _ALL_SOURCE 1
 #define _GNU_SOURCE 1
 #define _BSD_SOURCE 1
+#define _BSD_TYPES 1 /* IRIX needs this for u_short et al */
 #define _NETBSD_SOURCE 1
 #define _SGI_SOURCE 1
 
-- 
Gary V. Vaughan (gary@thewrittenword.com)
Junio C Hamano· Mar 16, 2010, 07:24 UTC · re: Gary V. Vaughan · lore

Re: [patch 07/15] host-IRIX.patch

"Gary V. Vaughan" <git@mlists.thewrittenword.com> writes:
> Irix 6.5 does not define 'sgi', but does define '__sgi'.
>
> Also, Irix 6.5 requires _BSD_TYPES to be defined in order for the BSD
> u_short types et. al. to be declared properly.

If Irix 6.5 defines __sgi and the patch _adds_ "defined(__sgi)" I wouldn't have to worry too much, but would replacing "defined(sgi)" with the double-underscore version make somebody who added "defined(sgi)" in the first place cry, if it was done for different version of Irix that does define "sgi" (worse yet, but not "__sgi")?

Another natural question is if defining _BSD_TYPES everywhere has negative effects on somebody else's platforms, but that is what people on different platforms will have to apply this patch, test, and report success or breakage. Help from the list audience is appreciated.

Thanks.
Gary V. Vaughan· Apr 25, 2010, 08:39 UTC · re: Junio C Hamano · lore

Re: [patch 07/15] host-IRIX.patch

On Tue, Mar 16, 2010 at 12:24:36AM -0700, Junio C Hamano wrote:
Show 12 quoted lines
> "Gary V. Vaughan" <git@mlists.thewrittenword.com> writes:
> 
> > Irix 6.5 does not define 'sgi', but does define '__sgi'.
> >
> > Also, Irix 6.5 requires _BSD_TYPES to be defined in order for the BSD
> > u_short types et. al. to be declared properly.
> 
> If Irix 6.5 defines __sgi and the patch _adds_ "defined(__sgi)" I wouldn't
> have to worry too much, but would replacing "defined(sgi)" with the
> double-underscore version make somebody who added "defined(sgi)" in the
> first place cry, if it was done for different version of Irix that does
> define "sgi" (worse yet, but not "__sgi")?

Agreed. I've amended my local version of this patch to check both (sgi) and (__sgi) now. Thanks.

> Another natural question is if defining _BSD_TYPES everywhere has negative
> effects on somebody else's platforms, but that is what people on different
> platforms will have to apply this patch, test, and report success or
> breakage.  Help from the list audience is appreciated.
Good point.  Perhaps better to make that change in the Makefile?
ifeq ($(uname_S),IRIX64)
        # Need this for u_short definitions et al
        BASIC_CFLAGS += -D_BSD_TYPES
endif

I only have use of mips-sgi-irix6.5 machines, so I'm not sure what other versions are affected... probably a safe bet that ifeq($(uname_S),IRIX) should get that definition too.

Cheers,
-- 
Gary V. Vaughan (gary@thewrittenword.com)
Brandon Casey· Mar 16, 2010, 15:27 UTC · re: Gary V. Vaughan · lore

Re: [patch 07/15] host-IRIX.patch

On 03/16/2010 12:42 AM, Gary V. Vaughan wrote:
Show 5 quoted lines
> 
> Irix 6.5 does not define 'sgi', but does define '__sgi'.
> 
> Also, Irix 6.5 requires _BSD_TYPES to be defined in order for the BSD
> u_short types et. al. to be declared properly.
Which IRIX release (uname -R) and compiler version are you using?
I have IRIX 6.5.29m and MIPSpro Compiler 7.4.4m.

Both 'sgi' and '__sgi' appear to be predefined by the preprocessor on my system. I wasn't aware of '__sgi' when I added 'sgi', otherwise I would have used it.

On my system, defining _SGI_SOURCE causes _SGIAPI to be enabled which causes all of the BSD types to be enabled. In my header files in /usr/include/ everywhere I see a test for _BSD_TYPES, I also see a test for _SGIAPI (or something equivalent) like this:

   #if _SGIAPI || defined(_BSD_TYPES)

So defining _BSD_TYPES will probably not affect compiling on IRIX for me (though I haven't tested your patches yet), but do your header files not do the same thing with _SGI_SOURCE, _SGIAPI, and _BSD_TYPES?

Which shell are you using? Bash? or the native Korn shell? If you're trying to use the Korn shell, then you'll need a patch to t/test-lib.sh in order for the test suite to work properly. I can send it to you if you'd like.

I compile and test with the following config.mak settings:
GIT_SKIP_TESTS := \
   t3900.1[129] t3900.2[0234] \
   t5100.5 t5100.1[09] \
   t8005.[234]
export GIT_SKIP_TESTS

# perl 5.8.0 # python 2.1 # GNU tar 1.2 PERL_PATH = /apps/bin/perl PYTHON_PATH = /apps/bin/python TAR = /sw/local/bin/gtar

CC = c99 CFLAGS = -n32 -O2

NO_C99_FORMAT = 1 NO_CURL = 1 NO_TCLTK = 1 NO_MMAP = NO_OPENSSL = 1 BLK_SHA1 = 1 DEFAULT_PAGER = more

# For IRIX <= 6.5.20 compatibility (uname -R) # i.e. the next two are not necessary for IRIX > 6.5.20 NO_STRLCPY = 1 NO_DEFLATE_BOUND = 1

-brandon
Gary V. Vaughan· Apr 25, 2010, 08:39 UTC · re: Brandon Casey · lore

Re: [patch 07/15] host-IRIX.patch

[It seems that while the list allows me to start a new thread, all my replies are actually discarded or held for moderation :( Please forward a copy to the list on my behalf]

On Tue, Mar 16, 2010 at 10:27:07AM -0500, Brandon Casey wrote:
Show 10 quoted lines
> On 03/16/2010 12:42 AM, Gary V. Vaughan wrote:
> > 
> > Irix 6.5 does not define 'sgi', but does define '__sgi'.
> > 
> > Also, Irix 6.5 requires _BSD_TYPES to be defined in order for the BSD
> > u_short types et. al. to be declared properly.
> 
> Which IRIX release (uname -R) and compiler version are you using?
> 
> I have IRIX 6.5.29m and MIPSpro Compiler 7.4.4m.
IRIX 6.5.26m here, with the same compiler.
> Both 'sgi' and '__sgi' appear to be predefined by the preprocessor
> on my system.  I wasn't aware of '__sgi' when I added 'sgi', otherwise
> I would have used it.
I was quite surprised too, but __sgi is necessary here.
Show 10 quoted lines
> On my system, defining _SGI_SOURCE causes _SGIAPI to be enabled which
> causes all of the BSD types to be enabled.  In my header files in
> /usr/include/ everywhere I see a test for _BSD_TYPES, I also see a
> test for _SGIAPI (or something equivalent) like this:
> 
>    #if _SGIAPI || defined(_BSD_TYPES)
> 
> So defining _BSD_TYPES will probably not affect compiling on IRIX for
> me (though I haven't tested your patches yet), but do your header
> files not do the same thing with _SGI_SOURCE, _SGIAPI, and _BSD_TYPES?

They do, but when I was looking for a macro to define to get the additional declarations, _BSD_TYPES was the first one I found. _SGI_SOURCE, _SGIAPI and even _BSD_COMPAT appear to work equally well.

> Which shell are you using? Bash? or the native Korn shell?  If you're
> trying to use the Korn shell, then you'll need a patch to t/test-lib.sh
> in order for the test suite to work properly.  I can send it to you if
> you'd like.

I believe we're using bash. At least our environment has SHELL=/opt/fsw/bash32/bin/bash and we call configure with '${SHELL} ./configure ...' and gmake with 'make SHELL=${SHELL}'. But I suppose it's possible that if t/Makefile ignores those settings and the tests begin with '#!/bin/sh', then perhaps they are using Korn shell?

Thanks, yes, I'll be interested to see your patch... but shouldn't we try to fix git in the repo so that it respects the SHELL environment and make setting?

Show 30 quoted lines
> I compile and test with the following config.mak settings:
> 
> GIT_SKIP_TESTS := \
>    t3900.1[129] t3900.2[0234] \
>    t5100.5 t5100.1[09] \
>    t8005.[234]
> export GIT_SKIP_TESTS
> 
> # perl 5.8.0
> # python 2.1
> # GNU tar 1.2
> PERL_PATH = /apps/bin/perl
> PYTHON_PATH = /apps/bin/python
> TAR = /sw/local/bin/gtar
> 
> CC = c99
> CFLAGS = -n32 -O2
> 
> NO_C99_FORMAT = 1
> NO_CURL = 1
> NO_TCLTK = 1
> NO_MMAP =
> NO_OPENSSL = 1
> BLK_SHA1 = 1
> DEFAULT_PAGER = more
> 
> # For IRIX <= 6.5.20 compatibility (uname -R)
> # i.e. the next two are not necessary for IRIX > 6.5.20
> NO_STRLCPY = 1
> NO_DEFLATE_BOUND = 1

And similarly, shouldn't these settings be fed back upstream for the benefit of other IRIX users of git?

Cheers,
-- 
Gary V. Vaughan (gary@thewrittenword.com)
Gary V. Vaughan· Mar 16, 2010, 05:42 UTC · re: Gary V. Vaughan · lore

[patch 08/15] host-HPUX10.patch

HP-UX 10.20 has no PREAD, and while it does support mmap(), there is
no system MAP_FAILED definition.
---
 Makefile          |    1 +
 git-compat-util.h |    5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)
Show changes to 2 files +7 −1

Makefile, git-compat-util.h

Index: b/Makefile
===================================================================
--- a/Makefile
+++ b/Makefile
@@ -929,6 +929,9 @@ ifeq ($(uname_S),HP-UX)
 	NO_HSTRERROR = YesPlease
 	NO_SYS_SELECT_H = YesPlease
 	SNPRINTF_RETURNS_BOGUS = YesPlease
+	ifeq ($(uname_R),B.10.20)
+		NO_PREAD = YesPlease
+	endif
 	GIT_TEST_CMP = cmp
 endif
 ifeq ($(uname_S),Windows)
Index: b/git-compat-util.h
===================================================================
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -217,7 +217,6 @@ static inline const char *skip_prefix(co
 #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_
 
 #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
-- 
Gary V. Vaughan (gary@thewrittenword.com)
Gary V. Vaughan· Mar 16, 2010, 05:42 UTC · re: Gary V. Vaughan · lore

[patch 09/15] host-HPUX11.patch

There is no nanosecond field on HPUX.
---
 Makefile |    1 +
 1 file changed, 1 insertion(+)
Show changes to Makefile +1 −0
Index: b/Makefile
===================================================================
--- a/Makefile
+++ b/Makefile
@@ -928,6 +928,7 @@ ifeq ($(uname_S),HP-UX)
 	NO_UNSETENV = YesPlease
 	NO_HSTRERROR = YesPlease
 	NO_SYS_SELECT_H = YesPlease
+	NO_NSEC = YesPlease
 	SNPRINTF_RETURNS_BOGUS = YesPlease
 	ifeq ($(uname_R),B.10.20)
 		NO_PREAD = YesPlease
-- 
Gary V. Vaughan (gary@thewrittenword.com)
Gary V. Vaughan· Mar 16, 2010, 05:42 UTC · re: Gary V. Vaughan · lore

[patch 10/15] host-OSF1.patch

Add defaults for Tru64 Unix.  Without this patch I cannot compile
git on Tru64 5.1.
---
 Makefile |    6 ++++++
 1 file changed, 6 insertions(+)
Show changes to Makefile +6 −0
Index: b/Makefile
===================================================================
--- a/Makefile
+++ b/Makefile
@@ -695,6 +695,12 @@ 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
+	NO_STRTOULL = YesPlease
+	NO_NSEC = YesPlease
+endif
 ifeq ($(uname_S),Linux)
 	NO_STRLCPY = YesPlease
 	NO_MKSTEMPS = YesPlease
-- 
Gary V. Vaughan (gary@thewrittenword.com)
Gary V. Vaughan· Mar 16, 2010, 05:42 UTC · re: Gary V. Vaughan · lore

[patch 11/15] no-hstrerror.patch

SunOS 5.6 and 5.5.1 do not have hstrerror, even in libresolv.
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.
---
 Makefile      |    1 +
 config.mak.in |    1 +
 configure.ac  |   17 ++++++++++++++---
 3 files changed, 16 insertions(+), 3 deletions(-)
Show changes to 3 files +16 −3

configure.ac, Makefile, config.mak.in

Index: b/configure.ac
===================================================================
--- a/configure.ac
+++ b/configure.ac
@@ -526,11 +526,22 @@ test -n "$NEEDS_SOCKET" && LIBS="$LIBS -
 
 #
 # 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"
 
Index: b/Makefile
===================================================================
--- a/Makefile
+++ b/Makefile
@@ -774,6 +774,7 @@ ifeq ($(uname_S),SunOS)
 	NO_MKSTEMPS = YesPlease
 	NO_REGEX = YesPlease
 	ifeq ($(uname_R),5.6)
+		NO_HSTRERROR = YesPlease
 		NO_IPV6 = YesPlease
 		NO_SOCKADDR_STORAGE = YesPlease
 		NO_UNSETENV = YesPlease
Index: b/config.mak.in
===================================================================
--- 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@
-- 
Gary V. Vaughan (gary@thewrittenword.com)
Junio C Hamano· Mar 16, 2010, 07:24 UTC · re: Gary V. Vaughan · lore

Re: [patch 11/15] no-hstrerror.patch

"Gary V. Vaughan" <git@mlists.thewrittenword.com> writes:
Show 23 quoted lines
> SunOS 5.6 and 5.5.1 do not have hstrerror, even in libresolv.
>
> 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.
> ---
>  Makefile      |    1 +
>  config.mak.in |    1 +
>  configure.ac  |   17 ++++++++++++++---
>  3 files changed, 16 insertions(+), 3 deletions(-)
>
> Index: b/configure.ac
> ===================================================================
> --- a/configure.ac
> +++ b/configure.ac
> @@ -526,11 +526,22 @@ test -n "$NEEDS_SOCKET" && LIBS="$LIBS -
>  
>  #
>  # 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.

You lost the thing they are "additional" to, so this needs a bit of rewording?

Other than that the patch looked sane (I don't have access to any vintage of Solaris these days, so I only read it through, though).

Thanks.
Gary V. Vaughan· Apr 25, 2010, 08:39 UTC · re: Junio C Hamano · lore

Re: [patch 11/15] no-hstrerror.patch

On Tue, Mar 16, 2010 at 12:24:47AM -0700, Junio C Hamano wrote:
Show 12 quoted lines
> "Gary V. Vaughan" <git@mlists.thewrittenword.com> writes:
> > @@ -526,11 +526,22 @@ test -n "$NEEDS_SOCKET" && LIBS="$LIBS -
> >  
> >  #
> >  # 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.
> 
> You lost the thing they are "additional" to, so this needs a bit of
> rewording?

I did that to minimise the changes in this patch. no-inet_ntop.patch rewrites the inet_ntop test and deletes the incomplete comment line too.

Cheers,
-- 
Gary V. Vaughan (gary@thewrittenword.com)
Gary V. Vaughan· Mar 16, 2010, 05:42 UTC · re: Gary V. Vaughan · lore

[patch 12/15] no-inet_ntop.patch

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.
---
 Makefile      |    6 ++++++
 config.mak.in |    2 ++
 configure.ac  |   38 ++++++++++++++++++++++++++++++--------
 3 files changed, 38 insertions(+), 8 deletions(-)
Show changes to 3 files +38 −8

Makefile, configure.ac, config.mak.in

Index: b/Makefile
===================================================================
--- a/Makefile
+++ b/Makefile
@@ -939,6 +939,12 @@ ifeq ($(uname_S),HP-UX)
 	SNPRINTF_RETURNS_BOGUS = YesPlease
 	ifeq ($(uname_R),B.10.20)
 		NO_PREAD = YesPlease
+		NO_INET_NTOP = YesPlease
+		NO_INET_PTON = YesPlease
+	endif
+	ifeq ($(uname_R),B.11.00)
+		NO_INET_NTOP = YesPlease
+		NO_INET_PTON = YesPlease
 	endif
 	GIT_TEST_CMP = cmp
 endif
Index: b/configure.ac
===================================================================
--- a/configure.ac
+++ b/configure.ac
@@ -525,11 +525,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.
@@ -541,8 +563,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],
@@ -772,7 +795,6 @@ GIT_CHECK_FUNC(mkstemps,
 [NO_MKSTEMPS=YesPlease])
 AC_SUBST(NO_MKSTEMPS)
 #
-#
 # Define NO_MMAP if you want to avoid mmap.
 #
 # Define NO_ICONV if your libc does not properly support iconv.
Index: b/config.mak.in
===================================================================
--- 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@
-- 
Gary V. Vaughan (gary@thewrittenword.com)
Gary V. Vaughan· Mar 16, 2010, 05:42 UTC · re: Gary V. Vaughan · lore

[patch 13/15] no-socklen_t.patch

SunOS 2.6 and earlier do not have a socklen_t type declaration.
---
 Makefile      |    4 ++++
 aclocal.m4    |   41 +++++++++++++++++++++++++++++++++++++++++
 config.mak.in |    1 +
 configure.ac  |    6 ++++++
 4 files changed, 52 insertions(+)
Show changes to 4 files +52 −0

Makefile, configure.ac, config.mak.in, aclocal.m4

Index: b/Makefile
===================================================================
--- a/Makefile
+++ b/Makefile
@@ -1064,6 +1064,10 @@ else
 BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d'
 endif
 
+ifneq (socklen_t,$(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)
Index: b/configure.ac
===================================================================
--- a/configure.ac
+++ b/configure.ac
@@ -613,6 +613,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], [socklen_t]) ;;
+  *)  		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=],
Index: b/config.mak.in
===================================================================
--- 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@
Index: b/aclocal.m4
===================================================================
--- /dev/null
+++ b/aclocal.m4
@@ -0,0 +1,41 @@
+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 <sys/types.h>
+                  #include <sys/socket.h>
+
+                  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 <sys/types.h>
+#include <sys/socket.h>])
+])
+
-- 
Gary V. Vaughan (gary@thewrittenword.com)
Junio C Hamano· Mar 16, 2010, 07:25 UTC · re: Gary V. Vaughan · lore

Re: [patch 13/15] no-socklen_t.patch

"Gary V. Vaughan" <git@mlists.thewrittenword.com> writes:
> +ifneq (socklen_t,$(SOCKLEN_T))
> +	BASIC_CFLAGS += -Dsocklen_t=$(SOCKLEN_T)
> +endif

This looks like making use of configure mandatory to me? Could you do this patch without doing so?

The same comment applies to [15/15].
Thanks.
Gary V. Vaughan· Apr 25, 2010, 08:39 UTC · re: Junio C Hamano · lore

Re: [patch 13/15] no-socklen_t.patch

On Tue, Mar 16, 2010 at 12:25:07AM -0700, Junio C Hamano wrote:
Show 8 quoted lines
> "Gary V. Vaughan" <git@mlists.thewrittenword.com> writes:
> 
> > +ifneq (socklen_t,$(SOCKLEN_T))
> > +	BASIC_CFLAGS += -Dsocklen_t=$(SOCKLEN_T)
> > +endif
> 
> This looks like making use of configure mandatory to me?  Could you do
> this patch without doing so?
Sure.
SunOS 2.6 and earlier, HP-UX 10.20 and OSF1 do not have a socklen_t type
declaration.
---
 Makefile      |   10 ++++++++++
 aclocal.m4    |   41 +++++++++++++++++++++++++++++++++++++++++
 config.mak.in |    1 +
 configure.ac  |    6 ++++++
 4 files changed, 58 insertions(+)
Show changes to 4 files +58 −0

Makefile, configure.ac, config.mak.in, aclocal.m4

Index: b/Makefile
===================================================================
--- 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.
@@ -698,6 +701,7 @@ EXTLIBS =
 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
@@ -774,6 +778,7 @@ ifeq ($(uname_S),SunOS)
 	NO_MKSTEMPS = YesPlease
 	NO_REGEX = YesPlease
 	ifeq ($(uname_R),5.6)
+		SOCKLEN_T = int
 		NO_HSTRERROR = YesPlease
 		NO_IPV6 = YesPlease
 		NO_SOCKADDR_STORAGE = YesPlease
@@ -938,6 +943,7 @@ ifeq ($(uname_S),HP-UX)
 	NO_NSEC = YesPlease
 	SNPRINTF_RETURNS_BOGUS = YesPlease
 	ifeq ($(uname_R),B.10.20)
+		SOCKLEN_T = size_t
 		NO_PREAD = YesPlease
 		NO_INET_NTOP = YesPlease
 		NO_INET_PTON = YesPlease
@@ -1064,6 +1070,10 @@ else
 BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d'
 endif
 
+ifeq (,$(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)
Index: b/configure.ac
===================================================================
--- a/configure.ac
+++ b/configure.ac
@@ -613,6 +613,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=],
Index: b/config.mak.in
===================================================================
--- 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@
Index: b/aclocal.m4
===================================================================
--- /dev/null
+++ b/aclocal.m4
@@ -0,0 +1,41 @@
+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 <sys/types.h>
+                  #include <sys/socket.h>
+
+                  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 <sys/types.h>
+#include <sys/socket.h>])
+])
+
Cheeers,
-- 
Gary V. Vaughan (gary@thewrittenword.com)
Gary V. Vaughan· Mar 16, 2010, 05:42 UTC · re: Gary V. Vaughan · lore

[patch 14/15] no-ss_family.patch

Systems that do not provide ss_family in sockaddr_storage do not compile.

This patch adds a configure test, and a new Makefile define along with default settings for HPUX-11.00, Solaris-2.6 and others.

I've also added a configure test to set NO_SOCKADDR_STORAGE
appropriately, rather than relying on the default settings in
Makefile.
---
 Makefile      |   15 +++++++++++++++
 config.mak.in |    1 +
 configure.ac  |   17 +++++++++++++++++
 daemon.c      |   31 ++++++++++++++++++++-----------
 4 files changed, 53 insertions(+), 11 deletions(-)
Show changes to 4 files +53 −11

daemon.c, Makefile, config.mak.in, configure.ac

Index: b/daemon.c
===================================================================
--- a/daemon.c
+++ b/daemon.c
@@ -591,19 +591,28 @@ static int execute(struct sockaddr *addr
 static int addrcmp(const struct sockaddr_storage *s1,
     const struct sockaddr_storage *s2)
 {
-	if (s1->ss_family != s2->ss_family)
-		return s1->ss_family - s2->ss_family;
-	if (s1->ss_family == AF_INET)
-		return memcmp(&((struct sockaddr_in *)s1)->sin_addr,
-		    &((struct sockaddr_in *)s2)->sin_addr,
-		    sizeof(struct in_addr));
+#ifndef NO_SS_FAMILY_IN_SOCKADDR_X
+	sa_family_t family = s1->ss_family;
+	sa_family_t family2 = s2->ss_family;
+#else
+	sa_family_t family = ((struct sockaddr *)s1)->sa_family;
+	sa_family_t family2 = ((struct sockaddr *)s2)->sa_family;
+#endif
+
+        if (family != family2)
+                return family - family2;
+        if (family == AF_INET)
+                return memcmp(&((struct sockaddr_in *)s1)->sin_addr,
+                    &((struct sockaddr_in *)s2)->sin_addr,
+                    sizeof(struct in_addr));
 #ifndef NO_IPV6
-	if (s1->ss_family == AF_INET6)
-		return memcmp(&((struct sockaddr_in6 *)s1)->sin6_addr,
-		    &((struct sockaddr_in6 *)s2)->sin6_addr,
-		    sizeof(struct in6_addr));
+        if (family == AF_INET6)
+                return memcmp(&((struct sockaddr_in6 *)s1)->sin6_addr,
+                    &((struct sockaddr_in6 *)s2)->sin6_addr,
+                    sizeof(struct in6_addr));
 #endif
-	return 0;
+
+        return 0;
 }
 
 static int max_connections = 32;
Index: b/Makefile
===================================================================
--- a/Makefile
+++ b/Makefile
@@ -122,6 +122,9 @@ all::
 # Define NO_SOCKADDR_STORAGE if your platform does not have struct
 # sockaddr_storage.
 #
+# Define NO_SS_FAMILY_IN_SOCKADDR_X if your platform lacks ss_family
+# in sockaddr_storage, sockaddr_in and sockaddr_in6.
+#
 # Define NO_ICONV if your libc does not properly support iconv.
 #
 # Define OLD_ICONV if your library has an old iconv(), where the second
@@ -700,6 +703,7 @@ ifeq ($(uname_S),OSF1)
 	BASIC_CFLAGS += -D_OSF_SOURCE
 	NO_STRTOULL = YesPlease
 	NO_NSEC = YesPlease
+	NO_SS_FAMILY_IN_SOCKADDR_X = YesPlease
 endif
 ifeq ($(uname_S),Linux)
 	NO_STRLCPY = YesPlease
@@ -777,6 +781,7 @@ ifeq ($(uname_S),SunOS)
 		NO_HSTRERROR = YesPlease
 		NO_IPV6 = YesPlease
 		NO_SOCKADDR_STORAGE = YesPlease
+		NO_SS_FAMILY_IN_SOCKADDR_X = YesPlease
 		NO_UNSETENV = YesPlease
 		NO_SETENV = YesPlease
 		NO_STRLCPY = YesPlease
@@ -788,6 +793,7 @@ ifeq ($(uname_S),SunOS)
 		NEEDS_RESOLV = YesPlease
 		NO_IPV6 = YesPlease
 		NO_SOCKADDR_STORAGE = YesPlease
+		NO_SS_FAMILY_IN_SOCKADDR_X = YesPlease
 		NO_UNSETENV = YesPlease
 		NO_SETENV = YesPlease
 		NO_STRLCPY = YesPlease
@@ -847,6 +853,9 @@ ifeq ($(uname_S),FreeBSD)
 		NO_UINTMAX_T = YesPlease
 		NO_STRTOUMAX = YesPlease
 	endif
+	ifeq ($(shell expr "$(uname_V).$(uname_R)" : '5\.[012]'),3)
+		NO_SS_FAMILY_IN_SOCKADDR_X = YesPlease
+	endif
 endif
 ifeq ($(uname_S),OpenBSD)
 	NO_STRCASESTR = YesPlease
@@ -895,6 +904,7 @@ ifeq ($(uname_S),IRIX)
 	NO_MEMMEM = YesPlease
 	NO_MKSTEMPS = YesPlease
 	NO_MKDTEMP = YesPlease
+	NO_SS_FAMILY_IN_SOCKADDR_X = YesPlease
 	# When compiled with the MIPSpro 7.4.4m compiler, and without pthreads
 	# (i.e. NO_PTHREADS is set), and _with_ MMAP (i.e. NO_MMAP is not set),
 	# git dies with a segmentation fault when trying to access the first
@@ -941,10 +951,12 @@ ifeq ($(uname_S),HP-UX)
 		NO_PREAD = YesPlease
 		NO_INET_NTOP = YesPlease
 		NO_INET_PTON = YesPlease
+		NO_SS_FAMILY_IN_SOCKADDR_X = YesPlease
 	endif
 	ifeq ($(uname_R),B.11.00)
 		NO_INET_NTOP = YesPlease
 		NO_INET_PTON = YesPlease
+		NO_SS_FAMILY_IN_SOCKADDR_X = YesPlease
 	endif
 	GIT_TEST_CMP = cmp
 endif
@@ -1284,6 +1296,9 @@ else
 	BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in6
 endif
 endif
+ifdef NO_SS_FAMILY_IN_SOCKADDR_X
+	BASIC_CFLAGS += -DNO_SS_FAMILY_IN_SOCKADDR_X
+endif
 ifdef NO_INET_NTOP
 	LIB_OBJS += compat/inet_ntop.o
 endif
Index: b/config.mak.in
===================================================================
--- a/config.mak.in
+++ b/config.mak.in
@@ -42,6 +42,7 @@ NO_D_INO_IN_DIRENT=@NO_D_INO_IN_DIRENT@
 NO_D_TYPE_IN_DIRENT=@NO_D_TYPE_IN_DIRENT@
 NO_SOCKADDR_STORAGE=@NO_SOCKADDR_STORAGE@
 NO_IPV6=@NO_IPV6@
+NO_SS_FAMILY_IN_SOCKADDR_X=@NO_SS_FAMILY_IN_SOCKADDR_X@
 NO_C99_FORMAT=@NO_C99_FORMAT@
 NO_HSTRERROR=@NO_HSTRERROR@
 NO_STRCASESTR=@NO_STRCASESTR@
Index: b/configure.ac
===================================================================
--- a/configure.ac
+++ b/configure.ac
@@ -656,6 +656,23 @@ AC_CHECK_TYPE([struct addrinfo],[
 ])
 AC_SUBST(NO_IPV6)
 #
+# Define NO_SS_FAMILY_IN_SOCKADDR_X if your platform lacks ss_family
+# in struct sockaddr_storage, sockaddr_in6 and sockaddr_in.
+save_CPPFLAGS="$CPPFLAGS"
+case $NO_SOCKADDR_STORAGE:$NO_IPV6 in
+YesPlease:YesPlease)
+  CPPFLAGS="-Dsockaddr_storage=sockaddr_in${CPPFLAGS+ $CPPFLAGS}" ;;
+YesPlease:)
+  CPPFLAGS="-Dsockaddr_storage=sockaddr_in6${CPPFLAGS+ $CPPFLAGS}" ;;
+esac
+AC_CHECK_MEMBER(struct sockaddr_storage.ss_family,
+[NO_SS_FAMILY_IN_SOCKADDR_X=],
+[NO_SS_FAMILY_IN_SOCKADDR_X=YesPlease],[
+#include <sys/types.h>
+#include <sys/socket.h>
+])
+AC_SUBST(NO_SS_FAMILY_IN_SOCKADDR_X)
+#
 # Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
 # do not support the 'size specifiers' introduced by C99, namely ll, hh,
 # j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
-- 
Gary V. Vaughan (gary@thewrittenword.com)
Gary V. Vaughan· Mar 16, 2010, 05:42 UTC · re: Gary V. Vaughan · lore

[patch 15/15] no-inline.patch

Without this patch, git does not compile correctly on HPUX 11.11 and earlier.

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.
---
 Makefile      |    4 ++++
 config.mak.in |    1 +
 configure.ac  |    7 +++++++
 3 files changed, 12 insertions(+)
Show changes to 3 files +12 −0

Makefile, configure.ac, config.mak.in

Index: b/Makefile
===================================================================
--- a/Makefile
+++ b/Makefile
@@ -1076,6 +1076,10 @@ else
 BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d'
 endif
 
+ifneq (inline,$(INLINE))
+	BASIC_CFLAGS += -Dinline=$(INLINE)
+endif
+
 ifneq (socklen_t,$(SOCKLEN_T))
 	BASIC_CFLAGS += -Dsocklen_t=$(SOCKLEN_T)
 endif
Index: b/configure.ac
===================================================================
--- a/configure.ac
+++ b/configure.ac
@@ -307,6 +307,13 @@ GIT_PARSE_WITH(tcltk))
 AC_MSG_NOTICE([CHECKS for programs])
 #
 AC_PROG_CC([cc gcc])
+AC_C_INLINE
+case $ac_cv_c_inline in
+  no)		AC_SUBST([INLINE], []) ;;
+  inline | yes)	AC_SUBST([INLINE], [inline]) ;;
+  *)		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}"
Index: b/config.mak.in
===================================================================
--- a/config.mak.in
+++ b/config.mak.in
@@ -59,6 +59,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@
-- 
Gary V. Vaughan (gary@thewrittenword.com)
Sverre Rabbelier· Mar 16, 2010, 06:18 UTC · re: Gary V. Vaughan · lore

Re: [patch 00/15] Portability Patches v3

Heya,

On Tue, Mar 16, 2010 at 06:42, Gary V. Vaughan <git@mlists.thewrittenword.com> wrote:

> Here are the portability patches we needed at TWW to enable
> git-1.7.0.2 to compile and run on all of the wide range of Unix
> machines we support.
Oh wow, thanks! Glad to see you followed up on this, awesome!
> Note that I have not invested the time to figure out why the testsuite
> is mostly useless on everything but Linux and Solaris 8+, because I'm
> reasonably satisfied that the build itself is working properly.

I'm curious now, what kind of errors are you getting? Would you mind perhaps posting a few to the list in a new thread?

-- 
Cheers,

Sverre Rabbelier
Brandon Casey· Mar 16, 2010, 16:03 UTC · re: Gary V. Vaughan · lore

Re: [patch 00/15] Portability Patches v3

On 03/16/2010 12:42 AM, Gary V. Vaughan wrote:
Show 15 quoted lines
> Here are the portability patches we needed at TWW to enable
> git-1.7.0.2 to compile and run on all of the wide range of Unix
> machines we support.  These patches apply to the git-1.7.0.2 release,
> and address all of the feedback from the previous two times I posted
> them to this list, most particularly splitting everything into many
> small self-contained chunks.
> 
> Note that I have not invested the time to figure out why the testsuite
> is mostly useless on everything but Linux and Solaris 8+, because I'm
> reasonably satisfied that the build itself is working properly.  Most
> likely, it is merely GNUisms in the way the test cases call external
> tools.  But maybe I'm missing something, but even the 3 new patches to
> address test errors when diff does not support the -u option don't
> improve the testsuite situation on HPUX, AIX, OSF1 and Solaris 7 and
> older.

Which shell are you using? If you're trying to use Korn or /usr/xpg4/bin/sh on Solaris, you'll have problems, but it is possible. I can send you a patch.

I have 3 patches that I apply on top of master which allows me to compile and test on Solaris 7. I remove all but the first when installing, since it is necessary to compile and the others are only necessary for the test suite.

  1) Remove const declaration from arrays with non-constant initializers
  2) t5100/*.mbox: use '646' rather than 'us-ascii' for Solaris
  3) t/test-lib.sh: support Korn shell by converting GIT_EXIT_OK to GIT_EXIT_CODE
Here's the config.mak file I use:
GIT_SKIP_TESTS := \
   t1304.3 \
   t3900.2[23] \
   t5000.1[5-79] t5000.2[013-6] t5000.41 \
   t6030.1[23] \
   t8005.[23]
GIT_TEST_CMP = cmp -s
export GIT_SKIP_TESTS GIT_TEST_CMP
SHELL_PATH = /usr/xpg4/bin/sh

# This is an old GNU tar that's why some of the # tests in t5000? still fail TAR = /apps/bin/gtar

CC = /opt/SUNWspro/bin/cc

# zlib is installed in /apps CFLAGS = -fast -native -I/apps/include LDFLAGS = -L/apps/lib

NO_CURL = 1 NO_TCLTK = 1 NO_OPENSSL = 1 BLK_SHA1 = 1 NO_PYTHON = 1 DEFAULT_PAGER = more

-brandon

← back to recent threads