1
0
mirror of https://github.com/git/git.git synced 2024-10-19 12:58:13 +02:00
git/builtin
Jacob Keller 7efba5fa39 format-patch: teach format.useAutoBase "whenAble" option
The format.useAutoBase configuration option exists to allow users to
enable '--base=auto' for format-patch by default.

This can sometimes lead to poor workflow, due to unexpected failures
when attempting to format an ancient patch:

    $ git format-patch -1 <an old commit>
    fatal: base commit shouldn't be in revision list

This can be very confusing, as it is not necessarily immediately obvious
that the user requested a --base (since this was in the configuration,
not on the command line).

We do want --base=auto to fail when it cannot provide a suitable base,
as it would be equally confusing if a formatted patch did not include
the base information when it was requested.

Teach format.useAutoBase a new mode, "whenAble". This mode will cause
format-patch to attempt to include a base commit when it can. However,
if no valid base commit can be found, then format-patch will continue
formatting the patch without a base commit.

In order to avoid making yet another branch name unusable with --base,
do not teach --base=whenAble or --base=whenable.

Instead, refactor the base_commit option to use a callback, and rely on
the global configuration variable auto_base.

This does mean that a user cannot request this optional base commit
generation from the command line. However, this is likely not too
valuable. If the user requests base information manually, they will be
immediately informed of the failure to acquire a suitable base commit.
This allows the user to make an informed choice about whether to
continue the format.

