rebase -i: handle "Nothing to do" case with autostash
When a user invokes $ git rebase -i @~3 with dirty files and rebase.autostash turned on, and exits the $EDITOR with an empty buffer, the autostash fails to apply. Although the primary focus of rr/rebase-autostash was to get the git-rebase--backend.sh scripts to return control to git-rebase.sh, it missed this case in git-rebase--interactive.sh. Since this case is unlike the other cases which return control for housekeeping, assign it a special return status and handle that return value explicitly in git-rebase.sh. Reported-by: Karen Etheridge <ether@cpan.org> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
							parent
							
								
									ac1998dedd
								
							
						
					
					
						commit
						e4244eb395
					
				|  | @ -970,14 +970,14 @@ fi | ||||||
|  |  | ||||||
|  |  | ||||||
| has_action "$todo" || | has_action "$todo" || | ||||||
| 	die_abort "Nothing to do" | 	return 2 | ||||||
|  |  | ||||||
| cp "$todo" "$todo".backup | cp "$todo" "$todo".backup | ||||||
| git_sequence_editor "$todo" || | git_sequence_editor "$todo" || | ||||||
| 	die_abort "Could not execute editor" | 	die_abort "Could not execute editor" | ||||||
|  |  | ||||||
| has_action "$todo" || | has_action "$todo" || | ||||||
| 	die_abort "Nothing to do" | 	return 2 | ||||||
|  |  | ||||||
| test -d "$rewritten" || test -n "$force_rebase" || skip_unnecessary_picks | test -d "$rewritten" || test -n "$force_rebase" || skip_unnecessary_picks | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @ -147,7 +147,7 @@ move_to_original_branch () { | ||||||
| 	esac | 	esac | ||||||
| } | } | ||||||
|  |  | ||||||
| finish_rebase () { | apply_autostash () { | ||||||
| 	if test -f "$state_dir/autostash" | 	if test -f "$state_dir/autostash" | ||||||
| 	then | 	then | ||||||
| 		stash_sha1=$(cat "$state_dir/autostash") | 		stash_sha1=$(cat "$state_dir/autostash") | ||||||
|  | @ -166,6 +166,10 @@ You can run "git stash pop" or "git stash drop" at any time. | ||||||
| ' | ' | ||||||
| 		fi | 		fi | ||||||
| 	fi | 	fi | ||||||
|  | } | ||||||
|  |  | ||||||
|  | finish_rebase () { | ||||||
|  | 	apply_autostash && | ||||||
| 	git gc --auto && | 	git gc --auto && | ||||||
| 	rm -rf "$state_dir" | 	rm -rf "$state_dir" | ||||||
| } | } | ||||||
|  | @ -181,6 +185,11 @@ run_specific_rebase () { | ||||||
| 	if test $ret -eq 0 | 	if test $ret -eq 0 | ||||||
| 	then | 	then | ||||||
| 		finish_rebase | 		finish_rebase | ||||||
|  | 	elif test $ret -eq 2 # special exit status for rebase -i | ||||||
|  | 	then | ||||||
|  | 		apply_autostash && | ||||||
|  | 		rm -rf "$state_dir" && | ||||||
|  | 		die "Nothing to do" | ||||||
| 	fi | 	fi | ||||||
| 	exit $ret | 	exit $ret | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Ramkumar Ramachandra
						Ramkumar Ramachandra