git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 5/9] t3510 (cherry-pick-sequencer): use exit status

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Dec 9, 2011, 20:21 UTC
Message-ID
<20111209202149.GH20913@elie.hsd1.il.comcast.net>
In-Reply-To
<1323445326-24637-6-git-send-email-artagnon@gmail.com>
Ramkumar Ramachandra wrote:
Show 6 quoted lines
> Since cf3e2486 (revert: Propagate errors upwards from do_pick_commit,
> 2011-08-04), 'git cherry-pick' has three different ways of failing:
>
> 1. die() with the exit status 128.
> 3. error() out with exit status -1.
> 2. exit with positive exit status to indicate a conflict.
I think your list-item counter is showing a little jitter. :)

error() does not produce exit status -1, and any situation other than propagating exit status from a user-defined script in which git exits with status 255 is a bug (yes, I know there are a couple, though none I know of in cherry-pick code paths).

Hasn't cherry-pick had two ways to exit with failing status like "git merge" does (conflicts versus error that didn't even allow us to start) since the very beginning?

[...]
>                   So, replace all instances of 'test_must_fail' with
> 'test_expect_code' to check the exit status explicitly.

Sounds like a sensible idea. Probably this one sentence, plus a quick note on the user-visible exit status convention, would suffice for explaining it.

> --- a/t/t3510-cherry-pick-sequence.sh
> +++ b/t/t3510-cherry-pick-sequence.sh
[...]
Show 7 quoted lines
> @@ -53,7 +53,7 @@ test_expect_success 'cherry-pick persists data on failure' '
>  
>  test_expect_success 'cherry-pick persists opts correctly' '
>  	pristine_detach initial &&
> -	test_must_fail git cherry-pick -s -m 1 --strategy=recursive -X patience -X ours base..anotherpick &&
> +	test_expect_code 128 git cherry-pick -s -m 1 --strategy=recursive -X patience -X ours base..anotherpick &&
>  	test_path_is_dir .git/sequencer &&

Encountered conflicts, preserving options, but the exit is with status 128? Smells like a bug.

[...]
Show 6 quoted lines
> @@ -88,12 +88,12 @@ test_expect_success '--quit does not complain when no cherry-pick is in progress
>  
>  test_expect_success '--abort requires cherry-pick in progress' '
>  	pristine_detach initial &&
> -	test_must_fail git cherry-pick --abort
> +	test_expect_code 128 git cherry-pick --abort

I don't think the exit status is important for this one. (I.e., I can imagine some future version of cherry-pick using different small positive integers to refer to different reasons for --abort to fail, and I don't think that would be a problem or break anything.)

[...]
Show 9 quoted lines
> @@ -179,9 +179,9 @@ test_expect_success '--abort keeps unrelated change, easy case' '
>  test_expect_success '--abort refuses to clobber unrelated change, harder case' '
>  	pristine_detach initial &&
>  	echo changed >expect &&
> -	test_must_fail git cherry-pick base..anotherpick &&
> +	test_expect_code 1 git cherry-pick base..anotherpick &&
>  	echo changed >unrelated &&
> -	test_must_fail git cherry-pick --abort &&
> +	test_expect_code 128 git cherry-pick --abort &&
Likewise here.
Except as noted above,
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Previous: Ramkumar RamachandraNext: Ramkumar Ramachandra
Message 14 of 45 in “Re-roll rr/revert-cherry-pick v2”
  1. 0/9 Re-roll rr/revert-cherry-pick v2Ramkumar Ramachandra, Dec 9, 2011
  2. 1/9 revert: free msg in format_todo()Ramkumar Ramachandra, Dec 9, 2011
  3. 2/9 revert: make commit subjects in insn sheet optionalRamkumar Ramachandra, Dec 9, 2011
  4. Jonathan NiederDec 9, 2011
  5. 3/9 revert: tolerate extra spaces, tabs in insn sheetRamkumar Ramachandra, Dec 9, 2011
  6. Jonathan NiederDec 9, 2011
  7. Ramkumar RamachandraDec 9, 2011
  8. Junio C HamanoDec 9, 2011
  9. Ramkumar RamachandraDec 9, 2011
  10. 4/9 revert: simplify getting commit subject in format_todo()Ramkumar Ramachandra, Dec 9, 2011
  11. Jonathan NiederDec 9, 2011
  12. Ramkumar RamachandraDec 9, 2011
  13. 5/9 t3510 (cherry-pick-sequencer): use exit statusRamkumar Ramachandra, Dec 9, 2011
  14. Jonathan NiederDec 9, 2011
  15. Ramkumar RamachandraDec 9, 2011
  16. Jonathan NiederDec 9, 2011
  17. 6/9 t3510 (cherry-pick-sequencer): remove malformed sheet 2Ramkumar Ramachandra, Dec 9, 2011
  18. Jonathan NiederDec 9, 2011
  19. Ramkumar RamachandraDec 9, 2011
  20. Jonathan NiederDec 9, 2011
  21. 7/9 revert: allow mixed pick and revert instructionsRamkumar Ramachandra, Dec 9, 2011
  22. Jonathan NiederDec 9, 2011
  23. 8/9 revert: report fine-grained error messages from insn parserRamkumar Ramachandra, Dec 9, 2011
  24. Jonathan NiederDec 9, 2011
  25. 9/9 revert: simplify communicating command-line argumentsRamkumar Ramachandra, Dec 9, 2011
  26. Jonathan NiederDec 9, 2011
  27. Ramkumar RamachandraDec 9, 2011
  28. Jonathan NiederDec 9, 2011
  29. Ramkumar RamachandraDec 9, 2011
  30. Jonathan NiederDec 9, 2011
  31. Jonathan NiederDec 9, 2011
  32. Ramkumar RamachandraDec 9, 2011
  33. 00/10 Re-roll rr/revert-cherry-pick v3Ramkumar Ramachandra, Dec 14, 2011
  34. 01/10 revert: free msg in format_todo()Ramkumar Ramachandra, Dec 14, 2011
  35. 02/10 revert: make commit subjects in insn sheet optionalRamkumar Ramachandra, Dec 14, 2011
  36. 03/10 revert: tolerate extra spaces, tabs in insn sheetRamkumar Ramachandra, Dec 14, 2011
  37. 04/10 revert: simplify getting commit subject in format_todo()Ramkumar Ramachandra, Dec 14, 2011
  38. 05/10 t3510 (cherry-pick-sequencer): use exit statusRamkumar Ramachandra, Dec 14, 2011
  39. 06/10 t3502, t3510: clarify cherry-pick -m failureRamkumar Ramachandra, Dec 14, 2011
  40. 07/10 t3510 (cherry-pick-sequencer): remove malformed sheet 2Ramkumar Ramachandra, Dec 14, 2011
  41. 08/10 revert: move replay_action, replay_subcommand to headerRamkumar Ramachandra, Dec 14, 2011
  42. 09/10 revert: allow mixed pick and revert instructionsRamkumar Ramachandra, Dec 14, 2011
  43. 10/10 revert: report fine-grained error messages from insn parserRamkumar Ramachandra, Dec 14, 2011
  44. Junio C HamanoDec 15, 2011
  45. Ramkumar RamachandraDec 15, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.