git-am: fix detection of absolute paths for windows
authorPat Thoyts <patthoyts@users.sourceforge.net>
Thu, 30 Sep 2010 13:24:07 +0000 (14:24 +0100)
committerPat Thoyts <patthoyts@users.sourceforge.net>
Sun, 3 Oct 2010 22:31:59 +0000 (23:31 +0100)
Add an is_absolute_path function to abstract out platform differences
in checking for an absolute or relative path.
Specifically fixes t4150-am on Windows.

[PT: updated following suggestion from j6t to support \* and //*]

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
git-am.sh
git-sh-setup.sh

index e7f008c7baae2ff484e16882e199b6b9d75195aa..9317b3893552fda9d3e4cbdbd0c66bf69bd633a9 100755 (executable)
--- a/git-am.sh
+++ b/git-am.sh
@@ -444,12 +444,12 @@ else
                                set x
                                first=
                        }
-                       case "$arg" in
-                       /*)
-                               set "$@" "$arg" ;;
-                       *)
-                               set "$@" "$prefix$arg" ;;
-                       esac
+                       if is_absolute_path "$arg"
+                       then
+                               set "$@" "$arg"
+                       else
+                               set "$@" "$prefix$arg"
+                       fi
                done
                shift
        fi
index 6131670860514c215a6b9b7417dd05c3124e81b4..58d30c9388f14284214fee8ade4603a03e02b3b2 100644 (file)
@@ -209,5 +209,20 @@ case $(uname -s) in
        find () {
                /usr/bin/find "$@"
        }
+       is_absolute_path () {
+               case "$1" in
+               [/\\]* | [A-Za-z]:*)
+                       return 0 ;;
+               esac
+               return 1
+       }
        ;;
+*)
+       is_absolute_path () {
+               case "$1" in
+               /*)
+                       return 0 ;;
+               esac
+               return 1
+       }
 esac