From: Linus Torvalds Date: Fri, 8 Jul 2005 23:22:22 +0000 (-0700) Subject: Make "upload-pack" match git-fetch-pack usage X-Git-Tag: v0.99~17 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=113b94751d7f10617e22de0d017033a52b224c68;p=git.git Make "upload-pack" match git-fetch-pack usage Do the default "try xyz.git xyz fails" thing for the directory we get passed in. --- diff --git a/receive-pack.c b/receive-pack.c index 1768c875..f39703f7 100644 --- a/receive-pack.c +++ b/receive-pack.c @@ -197,9 +197,7 @@ int main(int argc, char **argv) /* chdir to the directory. If that fails, try appending ".git" */ if (chdir(dir) < 0) { - static char path[PATH_MAX]; - snprintf(path, sizeof(path), "%s.git", dir); - if (chdir(path) < 0) + if (chdir(mkpath("%s.git", dir)) < 0) die("unable to cd to %s", dir); } diff --git a/upload-pack.c b/upload-pack.c index 6d844cc3..95d38120 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -170,8 +170,12 @@ int main(int argc, char **argv) if (argc != 2) usage(upload_pack_usage); dir = argv[1]; - if (chdir(dir)) - die("git-upload-pack unable to chdir to %s", dir); + + /* chdir to the directory. If that fails, try appending ".git" */ + if (chdir(dir) < 0) { + if (chdir(mkpath("%s.git", dir)) < 0) + die("git-upload-pack unable to chdir to %s", dir); + } chdir(".git"); if (access("objects", X_OK) || access("refs", X_OK)) die("git-upload-pack: %s doesn't seem to be a git archive", dir);