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

Re: [RFC 2/3] rebase -i: Reschedule tasks that failed before the index was touched

From
Phil Hord <hordp@cisco.com>
Date
May 27, 2014, 18:26 UTC
Message-ID
<5384D8DA.40005@cisco.com>
In-Reply-To
<53847D7D.5050000@alum.mit.edu>
Hi Fabian,
Thanks for looking into this.
On 05/27/2014 07:56 AM, Michael Haggerty wrote:
Show 23 quoted lines
>> +reschedule_last_action () {
>> +	tail -n 1 "$done" | cat - "$todo" >"$todo".new
>> +	sed -e \$d <"$done" >"$done".new
>> +	mv -f "$todo".new "$todo"
>> +	mv -f "$done".new "$done"
>> +}
>> +
>>  append_todo_help () {
>>  	git stripspace --comment-lines >>"$todo" <<\EOF
>>  
>> @@ -470,11 +480,15 @@ do_pick () {
>>  			   --no-post-rewrite -n -q -C $1 &&
>>  			pick_one -n $1 &&
>>  			git commit --allow-empty --allow-empty-message \
>> -				   --amend --no-post-rewrite -n -q -C $1 ||
>> -			die_with_patch $1 "Could not apply $1... $2"
>> +				   --amend --no-post-rewrite -n -q -C $1
> "git cherry-pick" indicates its error status specifically as 1 or some
> other value.  But here it could be that pick_one succeeds but "git
> commit" fails; in that case ret is set to the return code of "git
> commit".  So, if "git commit" fails with a retcode different than 1,
> then reschedule_last_action will be called a few lines later.  This
> seems incorrect to me.

I agree. I was thinking that pick_one should get this new behavior instead of do_pick, but some callers may not appreciate the new behavior (i.e. squash/fixup), though I expect those callers have similar problems as this commit is trying to fix.

I think adding a pick_one_with_reschedule function (to be called in both places from do_pick) could solve the issue Michael mentioned without breaking other pick_one callers.

I have not tested doing so, but I think it would look like this:
===================
diff --git i/git-rebase--interactive.sh w/git-rebase--interactive.sh
index fe813ba..ae5603a 100644
--- i/git-rebase--interactive.sh
+++ w/git-rebase--interactive.sh
@@ -235,6 +235,17 @@ git_sequence_editor () {
     eval "$GIT_SEQUENCE_EDITOR" '"$@"'
 }
 
+pick_one_with_reschedule () {
+    pick_one $1
+    ret=$?
+    case "$ret" in
+        0) ;;
+        1) ;;
+        *) reschedule_last_action ;;
+    esac
+    return $ret
+}
+
 pick_one () {
     ff=--ff
 
@@ -474,13 +485,13 @@ do_pick () {
         # rebase --continue.
         git commit --allow-empty --allow-empty-message --amend \
                --no-post-rewrite -n -q -C $1 &&
-            pick_one -n $1 &&
+            pick_one_with_reschedule -n $1 &&
             git commit --allow-empty --allow-empty-message \
                    --amend --no-post-rewrite -n -q -C $1 \
                    ${gpg_sign_opt:+"$gpg_sign_opt"} ||
             die_with_patch $1 "Could not apply $1... $2"
     else
-        pick_one $1 ||
+        pick_one_with_reschedule $1 ||
             die_with_patch $1 "Could not apply $1... $2"
     fi
 }

===================

I don't much like the name 'pick_one_with_reschedule', but I didn't like
my other choices, either.

I'll try to look at this and your patches more closely when I have a bit
more time.

Phil
Previous: Michael HaggertyNext: Fabian Ruch
Message 10 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.