X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=upload-pack.c;h=da10742c44201cfb6f86eb8d80f3be27940335ff;hb=f0ebff0dfebc667e5edf6f67d190fd960513ab66;hp=d35c0685ce2269cec48d19fbf6b0499374a34b7e;hpb=75bfc6c232689ae06aba6a7d4aa15ac2791d9a11;p=git.git diff --git a/upload-pack.c b/upload-pack.c index d35c0685..da10742c 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -5,7 +5,7 @@ static const char upload_pack_usage[] = "git-upload-pack "; #define MAX_HAS (16) -#define MAX_NEEDS (16) +#define MAX_NEEDS (256) static int nr_has = 0, nr_needs = 0; static unsigned char has_sha1[MAX_HAS][20]; static unsigned char needs_sha1[MAX_NEEDS][20]; @@ -153,6 +153,7 @@ static int send_ref(const char *refname, const unsigned char *sha1) static int upload_pack(void) { + head_ref(send_ref); for_each_ref(send_ref); packet_flush(1); nr_needs = receive_needs(); @@ -169,12 +170,16 @@ 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); - setenv("GIT_DIR", ".", 1); + putenv("GIT_DIR=."); upload_pack(); return 0; }