Skip to content

Commit 113b947

Browse files
author
Linus Torvalds
committed
Make "upload-pack" match git-fetch-pack usage
Do the default "try xyz.git xyz fails" thing for the directory we get passed in.
1 parent 26c8a53 commit 113b947

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

receive-pack.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,7 @@ int main(int argc, char **argv)
197197

198198
/* chdir to the directory. If that fails, try appending ".git" */
199199
if (chdir(dir) < 0) {
200-
static char path[PATH_MAX];
201-
snprintf(path, sizeof(path), "%s.git", dir);
202-
if (chdir(path) < 0)
200+
if (chdir(mkpath("%s.git", dir)) < 0)
203201
die("unable to cd to %s", dir);
204202
}
205203

upload-pack.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,12 @@ int main(int argc, char **argv)
170170
if (argc != 2)
171171
usage(upload_pack_usage);
172172
dir = argv[1];
173-
if (chdir(dir))
174-
die("git-upload-pack unable to chdir to %s", dir);
173+
174+
/* chdir to the directory. If that fails, try appending ".git" */
175+
if (chdir(dir) < 0) {
176+
if (chdir(mkpath("%s.git", dir)) < 0)
177+
die("git-upload-pack unable to chdir to %s", dir);
178+
}
175179
chdir(".git");
176180
if (access("objects", X_OK) || access("refs", X_OK))
177181
die("git-upload-pack: %s doesn't seem to be a git archive", dir);

0 commit comments

Comments
 (0)