Merge branch 'mw/symlinks'
authorJunio C Hamano <gitster@pobox.com>
Fri, 2 May 2014 20:11:02 +0000 (13:11 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 2 May 2014 20:11:03 +0000 (13:11 -0700)
A finishing touch fix to a new change already in 'master'.

* mw/symlinks:
setup: fix windows path buffer over-stepping

1  2 
setup.c
diff --combined setup.c
index 613e3b3c13b3f09bce07c54dc440d03c0b5beb0c,3857b58562d8ff0ceb1adbccdd51c989d2326172..0a22f8bd1d631fe5f0afe1d84162ca4064a00e4f
+++ b/setup.c
@@@ -29,7 -29,7 +29,7 @@@ static int abspath_part_inside_repo(cha
                return -1;
        wtlen = strlen(work_tree);
        len = strlen(path);
-       off = 0;
+       off = offset_1st_component(path);
  
        /* check if work tree is already the prefix */
        if (wtlen <= len && !strncmp(path, work_tree, wtlen)) {
@@@ -45,7 -45,7 +45,7 @@@
                off = wtlen;
        }
        path0 = path;
-       path += offset_1st_component(path) + off;
+       path += off;
  
        /* check each '/'-terminated level */
        while (*path) {
@@@ -136,7 -136,7 +136,7 @@@ int check_filename(const char *prefix, 
        const char *name;
        struct stat st;
  
 -      if (!prefixcmp(arg, ":/")) {
 +      if (starts_with(arg, ":/")) {
                if (arg[2] == '\0') /* ":/" is root dir, always exists */
                        return 1;
                name = arg + 2;
@@@ -358,7 -358,7 +358,7 @@@ const char *read_gitfile(const char *pa
        if (len != st.st_size)
                die("Error reading %s", path);
        buf[len] = '\0';
 -      if (prefixcmp(buf, "gitdir: "))
 +      if (!starts_with(buf, "gitdir: "))
                die("Invalid gitfile format: %s", path);
        while (buf[len - 1] == '\n' || buf[len - 1] == '\r')
                len--;
@@@ -841,27 -841,3 +841,27 @@@ void sanitize_stdfds(void
        if (fd > 2)
                close(fd);
  }
 +
 +int daemonize(void)
 +{
 +#ifdef NO_POSIX_GOODIES
 +      errno = ENOSYS;
 +      return -1;
 +#else
 +      switch (fork()) {
 +              case 0:
 +                      break;
 +              case -1:
 +                      die_errno("fork failed");
 +              default:
 +                      exit(0);
 +      }
 +      if (setsid() == -1)
 +              die_errno("setsid failed");
 +      close(0);
 +      close(1);
 +      close(2);
 +      sanitize_stdfds();
 +      return 0;
 +#endif
 +}