summaryrefslogtreecommitdiff
path: root/git-rebase--interactive.sh
AgeCommit message (Collapse)Author
2010-01-27work around an obnoxious bash "safety feature" on OpenBSDJunio C Hamano
Bash (4.0.24) on OpenBSD 4.6 refuses to run this snippet: $ cat gomi.sh #!/bin/sh one="/var/tmp/1 1" rm -f /var/tmp/1 "/var/tmp/1 1" echo hello >$one $ sh gomi.sh; ls /var/tmp/1* /var/tmp/1 1 $ bash gomi.sh; ls /var/tmp/1* gomi.sh: line 4: $one: ambiguous redirect ls: /var/tmp/1*: No such file or directory Every competent shell programmer knows that a <$word in redirection is not subject to field splitting (POSIX.1 "2.7 Redirection" explicitly lists the kind of expansion performed: "... the word that follows the redirection operator shall be subjected to ...", and "Field Splitting" is not among them). Some clueless folks apparently decided that users need to be protected in the name of "security", however. Output from "git grep -e '> *\$' -- '*.sh'" indicates that rebase-i suffers from this bogus "safety". Work it around by surrounding the variable reference with a dq pair. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-26fix portability issues with $ in double quotesStephen Boyd
Using a dollar sign in double quotes isn't portable. Escape them with a backslash or replace the double quotes with single quotes. Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-24rebase -i: Export GIT_AUTHOR_* variables explicitlyJunio C Hamano
There is no point doing self-assignments of these variables. Instead, just export them to the environment, but do so in a sub-shell, because VAR1=VAL1 VAR2=VAL2 ... command arg1 arg2... does not mark the variables exported if command that is run is a shell function, according to POSIX.1. The callers of do_with_author do not rely on seeing the effect of any shell variable assignments that may happen inside what was called through this shell function (currently "output" is the only one), so running it in the subshell doesn't have an adverse semantic effect. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-22rebase -i: Avoid non-portable "test X -a Y"Michael Haggerty
Reported by: Eric Blake <ebb9@byu.net> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-20Merge branch 'mh/rebase-fixup'Junio C Hamano
* mh/rebase-fixup: rebase -i: Retain user-edited commit messages after squash/fixup conflicts t3404: Set up more of the test repo in the "setup" step rebase -i: For fixup commands without squashes, do not start editor rebase -i: Change function make_squash_message into update_squash_message rebase -i: Extract function do_with_author rebase -i: Handle the author script all in one place in do_next rebase -i: Extract a function "commit_message" rebase -i: Simplify commit counting for generated commit messages rebase -i: Improve consistency of commit count in generated commit messages t3404: Test the commit count in commit messages generated by "rebase -i" rebase -i: Introduce a constant AMEND rebase -i: Introduce a constant AUTHOR_SCRIPT rebase -i: Document how temporary files are used rebase -i: Use symbolic constant $MSG consistently rebase -i: Use "test -n" instead of "test ! -z" rebase -i: Inline expression rebase -i: Remove dead code rebase -i: Make the condition for an "if" more transparent
2010-01-20Merge branch 'ns/rebase-auto-squash'Junio C Hamano
* ns/rebase-auto-squash: rebase -i --autosquash: auto-squash commits Conflicts: git-rebase--interactive.sh
2010-01-20Merge branch 'mh/rebase-fixup' (early part)Junio C Hamano
* 'mh/rebase-fixup' (early part): rebase-i: Ignore comments and blank lines in peek_next_command lib-rebase: Allow comments and blank lines to be added to the rebase script lib-rebase: Provide clearer debugging info about what the editor did Add a command "fixup" to rebase --interactive t3404: Use test_commit to set up test repository
2010-01-14rebase -i: Retain user-edited commit messages after squash/fixup conflictsMichael Haggerty
When a squash/fixup fails due to a conflict, the user is required to edit the commit message. Previously, if further squash/fixup commands followed the conflicting squash/fixup, this user-edited message was discarded and a new automatically-generated commit message was suggested. Change the handling of conflicts within squash/fixup command series: Whenever the user is required to intervene, consider the resulting commit to be a new basis for the following squash/fixups and use its commit message in later suggested combined commit messages. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-14rebase -i: For fixup commands without squashes, do not start editorMichael Haggerty
If the "rebase -i" commands include a series of fixup commands without any squash commands, then commit the combined commit using the commit message of the corresponding "pick" without starting up the commit-message editor. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-14rebase -i: Change function make_squash_message into update_squash_messageMichael Haggerty
Alter the file $SQUASH_MSG in place rather than outputting the new message then juggling it around. Change the function name accordingly. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-14rebase -i: Extract function do_with_authorMichael Haggerty
Call it instead of repeating similar code blocks in several places. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-14rebase -i: Handle the author script all in one place in do_nextMichael Haggerty
This change has no practical effect but makes the code easier to follow. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-14rebase -i: Extract a function "commit_message"Michael Haggerty
...instead of repeating the same short but slightly obscure blob of code in several places. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-14rebase -i: Simplify commit counting for generated commit messagesMichael Haggerty
Read the old count from the first line of the old commit message rather than counting the number of commit message blocks in the file. This is simpler, faster, and more robust (e.g., it cannot be confused by strange commit message contents). Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-14rebase -i: Improve consistency of commit count in generated commit messagesMichael Haggerty
Use the numeral "2" instead of the word "two" when two commits are being interactively squashed. This makes the treatment consistent with that for higher numbers of commits. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-14rebase -i: Introduce a constant AMENDMichael Haggerty
Add a constant AMEND holding the filename of the $DOTEST/amend file, and document how this temporary file is used. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-14rebase -i: Introduce a constant AUTHOR_SCRIPTMichael Haggerty
Add a constant AUTHOR_SCRIPT, holding the filename of the $DOTEST/author_script file, and document how this temporary file is used. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-14rebase -i: Document how temporary files are usedMichael Haggerty
Add documentation, inferred by reverse-engineering, about how git-rebase--interactive.sh uses many of its temporary files. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-14rebase -i: Use symbolic constant $MSG consistentlyMichael Haggerty
The filename constant $MSG was previously used in some places and written out literally in others. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-14rebase -i: Use "test -n" instead of "test ! -z"Michael Haggerty
It is a tiny bit simpler. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-14rebase -i: Inline expressionMichael Haggerty
Inline expression when generating output rather than overwriting the "sha1" local variable with a short SHA1. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-14rebase -i: Remove dead codeMichael Haggerty
This branch of the "if" is only executed if $no_ff is empty, which only happens if $1 was not '-n'. (This code has been dead since 1d25c8cf82eead72e11287d574ef72d3ebec0db1.) Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-14rebase -i: Make the condition for an "if" more transparentMichael Haggerty
Test $no_ff separately rather than testing it indirectly by gluing it onto a comparison of two SHA1s. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-13Merge branch 'jc/checkout-merge-base'Junio C Hamano
* jc/checkout-merge-base: rebase -i: teach --onto A...B syntax rebase: fix --onto A...B parsing and add tests "rebase --onto A...B" replays history on the merge base between A and B "checkout A...B" switches to the merge base between A and B
2010-01-12rebase-i: Ignore comments and blank lines in peek_next_commandMichael Haggerty
Previously, blank lines and/or comments within a series of squash/fixup commands would confuse "git rebase -i" into thinking that the series was finished. It would therefore require the user to edit the commit message for the squash/fixup commits seen so far. Then, after continuing, it would ask the user to edit the commit message again. Ignore comments and blank lines within a group of squash/fixup commands, allowing them to be processed in one go. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-12rebase--interactive: Ignore comments and blank lines in peek_next_commandMichael Haggerty
Previously, blank lines and/or comments within a series of squash/fixup commands would confuse "git rebase -i" into thinking that the series was finished. It would therefore require the user to edit the commit message for the squash/fixup commits seen so far. Then, after continuing, it would ask the user to edit the commit message again. Ignore comments and blank lines within a group of squash/fixup commands, allowing them to be processed in one go. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-07rebase -i: teach --onto A...B syntaxNanako Shiraishi
When rewriting commits on a topic branch, sometimes it is easier to compare the version of commits before and after the rewrite if they are based on the same commit that forked from the upstream. An earlier commit by Junio (fixed up by the previous commit) gives "--onto A...B" syntax to rebase command, and rebases on top of the merge base between A and B; teach the same to the interactive version, too. Signed-off-by: しらいし ななこ <nanako3@lavabit.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-07rebase -i --autosquash: auto-squash commitsNanako Shiraishi
Teach a new option, --autosquash, to the interactive rebase. When the commit log message begins with "!fixup ...", and there is a commit whose title begins with the same ..., automatically modify the todo list of rebase -i so that the commit marked for squashing come right after the commit to be modified, and change the action of the moved commit from pick to squash. Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-20Merge branch 'maint'Junio C Hamano
* maint: rebase -i: abort cleanly if the editor fails to launch technical-docs: document hash API api-strbuf.txt: fix typos and document launch_editor()
2009-12-20rebase -i: abort cleanly if the editor fails to launchBjörn Gustavsson
If the user's configured editor is emacsclient, the editor will fail to launch if emacs is not running and the git command that tried to lanuch the editor will abort. For most commands, all you have to do is to start emacs and repeat the command. The "git rebase -i" command, however, aborts without cleaning the "$GIT_DIR/rebase-merge" directory if it fails to launch the editor, so you'll need to do "git rebase --abort" before repeating the rebase command. Change "git rebase -i" to terminate using "die_abort" (instead of with "die") if the initial launch of the editor fails. Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-07Add a command "fixup" to rebase --interactiveMichael Haggerty
The command is like "squash", except that it discards the commit message of the corresponding commit. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-03Merge branch 'rs/work-around-grep-opt-insanity' into maintJunio C Hamano
* rs/work-around-grep-opt-insanity: Protect scripted Porcelains from GREP_OPTIONS insanity mergetool--lib: simplify guess_merge_tool()
2009-11-25Merge branch 'rs/work-around-grep-opt-insanity'Junio C Hamano
* rs/work-around-grep-opt-insanity: Protect scripted Porcelains from GREP_OPTIONS insanity mergetool--lib: simplify guess_merge_tool() Conflicts: git-instaweb.sh
2009-11-24Protect scripted Porcelains from GREP_OPTIONS insanityJunio C Hamano
If the user has exported the GREP_OPTIONS environment variable, the output from "grep" and "egrep" in scripted Porcelains may be different from what they expect. For example, we may want to count number of matching lines, by "grep" piped to "wc -l", and GREP_OPTIONS=-C3 will break such use. The approach taken by this change to address this issue is to protect only our own use of grep/egrep. Because we do not unset it at the beginning of our scripts, hook scripts run from the scripted Porcelains are exposed to the same insanity this environment variable causes when grep/egrep is used to implement logic (e.g. "grep | wc -l"), and it is entirely up to the hook scripts to protect themselves. On the other hand, applypatch-msg hook may want to show offending words in the proposed commit log message using grep to the end user, and the user might want to set GREP_OPTIONS=--color to paint the match more visibly. The approach to protect only our own use without unsetting the environment variable globally will allow this use case. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-16Merge branch 'fc/doc-fast-forward'Junio C Hamano
* fc/doc-fast-forward: Use 'fast-forward' all over the place Conflicts: builtin-merge.c
2009-10-28Merge branch 'maint'Junio C Hamano
* maint: help -a: do not unnecessarily look for a repository Do not try to remove directories when removing old links rebase -i: more graceful handling of invalid commands help -i: properly error out if no info viewer can be found
2009-10-28rebase -i: more graceful handling of invalid commandsJan Krüger
Currently, when there is an invalid command, the rest of the line is still treated as if the command had been valid, i.e. rebase -i attempts to produce a patch, using the next argument as a SHA1 name. If there is no next argument or an invalid one, very confusing error messages appear (the line was '.'; path to git-rebase-todo substituted): Unknown command: . fatal: ambiguous argument 'Please fix this in the file $somefile.': unknown revision or path not in the working tree. Use '--' to separate paths from revisions fatal: Not a valid object name Please fix this in the file $somefile. fatal: bad revision 'Please fix this in the file $somefile.' Instead, verify the validity of the remaining line and error out earlier if necessary. Signed-off-by: Jan Krüger <jk@jk.gs> Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-25Use 'fast-forward' all over the placeFelipe Contreras
It's a compound word. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-19rebase -i: fix reword when using a terminal editorStephen Boyd
We don't want to use output() on git-commit --amend when rewording the commit message. This leads to confusion as the editor is run in a subshell with it's output saved away, leaving the user with a seemingly frozen terminal. Fix by removing the output part. Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-08Teach 'rebase -i' the command "reword"Björn Gustavsson
Make it easier to edit just the commit message for a commit using 'git rebase -i' by introducing the "reword" command. Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-07-22Fix rebase -p --ontoGreg Price
In a rebase with --onto, the correct test for whether we can skip rewriting a commit is if it is already on top of $ONTO, not $UPSTREAM. Without --onto, this distinction does not exist and the behavior does not change. In a situation with two merged branches on a common base X: X---o---o---o---M \ / x---x---x---x Y if we try to move the branches from their base on X to be based on Y, so as to get X Y---o'--o'--o'--M' \ / x'--x'--x'--x' then we fail. The command `git rebase -p --onto Y X M` moves only the first-parent chain, like so: X \ x---x---x---x \ Y---o'--o'--o'--M' because it mistakenly drops the other branch(es) x---x---x---x from the TODO file. This tests and fixes this behavior. Signed-off-by: Greg Price <price@ksplice.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-06-11Merge branch 'uk/maint-1.5.3-rebase-i-reflog' into maintJunio C Hamano
* uk/maint-1.5.3-rebase-i-reflog: rebase--interactive: remote stray closing parenthesis Conflicts: git-rebase--interactive.sh
2009-06-11rebase--interactive: remote stray closing parenthesisUwe Kleine-König
it was introduced in 68a163c9b483ae352fcfee8c4505d113213daa73 Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Cc: Jöhännës "Dschö" Schindëlin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-03-03rebase -i: avoid 'git reset' when possibleJohannes Schindelin
When picking commits whose parents have not changed, we do not need to rewrite the commit. We do not need to reset the working directory to the parent's state, either. Requested by Sverre Rabbelier. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-02-01Merge branch 'js/maint-rebase-i-submodule'Junio C Hamano
* js/maint-rebase-i-submodule: Fix submodule squashing into unrelated commit rebase -i squashes submodule changes into unrelated commit
2009-01-28Fix submodule squashing into unrelated commitJohannes Schindelin
Actually, I think the issue is pretty independent of submodules; when "git commit" gets an empty parameter, it misinterprets it as a file. So avoid passing an empty parameter to "git commit". Actually, this is a nice cleanup, as MSG_FILE and EDIT_COMMIT were mutually exclusive; use one variable instead Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-27rebase -i: correctly remember --root flag across --continueJunio C Hamano
d911d14 (rebase -i: learn to rebase root commit, 2009-01-02) tried to remember the --root flag across a merge conflict in a broken way. Introduce a flag file $DOTEST/rebase-root to fix and clarify. While at it, also make sure $UPSTREAM is always initialized to guard against existing values in the environment. [tr: added tests] Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-26rebase -i --root: fix check for number of argumentsJohannes Schindelin
If we are not rebasing with --root, then $# can only be either 1 (base) or 2 (base and the name of the branch to be rebased). If we are rebasing with --root, then it is Ok if $# is 0 (rebase the current branch down to everything) or 1 (rebase the named branch down to everything). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Acked-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-18Merge branch 'tr/rebase-root'Junio C Hamano
* tr/rebase-root: rebase: update documentation for --root rebase -i: learn to rebase root commit rebase: learn to rebase root commit rebase -i: execute hook only after argument checking
2009-01-13Merge branch 'maint-1.6.0' into maintJunio C Hamano
* maint-1.6.0: Avoid spurious error messages on error mistakes. contrib/examples/README: give an explanation of the status of these files