From: Johannes Sixt <j6t@kdbg.org>
To: Lucien Kong <Lucien.Kong@ensimag.imag.fr>
Cc: git@vger.kernel.org,
Valentin Duperray <Valentin.Duperray@ensimag.imag.fr>,
Franck Jonas <Franck.Jonas@ensimag.imag.fr>,
Thomas Nguy <Thomas.Nguy@ensimag.imag.fr>,
Huynh Khoi Nguyen Nguyen
<Huynh-Khoi-Nguyen.Nguyen@ensimag.imag.fr>,
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Subject: Re: [PATCHv2] rebase [-i --exec | -ix] <CMD>...
Date: Thu, 07 Jun 2012 10:40:38 +0200 [thread overview]
Message-ID: <4FD06906.1080007@kdbg.org> (raw)
In-Reply-To: <1338978856-26838-1-git-send-email-Lucien.Kong@ensimag.imag.fr>
Am 06.06.2012 12:34, schrieb Lucien Kong:
> This patch provides a way to automatically add these "exec" lines
> between each commit applications. For instance, running 'git rebase -i
> --exec "make test"' lets you check that intermediate commits are
> compilable.
While I won't be a heavy user of this feature, I think it has some merit
as a porcelain feature, particularly because it is rather cumbersome to
achieve the same effect as in the given example without plumbing commands.
> +-x <cmd>::
> +--exec <cmd>::
...
> ++
> +This has to be used along with the `--interactive` option explicitly.
...
> +
> +If the option '-i' is missing, The command will return a message
> +error. If there is no <cmd> specified behind --exec, the command will
> +return a message error and the usage page of 'git rebase'.
The important part (that -x needs -i) of this paragraph are already
spelled out above, and the exact error behavior does not need a
description in the manual. Drop this paragraph.
BTW, I don't think it is a good idea to dump the usage if -x was used
without -i.
> +# Add commands after a pick or after a squash/fixup serie
> +# in the todo list.
> +add_exec_commands () {
> + OIFS=$IFS
> + IFS=$LF
> + for i in $cmd
> + do
> + tmp=$(sed "/^pick .*/i\
> + exec $i" "$1")
Does this white-space before 'exec' not end up in the todo list?
I think it is wise to use introduce sed expressions by using -e. This
applies to all 'sed' invocations that this patch introduces (also in the
test-suite).
> + echo "$tmp" >"$1"
Some 'echo' implementations expand escape sequences in the supplied
texts. To avoid it (this is user-supplied text!), do this:
printf "%s\n" "$tmp" >"$1"
> + tmp=$(sed '1d' "$1")
> + echo "$tmp" >"$1"
> + echo "exec $i" >>"$1"
Ditto.
> + done
> + IFS=$OIFS
> +}
> + -x)
> + test 2 -le "$#" || usage
> + cmd="${cmd:+"$cmd$LF"} $2"
The quoting here is *very* odd. The outer dquotes do extend their effect
into the replacement word after the :+ operator. I am surprised that so
many shells grok it. ash does not, by the way. Also, you don't need the
space anymore. Therefore:
cmd="${cmd:+$cmd$LF}$2"
> + shift
> + ;;
> +test_expect_success 'running "git rebase -i --exec git show HEAD"' '
> + git rebase -i --exec "git show HEAD" HEAD~2 >actual &&
> + (
> + FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" &&
> + export FAKE_LINES &&
> + git rebase -i HEAD~2 >expected
> + ) &&
> + sed '1,9d' expected >expect &&
Here and everywhere else: Single quotes do not nest :-) use dquotes (and
-e).
> + mv expect expected &&
Why not
( ... git rebase ... >expect ) &&
sed -e ... expect >expected &&
without the mv?
You could even line up the commands in a pipeline, but since the first
one contains a git command, it is better not to do that because breakage
of the git command would not be detected if it is not the last command
in the pipeline.
> +test_expect_success 'rebase --exec without -i shows error message' '
> + git reset --hard execute &&
> + test_must_fail git rebase --exec "git show HEAD" HEAD~2 2>actual &&
> + echo "--exec option must be used with --interactive option\n" >expected &&
> + test_cmp expected actual
Sooner or later this text will be translated. Therefore:
test_i18ncmp ...
-- Hannes
next prev parent reply other threads:[~2012-06-07 8:40 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-04 13:47 [PATCH] rebase [-i --exec | -ix] <CMD> Kong Lucien
2012-06-04 17:42 ` Junio C Hamano
2012-06-04 20:30 ` Matthieu Moy
2012-06-04 21:06 ` Junio C Hamano
2012-06-05 17:59 ` konglu
2012-06-05 18:13 ` Junio C Hamano
2012-06-04 17:48 ` Matthieu Moy
2012-06-06 10:34 ` [PATCHv2] " Lucien Kong
2012-06-06 20:03 ` Matthieu Moy
2012-06-06 22:54 ` Junio C Hamano
2012-06-07 8:25 ` Zbigniew Jędrzejewski-Szmek
2012-06-07 8:40 ` Johannes Sixt [this message]
2012-06-07 12:04 ` konglu
2012-06-07 13:43 ` Matthieu Moy
2012-06-08 14:53 ` [PATCHv3 1/2] git-rebase.txt: "--onto" option updated Lucien Kong
2012-06-08 14:53 ` [PATCHv3 2/2] rebase [-i --exec | -ix] <CMD> Lucien Kong
2012-06-08 17:02 ` Johannes Sixt
2012-06-08 18:56 ` Torsten Bögershausen
2012-06-08 19:15 ` konglu
2012-06-08 19:55 ` Torsten Bögershausen
2012-06-08 20:07 ` konglu
2012-06-08 20:51 ` Torsten Bögershausen
2012-06-08 21:03 ` konglu
2012-06-09 6:14 ` Torsten Bögershausen
2012-06-09 6:47 ` konglu
2012-06-10 10:44 ` [PATCHv4] " Lucien Kong
2012-06-10 11:56 ` Johannes Sixt
2012-06-11 15:14 ` Junio C Hamano
2012-06-12 18:55 ` Johannes Sixt
2012-06-12 20:29 ` Junio C Hamano
2012-06-12 8:05 ` [PATCHv5] " Lucien Kong
2012-06-12 9:23 ` Zbigniew Jędrzejewski-Szmek
2012-06-12 14:46 ` Junio C Hamano
2012-06-13 14:04 ` Zbigniew Jędrzejewski-Szmek
2012-06-13 17:32 ` Junio C Hamano
2012-06-13 18:05 ` konglu
2012-06-13 18:22 ` Junio C Hamano
2012-06-13 19:38 ` konglu
2012-06-13 20:59 ` Johannes Sixt
2012-06-13 21:07 ` Zbigniew Jędrzejewski-Szmek
2012-06-13 22:25 ` Junio C Hamano
2012-06-13 22:35 ` Junio C Hamano
2012-06-13 22:43 ` Zbigniew Jędrzejewski-Szmek
2012-06-14 6:57 ` Matthieu Moy
2012-06-14 14:08 ` Marc Branchaud
2012-06-08 15:00 ` [PATCHv3 1/2] git-rebase.txt: "--onto" option updated Matthieu Moy
2012-06-08 17:07 ` Junio C Hamano
2012-06-08 19:06 ` konglu
2012-06-08 19:52 ` Junio C Hamano
2012-06-08 20:08 ` konglu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4FD06906.1080007@kdbg.org \
--to=j6t@kdbg.org \
--cc=Franck.Jonas@ensimag.imag.fr \
--cc=Huynh-Khoi-Nguyen.Nguyen@ensimag.imag.fr \
--cc=Lucien.Kong@ensimag.imag.fr \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=Thomas.Nguy@ensimag.imag.fr \
--cc=Valentin.Duperray@ensimag.imag.fr \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.