@matheusbsbs / matheus-bagliano / commits / 8d63013291
Fork 0

Server-side support for user-relative paths.

This patch basically just removes the redundant code from {receive,upload}-pack.c in favour of the library code in path.c. Signed-off-by: Andreas Ericsson <ae@op5.se> Signed-off-by: Junio C Hamano <junkio@cox.net>

Andreas Ericsson committed Nov 17, 2005 at 20:37 UTC 8d6301329156e4eeb0d25d6bce14f6e958314986
2 files changed +7 -25
receive-pack.c
+4 -13
@@ -248,11 +248,11 @@ static void unpack(void)
248 int main(int argc, char **argv)
249 {
250 int i;
251 - const char *dir = NULL;
251 + char *dir = NULL;
252
253 argv++;
254 for (i = 1; i < argc; i++) {
255 - const char *arg = *argv++;
255 + char *arg = *argv++;
256
257 if (*arg == '-') {
258 /* Do flag handling here */
@@ -265,18 +265,9 @@ int main(int argc, char **argv)
265 if (!dir)
266 usage(receive_pack_usage);
267
268 - /* chdir to the directory. If that fails, try appending ".git" */
269 - if (chdir(dir) < 0) {
270 - if (chdir(mkpath("%s.git", dir)) < 0)
271 - die("unable to cd to %s", dir);
272 - }
273 -
274 - /* If we have a ".git" directory, chdir to it */
275 - chdir(".git");
276 - putenv("GIT_DIR=.");
268 + if(!enter_repo(dir, 0))
269 + die("'%s': unable to chdir or not a git archive", dir);
270
278 - if (access("objects", X_OK) < 0 || access("refs/heads", X_OK) < 0)
279 - die("%s doesn't appear to be a git directory", dir);
271 write_head_info();
272
273 /* EOF */
upload-pack.c
+3 -12
@@ -248,7 +248,7 @@ static int upload_pack(void)
248
249 int main(int argc, char **argv)
250 {
251 - const char *dir;
251 + char *dir;
252 int i;
253 int strict = 0;
254
@@ -275,18 +275,9 @@ int main(int argc, char **argv)
275 usage(upload_pack_usage);
276 dir = argv[i];
277
278 - /* chdir to the directory. If that fails, try appending ".git" */
279 - if (chdir(dir) < 0) {
280 - if (strict || chdir(mkpath("%s.git", dir)) < 0)
281 - die("git-upload-pack unable to chdir to %s", dir);
282 - }
283 - if (!strict)
284 - chdir(".git");
285 -
286 - if (access("objects", X_OK) || access("refs", X_OK))
287 - die("git-upload-pack: %s doesn't seem to be a git archive", dir);
278 + if (!enter_repo(dir, strict))
279 + die("'%s': unable to chdir or not a git archive", dir);
280
289 - putenv("GIT_DIR=.");
281 upload_pack();
282 return 0;
283 }