Commit Diff


commit - b5bedbbb00134c51ea21a700b6da9ab45c6e432e
commit + d259e49165acf62d0ffddd9f1cd35a3608783ccf
blob - 198a7f343d11535dcd0b9767bbe1703a6ef2a4aa
blob + 933902ef1a76ca0c564195254e69901b590b58e4
--- lib/worktree.c
+++ lib/worktree.c
@@ -5020,6 +5020,18 @@ append_ct_diff(struct got_commitable *ct, int *diff_he
 	char *id_str = NULL;
 
 	memset(&sb, 0, sizeof(sb));
+
+	if (diff_staged) {
+		if (ct->staged_status != GOT_STATUS_MODIFY &&
+		    ct->staged_status != GOT_STATUS_ADD &&
+		    ct->staged_status != GOT_STATUS_DELETE)
+			return NULL;
+	} else {
+		if (ct->status != GOT_STATUS_MODIFY &&
+		    ct->status != GOT_STATUS_ADD &&
+		    ct->status != GOT_STATUS_DELETE)
+			return NULL;
+	}
 
 	err = got_opentemp_truncate(f1);
 	if (err)