From 24ab81ae4d12c81076da256b3f9cdde45277f126 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 27 Oct 2009 20:52:57 -0400 Subject: add-interactive: handle deletion of empty files Usually we show deletion as a big hunk deleting all of the file's text. However, for files with no content, the diff shows just the 'deleted file mode ...' line. This patch cause "add -p" (and related commands) to recognize that line and explicitly ask about deleting the file. We only add the "stage this deletion" hunk for empty files, since other files will already ask about the big content deletion hunk. We could also change those files to simply display "stage this deletion", but showing the actual deleted content is probably what an interactive user wants. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t3701-add-interactive.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 't/t3701-add-interactive.sh') diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index 62fd65e18d..aa5909b14c 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -214,4 +214,21 @@ test_expect_success 'add first line works' ' test_cmp expected diff ' +cat >expected < empty && + git add empty && + git commit -m empty && + rm empty && + echo y | git add -p empty && + git diff --cached >diff && + test_cmp expected diff +' + test_done -- cgit v1.2.1