Download raw body.
small got commit temp-diff fix
On Tue, Nov 01, 2022 at 09:01:44AM +0100, Omar Polo wrote: > On 2022/11/01 08:51:50 +0100, Stefan Sperling <stsp@stsp.name> wrote: > > There is already a flag which tells us whether any staged files exist in > > the work tree. Use it instead of looking at a per-file flag to figure > > out whether the diff header should say "staged changes". Otherwise we > > can get the header wrong if we come across a file that is not staged > > before we see a staged file. > > > > ok? > > ok > Thanks. Now there is another problem: Since we use the global flag and might come across staged and non-staged files in any order, we should ensure that a file is in fact staged/non-staged before diffing. Also ensure that we don't attempt to diff files which are in an unexpected state. diff 6d15dc69f06b84b429b255763d5f75e9f22869a7 refs/heads/ct-diff-status commit - 6d15dc69f06b84b429b255763d5f75e9f22869a7 commit + 2e6693cbbdaf6c4a7506c846f5918d9c6ab9136e blob - e7055fd5e6b3d6a39a016774c3c5ed30c1ca88b1 blob + d14c58399fceec0280e8957209afc6f96c826df5 --- lib/worktree.c +++ lib/worktree.c @@ -5023,6 +5023,19 @@ append_ct_diff(struct got_commitable *ct, int *diff_he 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 && + ct->status != GOT_STATUS_CONFLICT) + return NULL; + } + err = got_opentemp_truncate(f1); if (err) return got_error_from_errno("got_opentemp_truncate");
small got commit temp-diff fix