Re: [PATCH 2/4] rev-parse: make --git-dir return /.git instead of //.git

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Dienstag, 9. Februar 2010, Nguyễn Thái Ngọc Duy wrote:
> @@ -647,7 +647,7 @@ int cmd_rev_parse(int argc, const char **argv, const
> char *prefix) }
>  				if (!getcwd(cwd, PATH_MAX))
>  					die_errno("unable to get current working directory");
> -				printf("%s/.git\n", cwd);
> +				printf("%s%s.git\n", cwd, *cwd == '/' && cwd[1] == '\0' ? "" : "/");

On Windows, when you are in the root of a drive, then cwd is "C:/", i.e. there 
is a trailing slash just as in the Unix root directory. But you do not take 
care of this situation. That is, you would print "C://".

How about:

static inline int is_root_path(const char *path)
{
	if (has_dos_drive_prefix(path))
		path += 2;
	while (is_dir_sep(*path))
		path++;
	return !*path;
}

and use it though-out your series?

(Simplify the loop to 'return is_dir_sep(*path) && !path[1];' if you can 
assume that paths are nomalized.)

-- Hannes
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]