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

Re: [PATCH 2/2] rebase: add --show-patch

From
PWPhillip Wood <phillip.wood@talktalk.net>
Date
Jan 26, 2018, 11:12 UTC
Message-ID
<4d7eb4c8-8d48-7c8d-259a-ba6b2f64def0@talktalk.net>
In-Reply-To
<20180126095520.919-3-pclouds@gmail.com>
On 26/01/18 09:55, Nguyễn Thái Ngọc Duy wrote:
Show 111 quoted lines
> 
> It is useful to see the full patch while resolving conflicts in a
> rebase. The only way to do it now is
> 
>     less .git/rebase-*/patch
> 
> which could turn out to be a lot longer to type [1] if you are in a
> linked worktree, or not at top-dir. On top of that, an ordinary user
> should not need to peek into .git directory. The new option is
> provided to examine the patch.
> 
> [1] A conflict caused by git-rebase--am.sh does show the path to this
>     patch file so you could copy/paste. But then after some time and
>     lots of commands to resolve the conflict, that path is likely
>     scrolled out of your terminal.
> 
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  Documentation/git-rebase.txt           |  5 +++-
>  contrib/completion/git-completion.bash |  4 +--
>  git-rebase--am.sh                      |  3 +++
>  git-rebase--interactive.sh             |  4 +++
>  git-rebase--merge.sh                   |  4 +++
>  git-rebase.sh                          |  7 +++++-
>  t/t3400-rebase.sh                      | 34 ++++++++++++++++++++++++++
>  t/t3404-rebase-interactive.sh          |  6 +++++
>  8 files changed, 63 insertions(+), 4 deletions(-)
> 
> diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
> index 8a861c1e0d..4fd571d393 100644
> --- a/Documentation/git-rebase.txt
> +++ b/Documentation/git-rebase.txt
> @@ -12,7 +12,7 @@ SYNOPSIS
>  	[<upstream> [<branch>]]
>  'git rebase' [-i | --interactive] [options] [--exec <cmd>] [--onto <newbase>]
>  	--root [<branch>]
> -'git rebase' --continue | --skip | --abort | --quit | --edit-todo
> +'git rebase' --continue | --skip | --abort | --quit | --edit-todo | --show-patch
>  
>  DESCRIPTION
>  -----------
> @@ -250,6 +250,9 @@ leave out at most one of A and B, in which case it defaults to HEAD.
>  --edit-todo::
>  	Edit the todo list during an interactive rebase.
>  
> +--show-patch::
> +	Show the current patch in an interactive rebase.
> +
>  -m::
>  --merge::
>  	Use merging strategies to rebase.  When the recursive (default) merge
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 1e9105f6d5..b70da4990f 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -1992,11 +1992,11 @@ _git_rebase ()
>  {
>  	__git_find_repo_path
>  	if [ -f "$__git_repo_path"/rebase-merge/interactive ]; then
> -		__gitcomp "--continue --skip --abort --quit --edit-todo"
> +		__gitcomp "--continue --skip --abort --quit --edit-todo --show-patch"
>  		return
>  	elif [ -d "$__git_repo_path"/rebase-apply ] || \
>  	     [ -d "$__git_repo_path"/rebase-merge ]; then
> -		__gitcomp "--continue --skip --abort --quit"
> +		__gitcomp "--continue --skip --abort --quit --show-patch"
>  		return
>  	fi
>  	__git_complete_strategy && return
> diff --git a/git-rebase--am.sh b/git-rebase--am.sh
> index 14c50782e0..564a4a5830 100644
> --- a/git-rebase--am.sh
> +++ b/git-rebase--am.sh
> @@ -27,6 +27,9 @@ skip)
>  	move_to_original_branch
>  	return
>  	;;
> +show-patch)
> +	exec git am --show-patch
> +	;;
>  esac
>  
>  if test -z "$rebase_root"
> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
> index d47bd29593..01cc002efd 100644
> --- a/git-rebase--interactive.sh
> +++ b/git-rebase--interactive.sh
> @@ -840,6 +840,10 @@ To continue rebase after editing, run:
>  
>  	exit
>  	;;
> +show-patch)
> +	cmt="$(cat "$state_dir/stopped-sha")"
> +	exec git format-patch --subject-prefix= --stdout "${cmt}^!"
> +	;;
>  esac
>  
>  comment_for_reflog start
> diff --git a/git-rebase--merge.sh b/git-rebase--merge.sh
> index 06a4723d4d..5c513a9736 100644
> --- a/git-rebase--merge.sh
> +++ b/git-rebase--merge.sh
> @@ -137,6 +137,10 @@ skip)
>  	finish_rb_merge
>  	return
>  	;;
> +show-patch)
> +	cmt="$(cat "$state_dir/current")"
> +	exec git format-patch --subject-prefix= --stdout "${cmt}^!"
> +	;;
>  esac

