path: root/builtin/revert.c
AgeCommit message (Collapse)Author
2015-01-14standardize usage info string formatAlex Henrie
This patch puts the usage info strings that were not already in docopt- like format into docopt-like format, which will be a litle easier for end users and a lot easier for translators. Changes include: - Placing angle brackets around fill-in-the-blank parameters - Putting dashes in multiword parameter names - Adding spaces to [-f|--foobar] to make [-f | --foobar] - Replacing <foobar>* with [<foobar>...] Signed-off-by: Alex Henrie <> Reviewed-by: Matthieu Moy <> Signed-off-by: Junio C Hamano <>
2014-03-24parse-options: multi-word argh should use dash to separate wordsJunio C Hamano
"When you need to use space, use dash" is a strange way to say that you must not use a space. Because it is more common for the command line descriptions to use dashed-multi-words, you do not even want to use spaces in these places. Rephrase the documentation to avoid this strangeness. Fix a few existing multi-word argument help strings, i.e. - GPG key-ids given to -S/--gpg-sign are "key-id"; - Refs used for storing notes are "notes-ref"; and - Expiry timestamps given to --expire are "expiry-date". and update the corresponding documentation pages. Signed-off-by: Junio C Hamano <>
2014-01-27cherry-pick, revert: add the --gpg-sign optionNicolas Vigier
Signed-off-by: Nicolas Vigier <> Signed-off-by: brian m. carlson <> Signed-off-by: Junio C Hamano <>
2013-10-23Merge branch 'hu/cherry-pick-previous-branch'Junio C Hamano
"git cherry-pick" without further options would segfault. Could use a follow-up to handle '-' after argv[1] better. * hu/cherry-pick-previous-branch: cherry-pick: handle "-" after parsing options
2013-10-10cherry-pick: handle "-" after parsing optionsJeff King
Currently, we only try converting argv[1] from "-" into "@{-1}". This means we do not notice "-" when used together with an option. Worse, when "git cherry-pick" is run with no options, we segfault. Fix this by doing the substitution after we have checked that there is something in argv to cherry-pick and know any remaining options are meant for the revision-listing machinery. This still does not handle "-" after the first non-cherry-pick option. For example, git cherry-pick foo~2 - bar~5 and git cherry-pick --no-merges - will still dump usage. Reported-by: Stefan Beller <> Signed-off-by: Jeff King <> Signed-off-by: Jonathan Nieder <>
2013-09-20Merge branch 'hu/cherry-pick-previous-branch'Junio C Hamano
Just like "git checkout -" knows to check out and "git merge -" knows to merge the branch you were previously on, "git cherry-pick" now understands "git cherry-pick -" to pick from the previous branch. * hu/cherry-pick-previous-branch: cherry-pick: allow "-" as abbreviation of '@{-1}'
2013-09-09cherry-pick: allow "-" as abbreviation of '@{-1}'Hiroshige Umino
"-" abbreviation is handy for "cherry-pick" like "checkout" and "merge". It's also good for uniformity that a "-" stands as the name of the previous branch where a branch name is accepted and it could not mean any other things like stdin. Signed-off-by: Hiroshige Umino <> Signed-off-by: Junio C Hamano <>
2013-08-07revert: use the OPT_CMDMODE for parsing, reducing codeStefan Beller
The revert command comes with their own implementation of checking for exclusiveness of parameters. Now that the OPT_CMDMODE is in place, we can also rely on that macro instead of cooking that solution for each command itself. This commit also replaces OPT_BOOLEAN, which was deprecated by b04ba2bb (parse-options: deprecate OPT_BOOLEAN, 2011-09-27). Instead OPT_BOOL is used. Signed-off-by: Stefan Beller <> Signed-off-by: Junio C Hamano <>
2013-07-19Add the LAST_ARG_MUST_BE_NULL macroRamsay Jones
The sentinel function attribute is not understood by versions of the gcc compiler prior to v4.0. At present, for earlier versions of gcc, the build issues 108 warnings related to the unknown attribute. In order to suppress the warnings, we conditionally define the LAST_ARG_MUST_BE_NULL macro to provide the sentinel attribute for gcc v4.0 and newer. Signed-off-by: Ramsay Jones <> Signed-off-by: Junio C Hamano <>
2013-07-10use "sentinel" function attribute for variadic listsJeff King
This attribute can help gcc notice when callers forget to add a NULL sentinel to the end of the function. This is our first use of the sentinel attribute, but we shouldn't need to #ifdef for other compilers, as __attribute__ is already a no-op on non-gcc-compatible compilers. Suggested-by: Bert Wesarg <> More-Spots-Found-By: Matt Kraai <> Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
2013-04-24cherry-pick/revert: make usage say '<commit-ish>...'Kevin Bracey
The usage string for cherry-pick and revert has never been updated to reflect their ability to handle multiple commits. Other documentation is already correct. Signed-off-by: Kevin Bracey <> Signed-off-by: Junio C Hamano <>
2012-09-10Merge branch 'mz/cherry-pick-cmdline-order'Junio C Hamano
"git cherry-pick A C B" used to replay changes in A and then B and then C if these three commits had committer timestamps in that order, which is not what the user who said "A C B" naturally expects. * mz/cherry-pick-cmdline-order: cherry-pick/revert: respect order of revisions to pick demonstrate broken 'git cherry-pick three one two' teach log --no-walk=unsorted, which avoids sorting
2012-09-07Merge branch 'nd/i18n-parseopt-help'Junio C Hamano
A lot of i18n mark-up for the help text from "git <cmd> -h". * nd/i18n-parseopt-help: (66 commits) Use imperative form in help usage to describe an action Reduce translations by using same terminologies i18n: write-tree: mark parseopt strings for translation i18n: verify-tag: mark parseopt strings for translation i18n: verify-pack: mark parseopt strings for translation i18n: update-server-info: mark parseopt strings for translation i18n: update-ref: mark parseopt strings for translation i18n: update-index: mark parseopt strings for translation i18n: tag: mark parseopt strings for translation i18n: symbolic-ref: mark parseopt strings for translation i18n: show-ref: mark parseopt strings for translation i18n: show-branch: mark parseopt strings for translation i18n: shortlog: mark parseopt strings for translation i18n: rm: mark parseopt strings for translation i18n: revert, cherry-pick: mark parseopt strings for translation i18n: rev-parse: mark parseopt strings for translation i18n: reset: mark parseopt strings for translation i18n: rerere: mark parseopt strings for translation i18n: status: mark parseopt strings for translation i18n: replace: mark parseopt strings for translation ...
2012-08-30cherry-pick/revert: respect order of revisions to pickMartin von Zweigbergk
When giving multiple individual revisions to cherry-pick or revert, as in 'git cherry-pick A B' or 'git revert B A', one would expect them to be picked/reverted in the order given on the command line. They are instead ordered by their commit timestamp -- in chronological order for "cherry-pick" and in reverse chronological order for "revert". This matches the order in which one would usually give them on the command line, making this bug somewhat hard to notice. Still, it has been reported at least once before [1]. It seems like the chronological sorting happened by accident because the revision walker has traditionally always sorted commits in reverse chronological order when rev_info.no_walk was enabled. In the case of 'git revert B A' where B is newer than A, this sorting is a no-op. For 'git cherry-pick A B', the sorting would reverse the arguments, but because the sequencer also flips the rev_info.reverse flag when picking (as opposed to reverting), the end result is a chronological order. The rev_info.reverse flag was probably flipped so that the revision walker emits B before C in 'git cherry-pick A..C'; that it happened to effectively undo the unexpected sorting done when not walking, was probably a coincidence that allowed this bug to happen at all. Fix the bug by telling the revision walker not to sort the commits when not walking. The only case we want to reverse the order is now when cherry-picking and walking revisions (rev_info.no_walk = 0). [1] Signed-off-by: Martin von Zweigbergk <> Signed-off-by: Junio C Hamano <>
2012-08-30teach log --no-walk=unsorted, which avoids sortingMartin von Zweigbergk
When 'git log' is passed the --no-walk option, no revision walk takes place, naturally. Perhaps somewhat surprisingly, however, the provided revisions still get sorted by commit date. So e.g 'git log --no-walk HEAD HEAD~1' and 'git log --no-walk HEAD~1 HEAD' give the same result (unless the two revisions share the commit date, in which case they will retain the order given on the command line). As the commit that introduced --no-walk (8e64006 (Teach revision machinery about --no-walk, 2007-07-24)) points out, the sorting is intentional, to allow things like git log --abbrev-commit --pretty=oneline --decorate --all --no-walk to show all refs in order by commit date. But there are also other cases where the sorting is not wanted, such as <command producing revisions in order> | git log --oneline --no-walk --stdin To accomodate both cases, leave the decision of whether or not to sort up to the caller, by allowing --no-walk={sorted,unsorted}, defaulting to 'sorted' for backward-compatibility reasons. Signed-off-by: Martin von Zweigbergk <> Signed-off-by: Junio C Hamano <>
2012-08-20i18n: revert, cherry-pick: mark parseopt strings for translationNguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <> Signed-off-by: Junio C Hamano <>
2012-08-06cherry-pick: add --allow-empty-message optionChris Webb
Scripts such as "git rebase -i" cannot currently cherry-pick commits which have an empty commit message, as git cherry-pick calls git commit without the --allow-empty-message option. Add an --allow-empty-message option to git cherry-pick which is passed through to git commit, so this behaviour can be overridden. Signed-off-by: Chris Webb <> Reviewed-by: Neil Horman <> Signed-off-by: Junio C Hamano <>
2012-04-30Merge branch 'nh/empty-rebase'Junio C Hamano
"git rebase" learned to optionally keep commits that do not introduce any change in the original history. By Neil Horman * nh/empty-rebase: git-rebase: add keep_empty flag git-cherry-pick: Add test to validate new options git-cherry-pick: Add keep-redundant-commits option git-cherry-pick: add allow-empty option
2012-04-27Merge branch 'cb/cherry-pick-rev-path-confusion'Junio C Hamano
The command line parser choked "git cherry-pick $name" when $name can be both revision name and a pathname, even though $name can never be a path in the context of the command. The issue the patch addresses is real, but the way it is implemented felt unnecessarily invasive a bit. It may be cleaner for this caller to add the "--" to the end of the argv_array it passes to setup_revisions(). By Clemens Buchacher * cb/cherry-pick-rev-path-confusion: cherry-pick: do not expect file arguments
2012-04-24git-cherry-pick: Add keep-redundant-commits optionNeil Horman
The git-cherry-pick --allow-empty command by default only preserves empty commits that were originally empty, i.e only those commits for which <commit>^{tree} and <commit>^^{tree} are equal. By default commits which are non-empty, but were made empty by the inclusion of a prior commit on the current history are filtered out. This option allows us to override that behavior and include redundant commits as empty commits in the change history. Note that this patch changes the default behavior of git cherry-pick slightly. Prior to this patch all commits in a cherry-pick sequence were applied and git commit was run. The implication here was that, if a commit was redundant, and the commit did not trigger the fast forward logic, the git commit operation, and therefore the git cherry-pick operation would fail, displaying the cherry pick advice (i.e. run git commit --allow-empty). With this patch however, such redundant commits are automatically skipped without stopping, unless --keep-redundant-commits is specified, in which case, they are automatically applied as empty commits. Signed-off-by: Neil Horman <> Signed-off-by: Junio C Hamano <>
2012-04-24Merge branch 'cc/fix-missing-va-end-in-revert'Junio C Hamano
By Christian Couder * cc/fix-missing-va-end-in-revert: revert: add missing va_end
2012-04-22revert: add missing va_endChristian Couder
Signed-off-by: Christian Couder <> Signed-off-by: Junio C Hamano <>
2012-04-15cherry-pick: do not expect file argumentsClemens Buchacher
If a commit-ish passed to cherry-pick or revert happens to have a file of the same name, git complains that the argument is ambiguous and advises to use '--'. To make things worse, the '--' argument is removed by parse_options, und so passing '--' has no effect. Instead, always interpret cherry-pick/revert arguments as revisions. Signed-off-by: Clemens Buchacher <> Signed-off-by: Junio C Hamano <>
2012-04-11git-cherry-pick: add allow-empty optionNeil Horman
git cherry-pick fails when picking a non-ff commit that is empty. The advice given with the failure is that a git-commit --allow-empty should be issued to explicitly add the empty commit during the cherry pick. This option allows a user to specify before hand that they want to keep the empty commit. This eliminates the need to issue both a cherry pick and a commit operation. Signed-off-by: Neil Horman <> Signed-off-by: Junio C Hamano <>
2012-01-12sequencer: factor code out of revert builtinRamkumar Ramachandra
Expose the cherry-picking machinery through a public sequencer_pick_revisions() (renamed from pick_revisions() in builtin/revert.c), so that cherry-picking and reverting are special cases of a general sequencer operation. The cherry-pick builtin is now a thin wrapper that does command-line argument parsing before calling into sequencer_pick_revisions(). In the future, we can write a new "foo" builtin that calls into the sequencer like: memset(&opts, 0, sizeof(opts)); opts.action = REPLAY_FOO; opts.revisions = xmalloc(sizeof(*opts.revs)); parse_args_populate_opts(argc, argv, &opts); init_revisions(opts.revs); sequencer_pick_revisions(&opts); This patch does not intend to make any functional changes. Check with: $ git blame -s -C HEAD^..HEAD -- sequencer.c | grep -C3 '^[^^]' Signed-off-by: Ramkumar Ramachandra <> Reviewed-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
2012-01-12revert: prepare to move replay_action to headerRamkumar Ramachandra
REVERT and CHERRY_PICK and are unsuitable names for an enumerator in a public interface, because they are generic enough to be likely to clash with identifiers with other meanings. Rename to REPLAY_REVERT and REPLAY_PICK as preparation for exposing them. Helped-by: Jonathan Nieder <> Signed-off-by: Ramkumar Ramachandra <> Signed-off-by: Junio C Hamano <>
2011-12-22Merge branch 'rr/revert-cherry-pick'Junio C Hamano
* rr/revert-cherry-pick: t3502, t3510: clarify cherry-pick -m failure t3510 (cherry-pick-sequencer): use exit status revert: simplify getting commit subject in format_todo() revert: tolerate extra spaces, tabs in insn sheet revert: make commit subjects in insn sheet optional revert: free msg in format_todo()
2011-12-20Merge branch 'nd/resolve-ref'Junio C Hamano
* nd/resolve-ref: Rename resolve_ref() to resolve_ref_unsafe() Convert resolve_ref+xstrdup to new resolve_refdup function revert: convert resolve_ref() to read_ref_full()
2011-12-15revert: simplify getting commit subject in format_todo()Ramkumar Ramachandra
format_todo() calls get_message(), but uses only the subject line of the commit message. As a minor optimization, save work and unnecessary memory allocations by using find_commit_subject() instead. Also, remove the unnecessary check on cur->item->buffer: the lookup_commit_reference() call in parse_insn_line() has already made sure of this. Suggested-by: Jonathan Nieder <> Helped-by: Junio C Hamano <> Signed-off-by: Ramkumar Ramachandra <> Signed-off-by: Junio C Hamano <>
2011-12-15revert: tolerate extra spaces, tabs in insn sheetRamkumar Ramachandra
Tolerate extra spaces and tabs as part of the the field separator in '.git/sequencer/todo', for people with fat fingers. Suggested-by: Junio C Hamano <> Signed-off-by: Ramkumar Ramachandra <> Signed-off-by: Junio C Hamano <>
2011-12-15revert: make commit subjects in insn sheet optionalRamkumar Ramachandra
Change the instruction sheet format subtly so that the subject of the commit message that follows the object name is optional. As a result, an instruction sheet like this is now perfectly valid: pick 35b0426 pick fbd5bbcbc2e pick 7362160f While at it, also fix a bug introduced by 5a5d80f4 (revert: Introduce --continue to continue the operation, 2011-08-04) that failed to read lines that are too long to fit on the commit-id-shaped buffer we currently use; eliminate the need for the buffer altogether. In addition to literal SHA-1 hexes, you can now safely use expressions like the following in the instruction sheet: featurebranch~4 rr/revert-cherry-pick-continue^2~12@{12 days ago} [jc: simplify parsing] Suggested-by: Jonathan Nieder <> Helped-by: Junio C Hamano <> Signed-off-by: Ramkumar Ramachandra <> Signed-off-by: Junio C Hamano <>
2011-12-15revert: free msg in format_todo()Ramkumar Ramachandra
Memory allocated to the fields of msg by get_message() isn't freed. This is potentially a big leak, because fresh memory is allocated to store the commit message for each commit. Fix this using free_message(). Reported-by: Jonathan Nieder <> Signed-off-by: Ramkumar Ramachandra <> Signed-off-by: Junio C Hamano <>
2011-12-12revert: stop creating and removing sequencer-old directoryJonathan Nieder
Now that "git reset" no longer implicitly removes .git/sequencer that the operator may or may not have wanted to keep, the logic to write a backup copy of .git/sequencer and remove it when stale is not needed any more. Simplify the sequencer API and repository layout by dropping it. Signed-off-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
2011-12-12revert: do not remove state until sequence is finishedJonathan Nieder
As v1.7.8-rc0~141^2~4 (2011-08-04) explains, git cherry-pick removes the sequencer state just before applying the final patch. In the single-pick case, that was a good thing, since --abort and --continue work fine without access to such state and removing it provides a signal that git should not complain about the need to clobber it ("a cherry-pick or revert is already in progress") in sequences like the following: git cherry-pick foo git read-tree -m -u HEAD; # forget that; let's try a different one git cherry-pick bar After the recent patch "allow single-pick in the middle of cherry-pick sequence" we don't need that hack any more. In the new regime, a traditional "git cherry-pick <commit>" command never looks at .git/sequencer, so we do not need to cripple "git cherry-pick <commit>..<commit>" for it any more. So now you can run "git cherry-pick --abort" near the end of a multi-pick sequence and it will abort the entire sequence, instead of misbehaving and aborting just the final commit. Signed-off-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
2011-12-12revert: allow single-pick in the middle of cherry-pick sequenceJonathan Nieder
After messing up a difficult conflict resolution in the middle of a cherry-pick sequence, it can be useful to be able to git checkout HEAD . && git cherry-pick that-one-commit to restart the conflict resolution. The current code however errors out saying that another cherry-pick is already in progress. Suggested-by: Johannes Sixt <> Signed-off-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
2011-12-12revert: pass around rev-list args in already-parsed formJonathan Nieder
Since 7e2bfd3f (revert: allow cherry-picking more than one commit, 2010-07-02), the pick/revert machinery has kept track of the set of commits to be cherry-picked or reverted using commit_argc and commit_argv variables, storing the corresponding command-line parameters. Future callers as other commands are built in (am, rebase, sequencer) may find it easier to pass rev-list options to this machinery in already-parsed form. Teach cmd_cherry_pick and cmd_revert to parse the rev-list arguments in advance and pass the commit set to pick_revisions() as a rev_info structure. Original patch by Jonathan, tweaks and test from Ram. Signed-off-by: Jonathan Nieder <> Improved-by: Ramkumar Ramachandra <> Signed-off-by: Junio C Hamano <>
2011-12-12revert: allow cherry-pick --continue to commit before resumingJonathan Nieder
When "git cherry-pick" encounters conflicts, permit the operator to use cherry-pick --continue after resolving them as a shortcut for "git commit && git cherry-pick --continue" to record the resolution and carry on with the rest of the sequence. This improves the analogy with "git rebase" (in olden days --continue was the way to preserve authorship when a rebase encountered conflicts) and fits well with a general UI goal of making "git cmd --continue" save humans the trouble of deciding what to do next. Example: after encountering a conflict from running "git cherry-pick foo bar baz": CONFLICT (content): Merge conflict in main.c error: could not apply f78a8d98c... bar! hint: after resolving the conflicts, mark the corrected paths hint: with 'git add <paths>' or 'git rm <paths>' hint: and commit the result with 'git commit' We edit main.c to resolve the conflict, mark it acceptable with "git add main.c", and can run "cherry-pick --continue" to resume the sequence. $ git cherry-pick --continue [editor opens to confirm commit message] [master 78c8a8c98] bar! 1 files changed, 1 insertions(+), 1 deletions(-) [master 87ca8798c] baz! 1 files changed, 1 insertions(+), 1 deletions(-) This is done for both codepaths to pick multiple commits and a single commit. Signed-off-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
2011-12-12revert: give --continue handling its own functionJonathan Nieder
This makes pick_revisions() a little shorter and easier to read straight through. Signed-off-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
2011-12-12revert: convert resolve_ref() to read_ref_full()Nguyễn Thái Ngọc Duy
This is the follow up of c689332 (Convert many resolve_ref() calls to read_ref*() and ref_exists() - 2011-11-13). See the said commit for rationale. Signed-off-by: Nguyễn Thái Ngọc Duy <> Signed-off-by: Junio C Hamano <>
2011-11-23revert --abort: do not leave behind useless sequencer-old directoryJonathan Nieder
The "git cherry-pick --abort" command currently renames the .git/sequencer directory to .git/sequencer-old instead of removing it on success due to an accident. cherry-pick --abort is designed to work in three steps: 1) find which commit to roll back to 2) call "git reset --merge <commit>" to move to that commit 3) remove the .git/sequencer directory But the careless author forgot step 3 entirely. The only reason the command worked anyway is that "git reset --merge <commit>" renames the .git/sequencer directory as a secondary effect --- after moving to <commit>, or so the logic goes, it is unlikely but possible that the caller of git reset wants to continue the series of cherry-picks that was in progress, so git renames the sequencer state to .git/sequencer-old to be helpful while allowing the cherry-pick to be resumed if the caller did not want to end the sequence after all. By running "git cherry-pick --abort", the operator has clearly indicated that she is not planning to continue cherry-picking. Remove the (renamed) .git/sequencer directory as intended all along. Signed-off-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
2011-11-23Fix revert --abort on WindowsJohannes Sixt
On Windows, it is not possible to rename or remove a directory that has open files. 'revert --abort' renamed .git/sequencer when it still had .git/sequencer/head open. Close the file as early as possible to allow the rename operation on Windows. Signed-off-by: Johannes Sixt <> Acked-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
2011-11-23revert: do not pass non-literal string as format to git_path()Nguyễn Thái Ngọc Duy
This fixes the following warning. CC builtin/revert.o builtin/revert.c: In function ‘write_cherry_pick_head’: builtin/revert.c:311: warning: format not a string literal and no format arguments Signed-off-by: Nguyễn Thái Ngọc Duy <> Signed-off-by: Junio C Hamano <>
2011-11-23revert: remove --reset compatibility optionJonathan Nieder
Remove the "git cherry-pick --reset" option, which has a different preferred spelling nowadays ("--quit"). Luckily the old --reset name was not around long enough for anyone to get used to it. Signed-off-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
2011-11-23revert: introduce --abort to cancel a failed cherry-pickJonathan Nieder
After running some ill-advised command like "git cherry-pick HEAD..linux-next", the bewildered novice may want to return to more familiar territory. Introduce a "git cherry-pick --abort" command that rolls back the entire cherry-pick sequence and places the repository back on solid ground. Just like "git merge --abort", this internally uses "git reset --merge", so local changes not involved in the conflict resolution are preserved. Signed-off-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
2011-11-22revert: write REVERT_HEAD pseudoref during conflicted revertJonathan Nieder
When conflicts are encountered while reverting a commit, it can be handy to have the name of that commit easily available. For example, to produce a copy of the patch to refer to while resolving conflicts: $ git revert 2eceb2a8 error: could not revert 2eceb2a8... awesome, buggy feature $ git show -R REVERT_HEAD >the-patch $ edit $(git diff --name-only) Set a REVERT_HEAD pseudoref when "git revert" does not make a commit, for cases like this. This also makes it possible for scripts to distinguish between a revert that encountered conflicts and other sources of an unmerged index. After successfully committing, resetting with "git reset", or moving to another commit with "git checkout" or "git reset", the pseudoref is no longer useful, so remove it. Signed-off-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
2011-11-22revert: improve error message for cherry-pick during cherry-pickJonathan Nieder
In the spirit of v1.6.3.3~3^2 (refuse to merge during a merge, 2009-07-01), "git cherry-pick" refuses to start a new cherry-pick when in the middle of an existing conflicted cherry-pick in the following sequence: 1. git cherry-pick HEAD..origin 2. resolve conflicts 3. git cherry-pick HEAD..origin (instead of "git cherry-pick --continue", by mistake) Good. However, the error message on attempting step 3 is more convoluted than necessary: $ git cherry-pick HEAD..origin error: .git/sequencer already exists. error: A cherry-pick or revert is in progress. hint: Use --continue to continue the operation hint: or --quit to forget about it fatal: cherry-pick failed Clarify by removing the redundant first "error:" message, simplifying the advice, and using lower-case and no full stops to be consistent with other commands that prefix their messages with "error:", so it becomes error: a cherry-pick or revert is already in progress hint: try "git cherry-pick (--continue | --quit)" fatal: cherry-pick failed The "fatal: cherry-pick failed" line seems unnecessary, too, but that can be fixed some other day. Signed-off-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
2011-11-22revert: rearrange pick_revisions() for clarityJonathan Nieder
Deal completely with "cherry-pick --quit" and --continue at the beginning of pick_revisions(), leaving the rest of the function for the more interesting "git cherry-pick <commits>" case. No functional change intended. The impact is just to unindent the code a little. Signed-off-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
2011-11-22revert: rename --reset option to --quitJonathan Nieder
The option to "git cherry-pick" and "git revert" to discard the sequencer state introduced by v1.7.8-rc0~141^2~6 (revert: Introduce --reset to remove sequencer state, 2011-08-04) has a confusing name. Change it now, while we still have the time. The new name for "cherry-pick, please get out of my way, since I've long forgotten about the sequence of commits I was cherry-picking when you wrote that old .git/sequencer directory" is --quit. Mnemonic: this is analagous to quiting a program the user is no longer using --- we just want to get out of the multiple-command cherry-pick procedure and not to reset HEAD or rewind any other old state. The "--reset" option is kept as a synonym to minimize the impact. We might consider dropping it for simplicity in a separate patch, though. Adjust documentation and tests to use the newly preferred name (--quit) instead of --reset. While at it, let's clarify the short descriptions of these operations in "-h" output. Before: --reset forget the current operation --continue continue the current operation After: --quit end revert or cherry-pick sequence --continue resume revert or cherry-pick sequence Noticed-by: Phil Hord <> Signed-off-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
2011-11-17do not let git_path clobber errno when reporting errorsJonathan Nieder
Because git_path() calls vsnprintf(), code like fd = open(git_path("SQUASH_MSG"), O_WRONLY | O_CREAT, 0666); die_errno(_("Could not write to '%s'"), git_path("SQUASH_MSG")); can end up printing an error indicator from vsnprintf() instead of open() by mistake. Store the path we are trying to write to in a temporary variable and pass _that_ to die_errno(), so the messages written by git cherry-pick/revert and git merge can avoid this source of confusion. Signed-off-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
2011-11-16revert: prettify fatal messagesRamkumar Ramachandra
Some of the fatal messages printed by revert and cherry-pick look ugly like the following: fatal: Could not open .git/sequencer/todo.: No such file or directory The culprit here is that these callers of the die_errno() function did not take it into account that the message string they give to it is followed by ": <strerror>", hence the message typically should not end with the full-stop. Signed-off-by: Ramkumar Ramachandra <> Signed-off-by: Junio C Hamano <>