summaryrefslogtreecommitdiff
path: root/compat
diff options
context:
space:
mode:
authorLibravatar Johannes Sixt <johannes.sixt@telecom.at>2008-03-05 21:51:27 +0100
committerLibravatar Johannes Sixt <johannes.sixt@telecom.at>2008-06-23 13:30:22 +0200
commit25fe217b86ca40c53e710d776e120dfa0d81f60b (patch)
tree17d027b37da265e44e48bf01f872cf20c1e6d931 /compat
parentsetup.c: Prepare for Windows directory separators. (diff)
downloadtgif-25fe217b86ca40c53e710d776e120dfa0d81f60b.tar.xz
Windows: Treat Windows style path names.
GIT's guts work with a forward slash as a path separators. We do not change that. Rather we make sure that only "normalized" paths enter the depths of the machinery. We have to translate backslashes to forward slashes in the prefix and in command line arguments. Fortunately, all of them are passed through functions in setup.c. A macro has_dos_drive_path() is defined that checks whether a path begins with a drive letter+colon combination. This predicate is always false on Unix. Another macro is_dir_sep() abstracts that a backslash is also a directory separator on Windows. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Diffstat (limited to 'compat')
-rw-r--r--compat/mingw.c13
-rw-r--r--compat/mingw.h9
2 files changed, 22 insertions, 0 deletions
diff --git a/compat/mingw.c b/compat/mingw.c
index 075448d245..4e559bdc93 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -40,6 +40,19 @@ struct tm *localtime_r(const time_t *timep, struct tm *result)
return result;
}
+#undef getcwd
+char *mingw_getcwd(char *pointer, int len)
+{
+ int i;
+ char *ret = getcwd(pointer, len);
+ if (!ret)
+ return ret;
+ for (i = 0; pointer[i]; i++)
+ if (pointer[i] == '\\')
+ pointer[i] = '/';
+ return ret;
+}
+
struct passwd *getpwuid(int uid)
{
static struct passwd p;
diff --git a/compat/mingw.h b/compat/mingw.h
index 22aae0077e..a954014ff2 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -134,7 +134,16 @@ int setitimer(int type, struct itimerval *in, struct itimerval *out);
int sigaction(int sig, struct sigaction *in, struct sigaction *out);
/*
+ * replacements of existing functions
+ */
+
+char *mingw_getcwd(char *pointer, int len);
+#define getcwd mingw_getcwd
+
+/*
* git specific compatibility
*/
+#define has_dos_drive_prefix(path) (isalpha(*(path)) && (path)[1] == ':')
+#define is_dir_sep(c) ((c) == '/' || (c) == '\\')
#define PATH_SEP ';'