Thread (190 messages) 190 messages, 7 authors, 2019-11-21

Re: [PATCH v2 03/11] clone: add --sparse mode

From: Elijah Newren <hidden>
Date: 2019-10-05 19:40:59

On Thu, Sep 19, 2019 at 3:06 PM Derrick Stolee via GitGitGadget
[off-list ref] wrote:
During the 'git sparse-checkout init' call, we must first look
to see if HEAD is valid, or else we will fail while trying to
update the working directory. The first checkout will actually
update the working directory correctly.
This is new since the RFC series, but I'm not sure I understand.  Is
the issue you're fixing here that a 'git init somerepo' would hit this
codepath and print funny errors because HEAD doesn't exist yet and
thus the whole `git read-tree -mu HEAD` stuff can't work?  Or that
when the remote has HEAD pointing at a bad commit that you get error
messages different than expected?
quoted hunk ↗ jump to hunk
diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c
index 895479970d..656e6ebdd5 100644
--- a/builtin/sparse-checkout.c
+++ b/builtin/sparse-checkout.c
@@ -99,6 +99,7 @@ static int sparse_checkout_init(int argc, const char **argv)
        char *sparse_filename;
        FILE *fp;
        int res;
+       struct object_id oid;

        if (sc_enable_config())
                return 1;
@@ -120,6 +121,11 @@ static int sparse_checkout_init(int argc, const char **argv)
        fprintf(fp, "/*\n!/*/\n");
        fclose(fp);

+       if (get_oid("HEAD", &oid)) {
+               /* assume we are in a fresh repo */
+               return 0;
+       }
+
 reset_dir:
        return update_working_directory();
 }
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help