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

Re: [PATCH] rebase [-i --exec | -ix] <CMD>...

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Jun 4, 2012, 17:48 UTC
Message-ID
<vpqk3znrmrh.fsf@bauges.imag.fr>
In-Reply-To
<1338817674-22877-1-git-send-email-Lucien.Kong@ensimag.imag.fr>
Kong Lucien <Lucien.Kong@ensimag.imag.fr> writes:
Show 21 quoted lines
> --- a/Documentation/git-rebase.txt
> +++ b/Documentation/git-rebase.txt
> @@ -8,9 +8,9 @@ git-rebase - Forward-port local commits to the updated upstream head
>  SYNOPSIS
>  --------
>  [verse]
> -'git rebase' [-i | --interactive] [options] [--onto <newbase>]
> +'git rebase' [-i | --interactive] [options] [--exec <cmd>] [--onto <newbase>]
>  	[<upstream>] [<branch>]
> -'git rebase' [-i | --interactive] [options] --onto <newbase>
> +'git rebase' [-i | --interactive] [options] [--exec <cmd>] --onto <newbase>
>  	--root [<branch>]
>  'git rebase' --continue | --skip | --abort
>  
> @@ -210,6 +210,17 @@ rebase.autosquash::
>  
>  OPTIONS
>  -------
> +<cmd>::
> +	Shell command executed between each commit applications. The
> +	--exec option has to be specified.
[...]
> +-x::
> +--exec::

That seems weird to have --exec <cmd> specification split into one for --exec, and another for <cmd> ...

> +You may execute several commands between each commit applications.
> +Therefore, you can use one instance of exec:
> +	git rebase -i --exec "cmd1; cmd2; ...".
s/Therefore/For this/ ?
(Therefore = donc in French)
Show 10 quoted lines
> +if test -n "$cmd"
> +then
> +	OIFS=$IFS
> +	IFS=','
> +	for i in $cmd
> +	do
> +		sed "/^pick .*/aexec $i" "$todo" >tmp
> +		cat tmp >"$todo"
> +	done
> +	rm tmp

Isn't this executed from the top of the workdir? What if the user already has a file named tmp there?

Show 6 quoted lines
> +			if test -n "$cmd"
> +			then
> +				cmd="$2,$cmd"
> +			else
> +				cmd="$2"
> +			fi

What happens when <cmd> contains a comma (e.g. --exec "rm file,with,commas,in,name.txt") ?

If you don't allow this case, then you should error out instead of executing a weird behavior silently. Or you can escape the comma and unescape it later, but that may be overkill.

Show 6 quoted lines
> +if test -n "$exec_flag" &&
> +   test -z "$interactive_rebase"
> +then
> +	echo "--exec option must be used with --interactive option\n"
> +	usage
> +fi

I'd even skip the "usage" here, as the error message is clear enough (and is much less visible before a page of "usage" output). Just die-ing would be better I think.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Junio C HamanoNext: Lucien Kong
Message 7 of 50 in “rebase [-i --exec | -ix] <CMD>...”
  1. rebase [-i --exec | -ix] <CMD>...Kong Lucien, Jun 4, 2012
  2. Junio C HamanoJun 4, 2012
  3. Matthieu MoyJun 4, 2012
  4. Junio C HamanoJun 4, 2012
  5. konglu@minatec.inpg.frJun 5, 2012
  6. Junio C HamanoJun 5, 2012
  7. Matthieu MoyJun 4, 2012
  8. [PATCHv2] rebase [-i --exec | -ix] <CMD>...Lucien Kong, Jun 6, 2012
  9. Matthieu MoyJun 6, 2012
  10. Junio C HamanoJun 6, 2012
  11. Zbigniew Jędrzejewski-SzmekJun 7, 2012
  12. Johannes SixtJun 7, 2012
  13. konglu@minatec.inpg.frJun 7, 2012
  14. Matthieu MoyJun 7, 2012
  15. 1/2 git-rebase.txt: "--onto" option updatedLucien Kong, Jun 8, 2012
  16. 2/2 rebase [-i --exec | -ix] <CMD>...Lucien Kong, Jun 8, 2012
  17. Johannes SixtJun 8, 2012
  18. Torsten BögershausenJun 8, 2012
  19. konglu@minatec.inpg.frJun 8, 2012
  20. Torsten BögershausenJun 8, 2012
  21. konglu@minatec.inpg.frJun 8, 2012
  22. Torsten BögershausenJun 8, 2012
  23. konglu@minatec.inpg.frJun 8, 2012
  24. Torsten BögershausenJun 9, 2012
  25. konglu@minatec.inpg.frJun 9, 2012
  26. [PATCHv4] rebase [-i --exec | -ix] <CMD>...Lucien Kong, Jun 10, 2012
  27. Johannes SixtJun 10, 2012
  28. Junio C HamanoJun 11, 2012
  29. Johannes SixtJun 12, 2012
  30. Junio C HamanoJun 12, 2012
  31. [PATCHv5] rebase [-i --exec | -ix] <CMD>...Lucien Kong, Jun 12, 2012
  32. Zbigniew Jędrzejewski-SzmekJun 12, 2012
  33. Junio C HamanoJun 12, 2012
  34. Zbigniew Jędrzejewski-SzmekJun 13, 2012
  35. Junio C HamanoJun 13, 2012
  36. konglu@minatec.inpg.frJun 13, 2012
  37. Junio C HamanoJun 13, 2012
  38. konglu@minatec.inpg.frJun 13, 2012
  39. Johannes SixtJun 13, 2012
  40. Zbigniew Jędrzejewski-SzmekJun 13, 2012
  41. Junio C HamanoJun 13, 2012
  42. Junio C HamanoJun 13, 2012
  43. Zbigniew Jędrzejewski-SzmekJun 13, 2012
  44. Matthieu MoyJun 14, 2012
  45. Marc BranchaudJun 14, 2012
  46. Matthieu MoyJun 8, 2012
  47. Junio C HamanoJun 8, 2012
  48. konglu@minatec.inpg.frJun 8, 2012
  49. Junio C HamanoJun 8, 2012
  50. konglu@minatec.inpg.frJun 8, 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.