From: Junio C Hamano Date: Tue, 21 Apr 2015 19:12:23 +0000 (-0700) Subject: Merge branch 'pt/enter-repo-comment-fix' into maint X-Git-Tag: v2.3.6~3 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/42b2f894a0237e3b393770330dba995e731ec7ad?ds=inline;hp=-c Merge branch 'pt/enter-repo-comment-fix' into maint Documentation update. * pt/enter-repo-comment-fix: enter_repo(): fix docs to match code --- 42b2f894a0237e3b393770330dba995e731ec7ad diff --combined path.c index e608993801,c480634a31..595da81ca6 --- a/path.c +++ b/path.c @@@ -148,12 -148,10 +148,12 @@@ void home_config_paths(char **global, c *global = mkpathdup("%s/.gitconfig", home); } - if (!xdg_home) - *xdg = NULL; - else - *xdg = mkpathdup("%s/git/%s", xdg_home, file); + if (xdg) { + if (!xdg_home) + *xdg = NULL; + else + *xdg = mkpathdup("%s/git/%s", xdg_home, file); + } free(to_free); } @@@ -277,16 -275,16 +277,16 @@@ char *expand_user_path(const char *path const char *home = getenv("HOME"); if (!home) goto return_null; - strbuf_add(&user_path, home, strlen(home)); + strbuf_addstr(&user_path, home); } else { struct passwd *pw = getpw_str(username, username_len); if (!pw) goto return_null; - strbuf_add(&user_path, pw->pw_dir, strlen(pw->pw_dir)); + strbuf_addstr(&user_path, pw->pw_dir); } to_copy = first_slash; } - strbuf_add(&user_path, to_copy, strlen(to_copy)); + strbuf_addstr(&user_path, to_copy); return strbuf_detach(&user_path, NULL); return_null: strbuf_release(&user_path); @@@ -303,14 -301,9 +303,9 @@@ * (3) "relative/path" to mean cwd relative directory; or * (4) "/absolute/path" to mean absolute directory. * - * Unless "strict" is given, we try access() for existence of "%s.git/.git", - * "%s/.git", "%s.git", "%s" in this order. The first one that exists is - * what we try. - * - * Second, we try chdir() to that. Upon failure, we return NULL. - * - * Then, we try if the current directory is a valid git repository. - * Upon failure, we return NULL. + * Unless "strict" is given, we check "%s/.git", "%s", "%s.git/.git", "%s.git" + * in this order. We select the first one that is a valid git repository, and + * chdir() to it. If none match, or we fail to chdir, we return NULL. * * If all goes well, we return the directory we used to chdir() (but * before ~user is expanded), avoiding getcwd() resolving symbolic @@@ -824,6 -817,13 +819,6 @@@ int daemon_avoid_alias(const char *p } } -int offset_1st_component(const char *path) -{ - if (has_dos_drive_prefix(path)) - return 2 + is_dir_sep(path[2]); - return is_dir_sep(path[0]); -} - static int only_spaces_and_periods(const char *path, size_t len, size_t skip) { if (len < skip)