Skip to content

Commit bb754fe

Browse files
committed
Merge branch 'jt/sparse-checkout-leading-dir-fix'
"git sparse-checkout init" failed to write into $GIT_DIR/info directory when the repository was created without one, which has been corrected to auto-create it. * jt/sparse-checkout-leading-dir-fix: sparse-checkout: create leading directory
2 parents c70b5e7 + 7f44842 commit bb754fe

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

builtin/sparse-checkout.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,9 @@ static int sparse_checkout_init(int argc, const char **argv)
471471
FILE *fp;
472472

473473
/* assume we are in a fresh repo, but update the sparse-checkout file */
474+
if (safe_create_leading_directories(sparse_filename))
475+
die(_("unable to create leading directories of %s"),
476+
sparse_filename);
474477
fp = xfopen(sparse_filename, "w");
475478
if (!fp)
476479
die(_("failed to open '%s'"), sparse_filename);

t/t1091-sparse-checkout-builtin.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ test_expect_success 'git sparse-checkout init' '
7979
check_files repo a
8080
'
8181

82+
test_expect_success 'git sparse-checkout init in empty repo' '
83+
test_when_finished rm -rf empty-repo blank-template &&
84+
git init --template= empty-repo &&
85+
git -C empty-repo sparse-checkout init
86+
'
87+
8288
test_expect_success 'git sparse-checkout list after init' '
8389
git -C repo sparse-checkout list >actual &&
8490
cat >expect <<-\EOF &&

0 commit comments

Comments
 (0)