From ffbc5dc2d0cbdbd63a4ae04dc2cc1ebf385fcc25 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Tue, 19 Jan 2010 05:25:58 +0100 Subject: reset: add test cases for "--keep" option This shows that with the "--keep" option, changes that are both in the work tree and the index are kept in the work tree after the reset (but discarded in the index). In the case of unmerged entries, we can see that "git reset --keep" works only when the target state is the same as HEAD. And then the work tree is not reset. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- t/t7111-reset-table.sh | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 't/t7111-reset-table.sh') diff --git a/t/t7111-reset-table.sh b/t/t7111-reset-table.sh index de896c948d..2ebda97828 100755 --- a/t/t7111-reset-table.sh +++ b/t/t7111-reset-table.sh @@ -44,26 +44,32 @@ A B C D soft A B D A B C D mixed A D D A B C D hard D D D A B C D merge XXXXX +A B C D keep XXXXX A B C C soft A B C A B C C mixed A C C A B C C hard C C C A B C C merge XXXXX +A B C C keep A C C B B C D soft B B D B B C D mixed B D D B B C D hard D D D B B C D merge D D D +B B C D keep XXXXX B B C C soft B B C B B C C mixed B C C B B C C hard C C C B B C C merge C C C +B B C C keep B C C B C C D soft B C D B C C D mixed B D D B C C D hard D D D B C C D merge XXXXX +B C C D keep XXXXX B C C C soft B C C B C C C mixed B C C B C C C hard C C C B C C C merge B C C +B C C C keep B C C EOF test_expect_success 'setting up branches to test with unmerged entries' ' @@ -104,10 +110,12 @@ X U B C soft XXXXX X U B C mixed X C C X U B C hard C C C X U B C merge C C C +X U B C keep XXXXX X U B B soft XXXXX X U B B mixed X B B X U B B hard B B B X U B B merge B B B +X U B B keep X B B EOF test_done -- cgit v1.2.3 From 812d2a3d61b1bbb1931aff2ed6d2a17e939f5bf2 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Tue, 19 Jan 2010 05:26:01 +0100 Subject: reset: disallow using --keep when there are unmerged entries The use case for --keep option is to remove previous commits unrelated to the current changes in the working tree. So in this use case we are not supposed to have unmerged entries. This is why it seems safer to just disallow using --keep when there are unmerged entries. And this patch changes the error message when --keep was disallowed and there were some unmerged entries from: error: Entry 'file1' would be overwritten by merge. Cannot merge. fatal: Could not reset index file to revision 'HEAD^'. to: fatal: Cannot do a keep reset in the middle of a merge. which is nicer. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- t/t7111-reset-table.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t7111-reset-table.sh') diff --git a/t/t7111-reset-table.sh b/t/t7111-reset-table.sh index 2ebda97828..ce421ad5ac 100755 --- a/t/t7111-reset-table.sh +++ b/t/t7111-reset-table.sh @@ -115,7 +115,7 @@ X U B B soft XXXXX X U B B mixed X B B X U B B hard B B B X U B B merge B B B -X U B B keep X B B +X U B B keep XXXXX EOF test_done -- cgit v1.2.3