diff mbox series

[2/2] am: fix incorrect exit status on am fail to abort

Message ID 5fa7daf264b75fc5419e829683be2e6d83191908.1631067429.git.gitgitgadget@gmail.com (mailing list archive)
State Superseded
Headers show
Series A pair of git am --abort issues | expand

Commit Message

Elijah Newren Sept. 8, 2021, 2:17 a.m. UTC
From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 builtin/am.c        | 3 ++-
 t/t4151-am-abort.sh | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

Comments

Junio C Hamano Sept. 8, 2021, 4:33 p.m. UTC | #1
"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Elijah Newren <newren@gmail.com>
>
> Signed-off-by: Elijah Newren <newren@gmail.com>
> ---

Obviously correct.

>  builtin/am.c        | 3 ++-
>  t/t4151-am-abort.sh | 2 +-
>  2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/am.c b/builtin/am.c
> index 0c2ad96b70e..c79e0167e98 100644
> --- a/builtin/am.c
> +++ b/builtin/am.c
> @@ -2106,7 +2106,8 @@ static void am_abort(struct am_state *state)
>  	if (!has_orig_head)
>  		oidcpy(&orig_head, the_hash_algo->empty_tree);
>  
> -	clean_index(&curr_head, &orig_head);
> +	if (clean_index(&curr_head, &orig_head))
> +		die(_("failed to clean index"));
>  
>  	if (has_orig_head)
>  		update_ref("am --abort", "HEAD", &orig_head,
> diff --git a/t/t4151-am-abort.sh b/t/t4151-am-abort.sh
> index 501a7a9d211..f889f25a98f 100755
> --- a/t/t4151-am-abort.sh
> +++ b/t/t4151-am-abort.sh
> @@ -195,7 +195,7 @@ test_expect_success 'am --abort leaves index stat info alone' '
>  	git diff-files --exit-code --quiet
>  '
>  
> -test_expect_failure 'git am --abort return failed exit status when it fails' '
> +test_expect_success 'git am --abort return failed exit status when it fails' '
>  	test_when_finished "rm -rf file-2/ && git reset --hard" &&
>  	git checkout changes &&
>  	git format-patch -1 --stdout conflicting >changes.mbox &&
diff mbox series

Patch

diff --git a/builtin/am.c b/builtin/am.c
index 0c2ad96b70e..c79e0167e98 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -2106,7 +2106,8 @@  static void am_abort(struct am_state *state)
 	if (!has_orig_head)
 		oidcpy(&orig_head, the_hash_algo->empty_tree);
 
-	clean_index(&curr_head, &orig_head);
+	if (clean_index(&curr_head, &orig_head))
+		die(_("failed to clean index"));
 
 	if (has_orig_head)
 		update_ref("am --abort", "HEAD", &orig_head,
diff --git a/t/t4151-am-abort.sh b/t/t4151-am-abort.sh
index 501a7a9d211..f889f25a98f 100755
--- a/t/t4151-am-abort.sh
+++ b/t/t4151-am-abort.sh
@@ -195,7 +195,7 @@  test_expect_success 'am --abort leaves index stat info alone' '
 	git diff-files --exit-code --quiet
 '
 
-test_expect_failure 'git am --abort return failed exit status when it fails' '
+test_expect_success 'git am --abort return failed exit status when it fails' '
 	test_when_finished "rm -rf file-2/ && git reset --hard" &&
 	git checkout changes &&
 	git format-patch -1 --stdout conflicting >changes.mbox &&