summaryrefslogtreecommitdiff
path: root/builtin/rebase.c
AgeCommit message (Collapse)AuthorFilesLines
2019-02-06Merge branch 'nd/the-index-final'Libravatar Junio C Hamano1-7/+7
The assumption to work on the single "in-core index" instance has been reduced from the library-ish part of the codebase. * nd/the-index-final: cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch read-cache.c: remove the_* from index_has_changes() merge-recursive.c: remove implicit dependency on the_repository merge-recursive.c: remove implicit dependency on the_index sha1-name.c: remove implicit dependency on the_index read-cache.c: replace update_index_if_able with repo_& read-cache.c: kill read_index() checkout: avoid the_index when possible repository.c: replace hold_locked_index() with repo_hold_locked_index() notes-utils.c: remove the_repository references grep: use grep_opt->repo instead of explict repo argument
2019-02-06Merge branch 'js/rebase-am'Libravatar Junio C Hamano1-125/+311
Instead of going through "git-rebase--am" scriptlet to use the "am" backend, the built-in version of "git rebase" learned to drive the "am" backend directly. * js/rebase-am: built-in rebase: call `git am` directly rebase: teach `reset_head()` to optionally skip the worktree rebase: avoid double reflog entry when switching branches rebase: move `reset_head()` into a better spot
2019-02-06Merge branch 'en/rebase-merge-on-sequencer'Libravatar Junio C Hamano1-20/+10
"git rebase --merge" as been reimplemented by reusing the internal machinery used for "git rebase -i". * en/rebase-merge-on-sequencer: rebase: implement --merge via the interactive machinery rebase: define linearization ordering and enforce it git-legacy-rebase: simplify unnecessary triply-nested if git-rebase, sequencer: extend --quiet option for the interactive machinery am, rebase--merge: do not overlook --skip'ed commits with post-rewrite t5407: add a test demonstrating how interactive handles --skip differently rebase: fix incompatible options error message rebase: make builtin and legacy script error messages the same
2019-02-05Merge branch 'pw/no-editor-in-rebase-i-implicit'Libravatar Junio C Hamano1-2/+3
When GIT_SEQUENCE_EDITOR is set, the command was incorrectly started when modes of "git rebase" that implicitly uses the machinery for the interactive rebase are run, which has been corrected. * pw/no-editor-in-rebase-i-implicit: implicit interactive rebase: don't run sequence editor
2019-01-29Merge branch 'os/rebase-runs-post-checkout-hook'Libravatar Junio C Hamano1-2/+10
"git rebase" internally runs "checkout" to switch between branches, and the command used to call the post-checkout hook, but the reimplementation stopped doing so, which is getting fixed. * os/rebase-runs-post-checkout-hook: rebase: run post-checkout hook on checkout t5403: simplify by using a single repository
2019-01-29Merge branch 'js/rebase-i-redo-exec'Libravatar Junio C Hamano1-1/+41
"git rebase -i" learned to re-execute a command given with 'exec' to run after it failed the last time. * js/rebase-i-redo-exec: rebase: introduce a shortcut for --reschedule-failed-exec rebase: add a config option to default to --reschedule-failed-exec rebase: introduce --reschedule-failed-exec
2019-01-28implicit interactive rebase: don't run sequence editorLibravatar Phillip Wood1-2/+3
If GIT_SEQUENCE_EDITOR is set then rebase runs it when executing implicit interactive rebases which are supposed to appear non-interactive to the user. Fix this by setting GIT_SEQUENCE_EDITOR=: rather than GIT_EDITOR=:. A couple of tests relied on the old behavior so they are updated to work with the new regime. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-01-24cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switchLibravatar Nguyễn Thái Ngọc Duy1-0/+1
By default, index compat macros are off from now on, because they could hide the_index dependency. Only those in builtin can use it. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-01-18built-in rebase: call `git am` directlyLibravatar Johannes Schindelin1-0/+179
While the scripted `git rebase` still has to rely on the `git-rebase--am.sh` script to implement the glue between the `rebase` and the `am` commands, we can go a more direct route in the built-in rebase and avoid using a shell script altogether. This patch represents a straight-forward port of `git-rebase--am.sh` to C, along with the glue code to call it directly from within `builtin/rebase.c`. This reduces the chances of Git for Windows running into trouble due to problems with the POSIX emulation layer (known as "MSYS2 runtime", itself a derivative of the Cygwin runtime): when no shell script is called, the POSIX emulation layer is avoided altogether. Note: we pass an empty action to `reset_head()` here when moving back to the original branch, as no other action is applicable, really. This parameter is used to initialize `unpack_trees()`' messages. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-01-18rebase: teach `reset_head()` to optionally skip the worktreeLibravatar Johannes Schindelin1-1/+7
This is what the legacy (scripted) rebase does in `move_to_original_branch`, and we will need this functionality in the next commit. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-01-18rebase: avoid double reflog entry when switching branchesLibravatar Johannes Schindelin1-3/+4
When switching a branch *and* updating said branch to a different revision, let's avoid a double entry in HEAD's reflog by first updating the branch and then adjusting the symbolic ref HEAD. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-01-18rebase: move `reset_head()` into a better spotLibravatar Johannes Schindelin1-119/+119
Over the next commits, we want to make use of it in `run_am()` (i.e. running the `--am` backend directly, without detouring to Unix shell script code) which in turn will be called from `run_specific_rebase()`. So let's move it before that latter function. This commit is best viewed using --color-moved. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-01-14read-cache.c: replace update_index_if_able with repo_&Libravatar Nguyễn Thái Ngọc Duy1-3/+2
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-01-14read-cache.c: kill read_index()Libravatar Nguyễn Thái Ngọc Duy1-4/+4
read_index() shares the same problem as hold_locked_index(): it assumes $GIT_DIR/index. Move all call sites to repo_read_index() instead. read_index_preload() and read_index_unmerged() are also killed as a consequence. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-01-07rebase: implement --merge via the interactive machineryLibravatar Elijah Newren1-9/+6
As part of an ongoing effort to make rebase have more uniform behavior, modify the merge backend to behave like the interactive one, by re-implementing it on top of the latter. Interactive rebases are implemented in terms of cherry-pick rather than the merge-recursive builtin, but cherry-pick also calls into the recursive merge machinery by default and can accept special merge strategies and/or special strategy options. As such, there really is not any need for having both git-rebase--merge and git-rebase--interactive anymore. Delete git-rebase--merge.sh and instead implement it in builtin/rebase.c. This results in a few deliberate but small user-visible changes: * The progress output is modified (see t3406 and t3420 for examples) * A few known test failures are now fixed (see t3421) * bash-prompt during a rebase --merge is now REBASE-i instead of REBASE-m. Reason: The prompt is a reflection of the backend in use; this allows users to report an issue to the git mailing list with the appropriate backend information, and allows advanced users to know where to search for relevant control files. (see t9903) testcase modification notes: t3406: --interactive and --merge had slightly different progress output while running; adjust a test to match the new expectation t3420: these test precise output while running, but rebase--am, rebase--merge, and rebase--interactive all were built on very different commands (am, merge-recursive, cherry-pick), so the tests expected different output for each type. Now we expect --merge and --interactive to have the same output. t3421: --interactive fixes some bugs in --merge! Wahoo! t9903: --merge uses the interactive backend so the prompt expected is now REBASE-i. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-01-04Merge branch 'nd/the-index'Libravatar Junio C Hamano1-8/+9
More codepaths become aware of working with in-core repository instance other than the default "the_repository". * nd/the-index: (22 commits) rebase-interactive.c: remove the_repository references rerere.c: remove the_repository references pack-*.c: remove the_repository references pack-check.c: remove the_repository references notes-cache.c: remove the_repository references line-log.c: remove the_repository reference diff-lib.c: remove the_repository references delta-islands.c: remove the_repository references cache-tree.c: remove the_repository references bundle.c: remove the_repository references branch.c: remove the_repository reference bisect.c: remove the_repository reference blame.c: remove implicit dependency the_repository sequencer.c: remove implicit dependency on the_repository sequencer.c: remove implicit dependency on the_index transport.c: remove implicit dependency on the_index notes-merge.c: remove implicit dependency the_repository notes-merge.c: remove implicit dependency on the_index list-objects.c: reduce the_repository references list-objects-filter.c: remove implicit dependency on the_index ...
2019-01-02rebase: run post-checkout hook on checkoutLibravatar Orgad Shaneh1-2/+10
The scripted version of rebase used to run this hook on the initial checkout. The transition to built-in introduced a regression. Signed-off-by: Orgad Shaneh <orgads@gmail.com> Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-12-28git-rebase, sequencer: extend --quiet option for the interactive machineryLibravatar Elijah Newren1-4/+1
While 'quiet' and 'interactive' may sound like antonyms, the interactive machinery actually has logic that implements several interactive_rebase=implied cases (--exec, --keep-empty, --rebase-merges) which won't pop up an editor. The rewrite of interactive rebase in C added a quiet option, though it only turns stats off. Since we want to make the interactive machinery also take over for git-rebase--merge, it should fully implement the --quiet option. git-rebase--interactive was already somewhat quieter than git-rebase--merge and git-rebase--am, possibly because cherry-pick has just traditionally been quieter. As such, we only drop a few informational messages -- "Rebasing (n/m)" and "Successfully rebased..." Also, for simplicity, remove the differences in how quiet and verbose options were recorded. Having one be signalled by the presence of a "verbose" file in the state_dir, while the other was signalled by the contents of a "quiet" file was just weirdly inconsistent. (This inconsistency pre-dated the rewrite into C.) Make them consistent by having them both key off the presence of the file. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-12-28rebase: fix incompatible options error messageLibravatar Elijah Newren1-7/+3
In commit f57696802c30 ("rebase: really just passthru the `git am` options", 2018-11-14), the handling of `git am` options was simplified dramatically (and an option parsing bug was fixed), but it introduced a small regression in the error message shown when options only understood by separate backends were used: $ git rebase --keep --ignore-whitespace fatal: cannot combine interactive options (--interactive, --exec, --rebase-merges, --preserve-merges, --keep-empty, --root + --onto) with am options (.git/rebase-apply/applying) $ git rebase --merge --ignore-whitespace fatal: cannot combine merge options (--merge, --strategy, --strategy-option) with am options (.git/rebase-apply/applying) Note that in both cases, the list of "am options" is ".git/rebase-apply/applying", which makes no sense. Since the lists of backend-specific options is documented pretty thoroughly in the rebase man page (in the "Incompatible Options" section, with multiple links throughout the document), and since I expect this list to change over time, just simplify the error message. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-12-28rebase: make builtin and legacy script error messages the sameLibravatar Elijah Newren1-5/+5
The conversion of the script version of rebase took messages that were prefixed with "error:" and passed them along to die(), which adds a "fatal:" prefix, thus resulting in messages of the form: fatal: error: cannot combine... which seems redundant. Remove the "error:" prefix from the builtin version of rebase, and change the prefix from "error:" to "fatal:" in the legacy script to match. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-12-11rebase: introduce a shortcut for --reschedule-failed-execLibravatar Johannes Schindelin1-0/+21
It is a bit cumbersome to write out the `--reschedule-failed-exec` option before `-x <cmd>` all the time; let's introduce a convenient option to do both at the same time: `-y <cmd>`. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-12-11rebase: add a config option to default to --reschedule-failed-execLibravatar Johannes Schindelin1-0/+5
It would be cumbersome to type out that option all the time, so let's offer the convenience of a config setting: rebase.rescheduleFailedExec. Besides, this opens the door to changing the default in a future version of Git: it does make some sense to reschedule failed `exec` commands by default (and if we could go back in time when the `exec` command was invented, we probably would change that default right from the start). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-12-11rebase: introduce --reschedule-failed-execLibravatar Johannes Schindelin1-1/+15
A common use case for the `--exec` option is to verify that each commit in a topic branch compiles cleanly, via `git rebase -x make <base>`. However, when an `exec` in such a rebase fails, it is not re-scheduled, which in this instance is not particularly helpful. Let's offer a flag to reschedule failed `exec` commands. Based on an idea by Paul Morelle. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-12-01Merge branch 'rt/rebase-in-c-message-fix'Libravatar Junio C Hamano1-2/+2
* rt/rebase-in-c-message-fix: builtin/rebase.c: remove superfluous space in messages
2018-12-01Merge branch 'js/rebase-stat-unrelated-fix'Libravatar Junio C Hamano1-6/+12
"git rebase --stat" to transplant a piece of history onto a totally unrelated history were not working before and silently showed wrong result. With the recent reimplementation in C, it started to instead die with an error message, as the original logic was not prepared to cope with this case. This has now been fixed. * js/rebase-stat-unrelated-fix: rebase --stat: fix when rebasing to an unrelated history
2018-12-01builtin/rebase.c: remove superfluous space in messagesLibravatar Ralf Thielow1-2/+2
The whitespace breakages in these messages were introduced while reimplementing the subcommand in C. Match these messages to those in the original scripted version. Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com> Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-11-30rebase --stat: fix when rebasing to an unrelated historyLibravatar Johannes Schindelin1-6/+12
When rebasing to a commit history that has no common commits with the current branch, there is no merge base. In diffstat mode, this means that we cannot compare to the merge base, but we have to compare to the empty tree instead. Also, if running in verbose diffstat mode, we should not output Changes from <merge-base> to <onto> as that does not make sense without any merge base. Note: neither scripted nor built-in versoin of `git rebase` were prepared for this situation well. We use this opportunity not only to fix the bug(s), but also to make both versions' output consistent in this instance. And add a regression test to keep this working in all eternity. Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-11-30rebase: fix GIT_REFLOG_ACTION regressionLibravatar Johannes Schindelin1-3/+26
The scripted version of "rebase" honored the `GIT_REFLOG_ACTION`, and some automation scripts expected the reflog entries to be prefixed with "rebase -i", not "rebase", after running "rebase -i". This regressed in the reimplementation in C. Fix that, and add a regression test, both with `GIT_REFLOG_ACTION` set and unset. Note: the reflog message for "rebase finished" did *not* honor GIT_REFLOG_ACTION, and as we are very late in the v2.20.0-rcN phase, we leave that bug for later (as it seems that that bug has been with us from the very beginning). Reported by Ian Jackson. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-11-21Merge branch 'js/builtin-rebase-perf-fix-err-fix'Libravatar Junio C Hamano1-1/+2
The object name of the tree reported in a recently added error message was wrong, which has been corrected. * js/builtin-rebase-perf-fix-err-fix: rebase: warn about the correct tree's OID
2018-11-21rebase: warn about the correct tree's OIDLibravatar Johannes Schindelin1-1/+2
This was a simple copy/paste error, and an obvious one at that: if we cannot fill the tree descriptor, we should show an error message about *that* tree, not another one. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-11-18Merge branch 'ab/rebase-in-c-escape-hatch'Libravatar Junio C Hamano1-1/+4
The recently merged "rebase in C" has an escape hatch to use the scripted version when necessary, but it hasn't been documented, which has been corrected. * ab/rebase-in-c-escape-hatch: tests: add a special setup where rebase.useBuiltin is off rebase doc: document rebase.useBuiltin
2018-11-18Merge branch 'js/rebase-am-options'Libravatar Junio C Hamano1-63/+45
The way "git rebase" parses and forwards the command line options meant for underlying "git am" has been revamped, which fixed for options with parameters that were not passed correctly. * js/rebase-am-options: rebase: validate -C<n> and --whitespace=<mode> parameters early rebase: really just passthru the `git am` options
2018-11-18Merge branch 'js/rebase-r-and-merge-head'Libravatar Junio C Hamano1-0/+3
Bugfix for the recently graduated "git rebase --rebase-merges". * js/rebase-r-and-merge-head: status: rebase and merge can be in progress at the same time built-in rebase --skip/--abort: clean up stale .git/<name> files rebase -i: include MERGE_HEAD into files to clean up rebase -r: do not write MERGE_HEAD unless needed rebase -r: demonstrate bug with conflicting merges
2018-11-18Merge branch 'js/builtin-rebase-perf-fix'Libravatar Junio C Hamano1-33/+46
Code clean-up with correction to make the reimplemented "git rebase" a more faithful rewrite of the original, which also regains performance. * js/builtin-rebase-perf-fix: built-in rebase: reinstate `checkout -q` behavior where appropriate rebase: prepare reset_head() for more flags rebase: consolidate clean-up code before leaving reset_head()
2018-11-18Merge branch 'js/rebase-autostash-detach-fix'Libravatar Junio C Hamano1-1/+2
"git rebase --autostash" did not correctly re-attach the HEAD at times. * js/rebase-autostash-detach-fix: built-in rebase --autostash: leave the current branch alone if possible built-in rebase: demonstrate regression with --autostash
2018-11-16tests: add a special setup where rebase.useBuiltin is offLibravatar Ævar Arnfjörð Bjarmason1-1/+4
Add a GIT_TEST_REBASE_USE_BUILTIN=false test mode which is equivalent to running with rebase.useBuiltin=false. This is needed to spot that we're not introducing any regressions in the legacy rebase version while we're carrying both it and the new builtin version. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-11-16rebase: validate -C<n> and --whitespace=<mode> parameters earlyLibravatar Johannes Schindelin1-1/+11
It is a good idea to error out early upon seeing, say, `-Cbad`, rather than starting the rebase only to have the `--am` backend complain later. Let's do this. The only options accepting parameters which we pass through to `git am` (which may, or may not, forward them to `git apply`) are `-C` and `--whitespace`. The other options we pass through do not accept parameters, so we do not have to validate them here. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-11-16rebase: really just passthru the `git am` optionsLibravatar Johannes Schindelin1-63/+35
Currently, we parse the options intended for `git am` as if we wanted to handle them in `git rebase`, and then reconstruct them painstakingly to define the `git_am_opt` variable. However, there is a much better way (that I was unaware of, at the time when I mentored Pratik to implement these options): OPT_PASSTHRU_ARGV. It is intended for exactly this use case, where command-line options want to be parsed into a separate `argv_array`. Let's use this feature. Incidentally, this also allows us to address a bug discovered by Phillip Wood, where the built-in rebase failed to understand that the `-C` option takes an optional argument. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-11-13built-in rebase: reinstate `checkout -q` behavior where appropriateLibravatar Johannes Schindelin1-15/+25
When we converted a `git checkout -q $onto^0` call to use `reset_head()`, we inadvertently incurred a change from a twoway_merge to a oneway_merge, as if we wanted a `git reset --hard` instead. This has performance ramifications under certain, though, as the oneway_merge needs to lstat() every single index entry whereas twoway_merge does not. So let's go back to the old behavior. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-11-13rebase: prepare reset_head() for more flagsLibravatar Johannes Schindelin1-3/+6
Currently, we only accept the flag indicating whether the HEAD should be detached not. In the next commit, we want to introduce another flag: to toggle between emulating `reset --hard` vs `checkout -q`. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-11-13rebase: consolidate clean-up code before leaving reset_head()Libravatar Johannes Schindelin1-18/+18
The same clean-up code is repeated quite a few times; Let's DRY up the code some. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-11-13built-in rebase --skip/--abort: clean up stale .git/<name> filesLibravatar Johannes Schindelin1-0/+3
The scripted version of the rebase used to execute `git reset --hard` when skipping or aborting. When we ported this to C, we did update the worktree and some reflogs, but we failed to imitate `git reset --hard`'s behavior regarding files in .git/ such as MERGE_HEAD. Let's address this oversight. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-11-12rerere.c: remove the_repository referencesLibravatar Nguyễn Thái Ngọc Duy1-2/+2
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-11-12cache-tree.c: remove the_repository referencesLibravatar Nguyễn Thái Ngọc Duy1-1/+1
This case is more interesting than other boring "remove the_repo" commits because while we need access to the object database, we cannot simply use r->index because unpack-trees.c can operate on a temporary index, not $GIT_DIR/index. Ideally we should be able to pass an object database to lookup_tree() but that ship has sailed. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-11-12wt-status.c: remove implicit dependency on the_indexLibravatar Nguyễn Thái Ngọc Duy1-3/+4
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-11-08built-in rebase --autostash: leave the current branch alone if possibleLibravatar Johannes Schindelin1-1/+2
When we converted a `git reset --hard` call in the original Unix shell script to built-in code, we asked to reset the worktree and the index and explicitly *not* to detach the HEAD. By mistake, though, we still did. Let's fix this. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-11-06assert NOARG/NONEG behavior of parse-options callbacksLibravatar Jeff King1-0/+6
When we define a parse-options callback, the flags we put in the option struct must match what the callback expects. For example, a callback which does not handle the "unset" parameter should only be used with PARSE_OPT_NONEG. But since the callback and the option struct are not defined next to each other, it's easy to get this wrong (as earlier patches in this series show). Fortunately, the compiler can help us here: compiling with -Wunused-parameters can show us which callbacks ignore their "unset" parameters (and likewise, ones that ignore "arg" expect to be triggered with PARSE_OPT_NOARG). But after we've inspected a callback and determined that all of its callers use the right flags, what do we do next? We'd like to silence the compiler warning, but do so in a way that will catch any wrong calls in the future. We can do that by actually checking those variables and asserting that they match our expectations. Because this is such a common pattern, we'll introduce some helper macros. The resulting messages aren't as descriptive as we could make them, but the file/line information from BUG() is enough to identify the problem (and anyway, the point is that these should never be seen). Each of the annotated callbacks in this patch triggers -Wunused-parameters, and was manually inspected to make sure all callers use the correct options (so none of these BUGs should be triggerable). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-11-02rebase: apply cocci patchLibravatar Junio C Hamano1-1/+1
Favor oideq() over !oidcmp() when checking for equality. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-11-02Merge branch 'js/rebase-autostash-fix'Libravatar Junio C Hamano1-3/+5
"git rebase" that has recently been rewritten in C had a few issues in its "--autstash" feature, which have been corrected. * js/rebase-autostash-fix: rebase --autostash: fix issue with dirty submodules rebase --autostash: demonstrate a problem with dirty submodules rebase (autostash): use an explicit OID to apply the stash rebase (autostash): store the full OID in <state-dir>/autostash rebase (autostash): avoid duplicate call to state_dir_path()
2018-11-02Merge branch 'jc/rebase-in-c-5-test-typofix'Libravatar Junio C Hamano1-3/+3
Typofix. * jc/rebase-in-c-5-test-typofix: rebase: fix typoes in error messages