Here and in the git-rebase--interactive you have access to the SHA of the failed pick so you could run git log --patch and git colored output and it would use the pager in the same way as 'git am --show-patch' does

Best Wishes
Phillip
Previous: Nguyễn Thái Ngọc DuyNext: Duy Nguyen
Message 4 of 40 in “Add "git rebase --show-patch"”
  1. 0/2 Add "git rebase --show-patch"Nguyễn Thái Ngọc Duy, Jan 26, 2018
  2. 1/2 am: add --show-patchNguyễn Thái Ngọc Duy, Jan 26, 2018
  3. 2/2 rebase: add --show-patchNguyễn Thái Ngọc Duy, Jan 26, 2018
  4. Phillip WoodJan 26, 2018
  5. Duy NguyenJan 26, 2018
  6. Phillip WoodJan 30, 2018
  7. Eric SunshineJan 26, 2018
  8. Duy NguyenJan 27, 2018
  9. Tim LandscheidtJan 26, 2018
  10. Duy NguyenJan 27, 2018
  11. Ævar Arnfjörð BjarmasonJan 27, 2018
  12. Johannes SchindelinJan 29, 2018
  13. Duy NguyenJan 30, 2018
  14. Johannes SchindelinJan 30, 2018
  15. Junio C HamanoJan 30, 2018
  16. Tim LandscheidtFeb 1, 2018
  17. 0/3 Add "git rebase --show-patch"Nguyễn Thái Ngọc Duy, Jan 31, 2018
  18. 1/3 am: add --show-current-patchNguyễn Thái Ngọc Duy, Jan 31, 2018
  19. Eric SunshineJan 31, 2018
  20. Junio C HamanoJan 31, 2018
  21. Duy NguyenFeb 2, 2018
  22. Eric SunshineFeb 2, 2018
  23. Duy NguyenFeb 2, 2018
  24. Junio C HamanoFeb 2, 2018
  25. gitignore.txt: elaborate shell glob syntaxNguyễn Thái Ngọc Duy, Jan 31, 2018
  26. Junio C HamanoJan 31, 2018
  27. Duy NguyenFeb 1, 2018
  28. 2/3 rebase: add --show-current-patchNguyễn Thái Ngọc Duy, Jan 31, 2018
  29. 3/3 rebase: introduce and use pseudo-ref ORIG_COMMITNguyễn Thái Ngọc Duy, Jan 31, 2018
  30. Junio C HamanoJan 31, 2018
  31. Duy NguyenFeb 1, 2018
  32. Junio C HamanoFeb 2, 2018
  33. Phillip WoodFeb 1, 2018
  34. 0/3 Add "git rebase --show-current-patch"Nguyễn Thái Ngọc Duy, Feb 11, 2018
  35. 1/3 am: add --show-current-patchNguyễn Thái Ngọc Duy, Feb 11, 2018
  36. 2/3 rebase: add --show-current-patchNguyễn Thái Ngọc Duy, Feb 11, 2018
  37. 3/3 rebase: introduce and use pseudo-ref REBASE_HEADNguyễn Thái Ngọc Duy, Feb 11, 2018
  38. Junio C HamanoFeb 22, 2018
  39. Tim LandscheidtFeb 22, 2018
  40. Duy NguyenFeb 23, 2018

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.