Add tests to cover the new mode of operation for --base.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-10-01 15:22:10 -07:00
..
add.c add -i: use the built-in version when feature.experimental is set 2020-09-08 14:53:36 -07:00
am.c Merge branch 'ds/maintenance-part-1' 2020-09-25 15:25:38 -07:00
annotate.c strvec: rename struct fields 2020-07-30 19:18:06 -07:00
apply.c
archive.c
bisect--helper.c bisect: swap command-line options in documentation 2020-08-28 14:06:06 -07:00
blame.c messages: avoid SHA-1 in end-user facing messages 2020-08-14 09:33:37 -07:00
branch.c ref-filter: allow merged and no-merged filters 2020-09-16 12:38:10 -07:00
bugreport.c Merge branch 'jk/slimmed-down' 2020-09-03 12:37:02 -07:00
bundle.c Merge branch 'bc/sha-256-part-3' 2020-08-11 18:04:11 -07:00
cat-file.c Merge branch 'cc/cat-file-usage-update' into master 2020-07-09 14:00:41 -07:00
check-attr.c
check-ignore.c dir: fix problematic API to avoid memory leaks 2020-08-18 17:17:31 -07:00
check-mailmap.c
check-ref-format.c
checkout-index.c Use OPT_CALLBACK and OPT_CALLBACK_F 2020-04-28 10:47:10 -07:00
checkout.c Merge branch 'jt/interpret-branch-name-fallback' 2020-09-09 13:53:09 -07:00
clean.c quote_path: give flags parameter to quote_path() 2020-09-10 10:49:19 -07:00
clone.c refspec: add and use refspec_appendf() 2020-09-06 13:15:46 -07:00
column.c
commit-graph.c Merge branch 'ds/commit-graph-bloom-updates' into master 2020-07-30 13:20:31 -07:00
commit-tree.c Use OPT_CALLBACK and OPT_CALLBACK_F 2020-04-28 10:47:10 -07:00
commit.c Merge branch 'ds/maintenance-part-1' 2020-09-25 15:25:38 -07:00
config.c Merge branch 'ls/mergetool-meld-auto-merge' 2020-09-22 12:36:29 -07:00
count-objects.c
credential-cache--daemon.c make credential helpers builtins 2020-08-13 11:02:08 -07:00
credential-cache.c Merge branch 'jc/undash-in-tree-git-callers' 2020-09-03 12:37:03 -07:00
credential-store.c make credential helpers builtins 2020-08-13 11:02:08 -07:00
credential.c
describe.c strvec: rename struct fields 2020-07-30 19:18:06 -07:00
diff-files.c diff-files: treat "i-t-a" files as "not-in-index" 2020-06-22 10:46:45 -07:00
diff-index.c
diff-tree.c diff-tree.c: load notes machinery when required 2020-04-20 18:22:54 -07:00
diff.c Merge branch 'ct/diff-with-merge-base-clarification' into master 2020-07-09 14:00:43 -07:00
difftool.c strvec: rename struct fields 2020-07-30 19:18:06 -07:00
env--helper.c env--helper: mark a file-local symbol as static 2019-07-11 14:31:04 -07:00
fast-export.c wt-status: tolerate dangling marks 2020-09-02 14:39:25 -07:00
fast-import.c fast-import: use write_pack_header() 2020-09-06 13:40:37 -07:00
fetch-pack.c fetch-pack: remove no_dependents code 2020-08-18 16:46:53 -07:00
fetch.c Merge branch 'ds/maintenance-part-1' 2020-09-25 15:25:38 -07:00
fmt-merge-msg.c Lib-ify fmt-merge-msg 2020-03-24 15:04:43 -07:00
for-each-ref.c ref-filter: allow merged and no-merged filters 2020-09-16 12:38:10 -07:00
fsck.c fsck: do not lazy fetch known non-promisor object 2020-08-06 13:01:03 -07:00
gc.c maintenance: add trace2 regions for task execution 2020-09-17 11:30:05 -07:00
get-tar-commit-id.c
grep.c quote_path: give flags parameter to quote_path() 2020-09-10 10:49:19 -07:00
hash-object.c
help.c help: drop usage of 'common' and 'useful' for guides 2020-08-04 18:34:01 -07:00
index-pack.c Merge branch 'jt/threaded-index-pack' 2020-09-22 12:36:28 -07:00
init-db.c init: make --separate-git-dir work from within linked worktree 2020-08-31 11:47:45 -07:00
interpret-trailers.c Use OPT_CALLBACK and OPT_CALLBACK_F 2020-04-28 10:47:10 -07:00
log.c format-patch: teach format.useAutoBase "whenAble" option 2020-10-01 15:22:10 -07:00
ls-files.c dir: fix problematic API to avoid memory leaks 2020-08-18 17:17:31 -07:00
ls-remote.c Merge branch 'jk/unleak-fixes' 2020-08-24 14:54:30 -07:00
ls-tree.c
mailinfo.c
mailsplit.c
merge-base.c rebase: --fork-point regression fix 2020-02-11 09:59:39 -08:00
merge-file.c
merge-index.c
merge-ours.c
merge-recursive.c Ensure index matches head before invoking merge machinery, round N 2019-08-19 10:08:03 -07:00
merge-tree.c Merge branch 'jk/tree-walk-overflow' 2019-08-22 12:34:10 -07:00
merge.c Merge branch 'ds/maintenance-part-1' 2020-09-25 15:25:38 -07:00
mktag.c sha1-file: allow check_object_signature() to handle any repo 2020-01-31 10:45:39 -08:00
mktree.c
multi-pack-index.c multi-pack-index: add [--[no-]progress] option. 2019-10-23 12:05:06 +09:00
mv.c git-mv: improve error message for conflicted file 2020-07-20 14:35:43 -07:00
name-rev.c messages: avoid SHA-1 in end-user facing messages 2020-08-14 09:33:37 -07:00
notes.c Use OPT_CALLBACK and OPT_CALLBACK_F 2020-04-28 10:47:10 -07:00
pack-objects.c Merge branch 'jc/object-names-are-not-sha-1' 2020-08-19 16:14:52 -07:00
pack-redundant.c
pack-refs.c
patch-id.c patch-id: use oid_to_hex() to print multiple object IDs 2019-12-09 12:26:40 -08:00
prune-packed.c Lib-ify prune-packed 2020-03-24 15:04:44 -07:00
prune.c Merge branch 'tb/shallow-cleanup' 2020-05-13 12:19:18 -07:00
pull.c strvec: rename struct fields 2020-07-30 19:18:06 -07:00
push.c refspec: add and use refspec_appendf() 2020-09-06 13:15:46 -07:00
range-diff.c strvec: convert builtin/ callers away from argv_array name 2020-07-28 15:02:18 -07:00
read-tree.c Use OPT_CALLBACK and OPT_CALLBACK_F 2020-04-28 10:47:10 -07:00
rebase.c Merge branch 'ds/maintenance-part-1' 2020-09-25 15:25:38 -07:00
receive-pack.c Merge branch 'jx/proc-receive-hook' 2020-09-25 15:25:39 -07:00
reflog.c Merge branch 'es/get-worktrees-unsort' 2020-07-06 22:09:15 -07:00
remote-ext.c strvec: convert builtin/ callers away from argv_array name 2020-07-28 15:02:18 -07:00
remote-fd.c
remote.c Merge branch 'cs/don-t-pretend-a-failed-remote-set-head-succeeded' 2020-09-22 12:36:32 -07:00
repack.c Merge branch 'tb/repack-clearing-midx' 2020-09-09 13:53:06 -07:00
replace.c strvec: rename struct fields 2020-07-30 19:18:06 -07:00
rerere.c
reset.c wt-status: tolerate dangling marks 2020-09-02 14:39:25 -07:00
rev-list.c bisect: combine args passed to find_bisection() 2020-08-07 15:13:03 -07:00
rev-parse.c wt-status: tolerate dangling marks 2020-09-02 14:39:25 -07:00
revert.c Merge branch 'ra/cherry-pick-revert-skip' 2019-07-19 11:30:21 -07:00
rm.c rm: support the --pathspec-from-file option 2020-02-19 10:56:49 -08:00
send-pack.c Merge branch 'jx/proc-receive-hook' 2020-09-25 15:25:39 -07:00
shortlog.c Use OPT_CALLBACK and OPT_CALLBACK_F 2020-04-28 10:47:10 -07:00
show-branch.c Merge branch 'jt/interpret-branch-name-fallback' 2020-09-09 13:53:09 -07:00
show-index.c builtin/show-index: provide options to determine hash algo 2020-05-27 10:07:07 -07:00
show-ref.c Use OPT_CALLBACK and OPT_CALLBACK_F 2020-04-28 10:47:10 -07:00
sparse-checkout.c Merge branch 'xl/upgrade-repo-format' 2020-06-29 14:17:24 -07:00
stash.c Merge branch 'jt/interpret-branch-name-fallback' 2020-09-09 13:53:09 -07:00
stripspace.c
submodule--helper.c Merge branch 'ss/submodule-summary-in-c-fixes' 2020-09-09 13:53:07 -07:00
symbolic-ref.c
tag.c ref-filter: allow merged and no-merged filters 2020-09-16 12:38:10 -07:00
unpack-file.c
unpack-objects.c sha1-file: pass git_hash_algo to hash_object_file() 2020-01-31 10:45:39 -08:00
update-index.c Use OPT_CALLBACK and OPT_CALLBACK_F 2020-04-28 10:47:10 -07:00
update-ref.c strvec: rename files from argv-array to strvec 2020-07-28 15:02:17 -07:00
update-server-info.c
upload-archive.c strvec: rename struct fields 2020-07-30 19:18:06 -07:00
upload-pack.c
var.c
verify-commit.c Merge branch 'jk/no-system-includes-in-dot-c' 2019-07-31 14:38:56 -07:00
verify-pack.c Merge branch 'bc/sha-256-part-3' 2020-08-11 18:04:11 -07:00
verify-tag.c
worktree.c Merge branch 'es/wt-add-detach' 2020-09-18 17:58:04 -07:00
write-tree.c