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

[RFC 1/3] sequencer: Signal failed ff as an aborted, not a conflicted merge

From
Fabian Ruch <bafain@gmail.com>
Date
May 26, 2014, 22:19 UTC
Message-ID
<5383BDE4.9000704@gmail.com>
In-Reply-To
<533C913C.20106@cisco.com>

`do_pick_commit` handles three situations if it is not fast-forwarding. In order for `do_pick_commit` to identify the situation, it examines the return value of the selected merge command.

1. return value 0 stands for a clean merge
2. 1 is passed in case of a failed merge due to conflict
3. any other return value means that the merge did not even start

So far, the sequencer returns 1 in case of a failed fast-forward, which would mean "failed merge due to conflict". However, a fast-forward either starts and succeeds or does not start at all. In particular, it cannot fail in between like a merge with a dirty index due to conflicts.

In order to signal the three possible situations (not only success and failure to complete) after a pick through porcelain commands such as `cherry-pick`, exit with a return value that is neither 0 nor 1. -1 was chosen in line with the other situations in which the sequencer encounters an error.

Signed-off-by: Fabian Ruch <bafain@gmail.com>
---
 sequencer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sequencer.c b/sequencer.c
index 90cac7b..97cecca 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -278,7 +278,7 @@ static int fast_forward_to(const unsigned char *to, const unsigned char *from,
 
 	read_cache();
 	if (checkout_fast_forward(from, to, 1))
-		exit(1); /* the callee should have complained already */
+		exit(-1); /* the callee should have complained already */
 	ref_lock = lock_any_ref_for_update("HEAD", unborn ? null_sha1 : from,
 					   0, NULL);
 	strbuf_addf(&sb, "%s: fast-forward", action_name(opts));
-- 
1.9.3
Previous: Phil HordNext: Junio C Hamano
Message 2 of 13 in “git-rebase-todo gets popped prematurely”
  1. Phil HordApr 2, 2014
  2. 1/3 sequencer: Signal failed ff as an aborted, not a conflicted mergeFabian Ruch, May 26, 2014
  3. Junio C HamanoMay 27, 2014
  4. Fabian RuchJun 9, 2014
  5. Junio C HamanoJun 10, 2014
  6. Phil HordJun 10, 2014
  7. Junio C HamanoJun 10, 2014
  8. 2/3 rebase -i: Reschedule tasks that failed before the index was touchedFabian Ruch, May 26, 2014
  9. Michael HaggertyMay 27, 2014
  10. Phil HordMay 27, 2014
  11. 3/3 tests: Add 'rebase -i commits that overwrite untracked files'Fabian Ruch, May 26, 2014
  12. Michael HaggertyMay 27, 2014
  13. Junio C HamanoMay 27, 2014

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.