fix modified files not shown by 'got status' after committing staged changes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
diff --git a/lib/worktree.c b/lib/worktree.c
index 71909fd..b6130cb 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -3918,7 +3918,8 @@ done:
static const struct got_error *
update_fileindex_after_commit(struct got_pathlist_head *commitable_paths,
- struct got_object_id *new_base_commit_id, struct got_fileindex *fileindex)
+ struct got_object_id *new_base_commit_id, struct got_fileindex *fileindex,
+ int have_staged_files)
{
const struct got_error *err = NULL;
struct got_pathlist_entry *pe;
@@ -3939,11 +3940,13 @@ update_fileindex_after_commit(struct got_pathlist_head *commitable_paths,
GOT_FILEIDX_STAGE_NONE);
err = got_fileindex_entry_update(ie,
ct->ondisk_path, ct->staged_blob_id->sha1,
- new_base_commit_id->sha1, 1);
+ new_base_commit_id->sha1,
+ !have_staged_files);
} else
err = got_fileindex_entry_update(ie,
ct->ondisk_path, ct->blob_id->sha1,
- new_base_commit_id->sha1, 1);
+ new_base_commit_id->sha1,
+ !have_staged_files);
} else {
err = got_fileindex_entry_alloc(&ie,
ct->ondisk_path, pe->path, ct->blob_id->sha1,
@@ -4282,7 +4285,7 @@ got_worktree_commit(struct got_object_id **new_commit_id,
goto done;
err = update_fileindex_after_commit(&commitable_paths, *new_commit_id,
- fileindex);
+ fileindex, have_staged_files);
sync_err = sync_fileindex(fileindex, fileindex_path);
if (sync_err && err == NULL)
err = sync_err;
@@ -4860,7 +4863,7 @@ rebase_commit(struct got_object_id **new_commit_id,
goto done;
err = update_fileindex_after_commit(&commitable_paths, *new_commit_id,
- fileindex);
+ fileindex, 0);
sync_err = sync_fileindex(fileindex, fileindex_path);
if (sync_err && err == NULL)
err = sync_err;
diff --git a/regress/cmdline/stage.sh b/regress/cmdline/stage.sh
index abe3641..c847136 100755
--- a/regress/cmdline/stage.sh
+++ b/regress/cmdline/stage.sh
@@ -1382,8 +1382,10 @@ function test_stage_commit {
return 1
fi
- echo 'A epsilon/new' > $testroot/stdout.expected
+ echo 'M alpha' > $testroot/stdout.expected
+ echo 'A epsilon/new' >> $testroot/stdout.expected
echo 'D epsilon/zeta' >> $testroot/stdout.expected
+ echo 'M foo' >> $testroot/stdout.expected
echo 'M gamma/delta' >> $testroot/stdout.expected
(cd $testroot/wt && got status > $testroot/stdout)