Skip to content

Commit 98f3f00

Browse files
committed
Merge branch 'en/status-multiple-renames-to-the-same-target-fix'
The code in "git status" sometimes hit an assertion failure. This was caused by a structure that was reused without cleaning the data used for the first run, which has been corrected. * en/status-multiple-renames-to-the-same-target-fix: commit: fix erroneous BUG, 'multiple renames on the same target? how?'
2 parents e366d0c + 3e73cc6 commit 98f3f00

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

builtin/commit.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
874874
s->use_color = 0;
875875
commitable = run_status(s->fp, index_file, prefix, 1, s);
876876
s->use_color = saved_color_setting;
877+
string_list_clear(&s->change, 1);
877878
} else {
878879
struct object_id oid;
879880
const char *parent = "HEAD";

t/t7500-commit.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,4 +359,27 @@ test_expect_success 'new line found before status message in commit template' '
359359
test_i18ncmp expected-template editor-input
360360
'
361361

362+
test_expect_success 'setup empty commit with unstaged rename and copy' '
363+
test_create_repo unstaged_rename_and_copy &&
364+
(
365+
cd unstaged_rename_and_copy &&
366+
367+
echo content >orig &&
368+
git add orig &&
369+
test_commit orig &&
370+
371+
cp orig new_copy &&
372+
mv orig new_rename &&
373+
git add -N new_copy new_rename
374+
)
375+
'
376+
377+
test_expect_success 'check commit with unstaged rename and copy' '
378+
(
379+
cd unstaged_rename_and_copy &&
380+
381+
test_must_fail git -c diff.renames=copy commit
382+
)
383+
'
384+
362385
test_done

0 commit comments

Comments
 (0)