git-clone: Support changing the origin branch with -o
[git.git] / http-fetch.c
index 4353173..3cd6ef9 100644 (file)
@@ -658,7 +658,7 @@ static int fetch_indices(struct alt_base *repo)
                switch (data[i]) {
                case 'P':
                        i++;
-                       if (i + 52 < buffer.posn &&
+                       if (i + 52 <= buffer.posn &&
                            !strncmp(data + i, " pack-", 6) &&
                            !strncmp(data + i + 46, ".pack\n", 6)) {
                                get_sha1_hex(data + i + 6, sha1);
@@ -667,7 +667,7 @@ static int fetch_indices(struct alt_base *repo)
                                break;
                        }
                default:
-                       while (data[i] != '\n')
+                       while (i < buffer.posn && data[i] != '\n')
                                i++;
                }
                i++;
@@ -922,6 +922,8 @@ int main(int argc, char **argv)
        int arg = 1;
        int rc = 0;
 
+       setup_git_directory();
+
        while (arg < argc && argv[arg][0] == '-') {
                if (argv[arg][1] == 't') {
                        get_tree = 1;