diff options
author | Junio C Hamano <gitster@pobox.com> | 2023-07-08 20:23:07 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-07-08 20:23:07 +0200 |
commit | 7f5ad0ca8d1d7db7a21755af34251714d86b2ec1 (patch) | |
tree | 8b71767227de1c77adf50c36cc9f0d567046c9ba /builtin/commit.c | |
parent | Merge branch 'ks/t4205-test-describe-with-abbrev-fix' (diff) | |
parent | commit -a -m: allow the top-level tree to become empty again (diff) | |
download | git-7f5ad0ca8d1d7db7a21755af34251714d86b2ec1.tar.xz git-7f5ad0ca8d1d7db7a21755af34251714d86b2ec1.zip |
Merge branch 'js/empty-index-fixes'
A few places failed to differenciate the case where the index is
truly empty (nothing added) and we haven't yet read from the
on-disk index file, which have been corrected.
* js/empty-index-fixes:
commit -a -m: allow the top-level tree to become empty again
split-index: accept that a base index can be empty
do_read_index(): always mark index as initialized unless erroring out
Diffstat (limited to 'builtin/commit.c')
-rw-r--r-- | builtin/commit.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/builtin/commit.c b/builtin/commit.c index 0b6752bfe8..7da5f92448 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1002,11 +1002,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix, struct object_id oid; const char *parent = "HEAD"; - if (!the_index.cache_nr) { - discard_index(&the_index); - if (repo_read_index(the_repository) < 0) - die(_("Cannot read index")); - } + if (!the_index.initialized && repo_read_index(the_repository) < 0) + die(_("Cannot read index")); if (amend) parent = "HEAD^1"; |