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

Re: [PATCH 2/3] rebase -i: Teach "--edit-todo" action

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 16, 2012, 06:54 UTC
Message-ID
<7v1ui2zccc.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1347739709-15289-3-git-send-email-andrew.kw.w@gmail.com>
Andrew Wong <andrew.kw.w@gmail.com> writes:
Show 46 quoted lines
> This allows users to edit the todo file while they're stopped in the
> middle of an interactive rebase. When this action is executed, all
> comments from the original todo file are stripped, and new help messages
> are appended to the end.
>
> Signed-off-by: Andrew Wong <andrew.kw.w@gmail.com>
> ---
>  Documentation/git-rebase.txt |  5 ++++-
>  git-rebase--interactive.sh   | 16 ++++++++++++++++
>  git-rebase.sh                | 14 ++++++++++++++
>  3 files changed, 34 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
> index fd535b0..da067ec 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
> +'git rebase' --continue | --skip | --abort | --edit-todo
>  
>  DESCRIPTION
>  -----------
> @@ -245,6 +245,9 @@ leave out at most one of A and B, in which case it defaults to HEAD.
>  --skip::
>  	Restart the rebasing process by skipping the current patch.
>  
> +--edit-todo::
> +	Edit the todo list during an interactive rebase.
> +
>  -m::
>  --merge::
>  	Use merging strategies to rebase.  When the recursive (default) merge
> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
> index 4d57e50..ca55fac 100644
> --- a/git-rebase--interactive.sh
> +++ b/git-rebase--interactive.sh
> @@ -792,6 +792,22 @@ skip)
>  
>  	do_rest
>  	;;
> +edit-todo)
> +	sed -i '/^#/d' "$todo"
> +	append_todo_help

I do not think the "sed -i" in-place edit is portable. AFAIK, it is not even in POSIX.1

In any case, what information are you discarding and then replacing with the standard boilerplate?

Show 29 quoted lines
> diff --git a/git-rebase.sh b/git-rebase.sh
> index 15da926..e660203 100755
> --- a/git-rebase.sh
> +++ b/git-rebase.sh
> @@ -38,6 +38,7 @@ C=!                passed to 'git apply'
>  continue!          continue
>  abort!             abort and check out the original branch
>  skip!              skip current patch and continue
> +edit-todo!         edit the todo list during an interactive rebase
>  "
>  . git-sh-setup
>  . git-sh-i18n
> @@ -194,6 +195,10 @@ do
>  		test $total_argc -eq 2 || usage
>  		action=${1##--}
>  		;;
> +	--edit-todo)
> +		test $total_argc -eq 2 || usage
> +		action=${1##--}
> +		;;
>  	--onto)
>  		test 2 -le "$#" || usage
>  		onto="$2"
> @@ -306,6 +311,12 @@ then
>  	fi
>  fi
>  
> +if test "$action" = "edit-todo" &&
> +	test "$type" != "interactive"
I do not see a need to split this short expression into two lines.
Previous: Andrew WongNext: Andrew Wong
Message 14 of 34 in “[RFC] Add "edit" action for interactive rebase?”
  1. Andrew WongSep 10, 2012
  2. rebase -i: Teach "--edit" actionAndrew Wong, Sep 10, 2012
  3. Matthieu MoySep 10, 2012
  4. Andrew WongSep 10, 2012
  5. Jeff KingSep 10, 2012
  6. Johannes SixtSep 10, 2012
  7. Jeff KingSep 10, 2012
  8. Andrew WongSep 10, 2012
  9. Junio C HamanoSep 10, 2012
  10. Andrew WongSep 10, 2012
  11. 0/3 rebase -i: Teach "--edit-todo"Andrew Wong, Sep 15, 2012
  12. 1/3 rebase -i: Refactor help messages for todo fileAndrew Wong, Sep 15, 2012
  13. 2/3 rebase -i: Teach "--edit-todo" actionAndrew Wong, Sep 15, 2012
  14. Junio C HamanoSep 16, 2012
  15. Andrew WongSep 16, 2012
  16. Junio C HamanoSep 18, 2012
  17. 3/3 rebase -i: Add tests for "--edit-todo"Andrew Wong, Sep 15, 2012
  18. Junio C HamanoSep 16, 2012
  19. 1/3 rebase -i: Refactor help messages for todo fileAndrew Wong, Sep 16, 2012
  20. 2/3 rebase -i: Teach "--edit-todo" actionAndrew Wong, Sep 16, 2012
  21. Martin von ZweigbergkSep 17, 2012
  22. 0/4 rebase -i: Teach "--edit-todo" actionAndrew Wong, Sep 18, 2012
  23. 1/4 rebase usage: subcommands can not be combined with -iAndrew Wong, Sep 18, 2012
  24. 2/4 rebase -i: Refactor help messages for todo fileAndrew Wong, Sep 18, 2012
  25. 3/4 rebase -i: Teach "--edit-todo" actionAndrew Wong, Sep 18, 2012
  26. 4/4 rebase -i: Add tests for "--edit-todo"Andrew Wong, Sep 18, 2012
  27. Martin von ZweigbergkSep 18, 2012
  28. Andrew WongSep 18, 2012
  29. Martin von ZweigbergkSep 18, 2012
  30. 5/4 rebase -i: suggest using --edit-todo to fix an unknown instructionJohannes Sixt, Sep 19, 2012
  31. Junio C HamanoSep 19, 2012
  32. 3/3 rebase -i: Add tests for "--edit-todo"Andrew Wong, Sep 16, 2012
  33. Johannes SixtSep 10, 2012
  34. Andrew WongSep 10, 2012

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.