From: Junio C Hamano Date: Wed, 02 Nov 2005 00:14:40 GMT Subject: Re: [PATCH 2/4] Library code for user-relative paths. Message-ID: <7vk6fr6h3j.fsf@assigned-by-dhcp.cox.net> In-Reply-To: <20051101225921.2C6035BA82@nox.op5.se> Andreas Ericsson writes: > + if((slash = strchr(dir, '/'))) { > + *slash = '\0'; > + pw = getpwnam(dir); > + *slash = '/'; Should you be writing into *slash when dir and path are const char *? I know strchr returns "char *" and the compiler would not complain but this sounds somewhat yucky. > + if(slash && *slash + 1) I think you mean "if (slash && slash[1])" here. While we are at it, please have a SP betweeen if and open parenthesis. > + dir = slash + 1; > + else > + dir = current_dir(); > + } > + > + /* ~foo/path/to/repo is now path/to/repo and we're in foo's homedir */ > + if(chdir(dir) < 0) > + return NULL; Hmm. It's not wrong, but "dir = current_dir()" immediately followed by "chdir(dir)" does not feel right.