From ee8b7c8ecc7ea2cd35a3e1c298c7afaf8823e048 Mon Sep 17 00:00:00 2001
From: Ingo Weinhold <ingo_weinhold@gmx.de>
Date: Tue, 13 Aug 2013 08:07:25 +0200
Subject: [PATCH 1/5] git-web--browse.sh: use "open" on Haiku

---
 git-web--browse.sh | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/git-web--browse.sh b/git-web--browse.sh
index ae15253..1f6e306 100755
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -132,6 +132,10 @@ if test -z "$browser" ; then
 	if test -x /usr/bin/cygstart; then
 		browser_candidates="cygstart $browser_candidates"
 	fi
+	# /boot/system/haiku_loader indicates Haiku
+	if test -f /boot/system/haiku_loader; then
+		browser_candidates="open $browser_candidates"
+	fi
 
 	for i in $browser_candidates; do
 		init_browser_path $i
-- 
1.8.3.4


From a7f24c225e8b75abf52d07f73625ea404503b475 Mon Sep 17 00:00:00 2001
From: Ingo Weinhold <ingo_weinhold@gmx.de>
Date: Mon, 19 Jan 2015 15:37:16 -0500
Subject: [PATCH 2/5] On Haiku use the user settings directory instead of HOME

---
 path.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/path.c b/path.c
index e608993..ee5831c 100644
--- a/path.c
+++ b/path.c
@@ -5,6 +5,11 @@
 #include "strbuf.h"
 #include "string-list.h"
 
+#ifdef __HAIKU__
+#	include <FindDirectory.h>
+#	include <StorageDefs.h>
+#endif
+
 static int get_st_mode_bits(const char *path, int *mode)
 {
 	struct stat st;
@@ -132,6 +137,19 @@ char *git_path(const char *fmt, ...)
 
 void home_config_paths(char **global, char **xdg, char *file)
 {
+#ifdef __HAIKU__
+	char settingsPath[B_PATH_NAME_LENGTH];
+
+	*xdg = NULL;
+
+	if (global) {
+		if (find_directory(B_USER_SETTINGS_DIRECTORY, -1, true, settingsPath,
+			sizeof(settingsPath)) == B_OK) {
+			*global = mkpathdup("%s/git/%s", settingsPath, file);
+		} else
+			*global = NULL;
+	}
+#else
 	char *xdg_home = getenv("XDG_CONFIG_HOME");
 	char *home = getenv("HOME");
 	char *to_free = NULL;
@@ -156,6 +174,7 @@ void home_config_paths(char **global, char **xdg, char *file)
 	}
 
 	free(to_free);
+#endif
 }
 
 char *git_path_submodule(const char *path, const char *fmt, ...)
-- 
1.8.3.4


From b2890c33ea7dff56b4060394673d36746ad4e448 Mon Sep 17 00:00:00 2001
From: Oliver Tappe <zooey@hirschkaefer.de>
Date: Mon, 19 Jan 2015 15:50:09 -0500
Subject: [PATCH 3/5] Ensure config-directory exists before using it.

---
 config.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/config.c b/config.c
index 752e2e2..1e07f5c 100644
--- a/config.c
+++ b/config.c
@@ -1934,6 +1934,7 @@ int git_config_set_multivar_in_file(const char *config_filename,
 	int ret;
 	struct lock_file *lock = NULL;
 	char *filename_buf = NULL;
+	char *config_dir = NULL;
 
 	/* parse-key returns negative; flip the sign to feed exit(3) */
 	ret = 0 - git_config_parse_key(key, &store.key, &store.baselen);
@@ -1945,6 +1946,12 @@ int git_config_set_multivar_in_file(const char *config_filename,
 	if (!config_filename)
 		config_filename = filename_buf = git_pathdup("config");
 
+	config_dir = xstrdup(config_filename);
+	* find_last_dir_sep(config_dir) = '\0';
+	if (access(config_dir, F_OK) != 0)
+		mkdir(config_dir, 0755);
+	free(config_dir);
+
 	/*
 	 * The lock serves a purpose in addition to locking: the new
 	 * contents of .git/config will be written into it.
-- 
1.8.3.4


From 089d55aa7d52ac66b9639b47b0be062851bfbda2 Mon Sep 17 00:00:00 2001
From: Augustin Cavalier <waddlesplash@gmail.com>
Date: Mon, 19 Jan 2015 16:40:30 -0500
Subject: [PATCH 4/5] Don't use __builtin_ctzll on GCC2.

---
 ewah/ewok.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ewah/ewok.h b/ewah/ewok.h
index f6ad190..ca059c9 100644
--- a/ewah/ewok.h
+++ b/ewah/ewok.h
@@ -47,7 +47,7 @@ static inline uint32_t ewah_bit_popcount64(uint64_t x)
 	return (x * 0x0101010101010101ULL) >> 56;
 }
 
-#ifdef __GNUC__
+#if defined(__GNUC__) && __GNUC__ >= 3
 #define ewah_bit_ctz64(x) __builtin_ctzll(x)
 #else
 static inline int ewah_bit_ctz64(uint64_t x)
-- 
1.8.3.4
