1
0
mirror of https://github.com/git/git synced 2024-07-02 15:48:44 +00:00
git/builtin
Jeff King 53ce2e3f0a am: add explicit "--retry" option
After a patch fails, you can ask "git am" to try applying it again with
new options by running without any of the resume options. E.g.:

  git am <patch
  # oops, it failed; let's try again
  git am --3way

But since this second command has no explicit resume option (like
"--continue"), it looks just like an invocation to read a fresh patch
from stdin. To avoid confusing the two cases, there are some heuristics,
courtesy of 8d18550318 (builtin-am: reject patches when there's a
session in progress, 2015-08-04):

	if (in_progress) {
		/*
		 * Catch user error to feed us patches when there is a session
		 * in progress:
		 *
		 * 1. mbox path(s) are provided on the command-line.
		 * 2. stdin is not a tty: the user is trying to feed us a patch
		 *    from standard input. This is somewhat unreliable -- stdin
		 *    could be /dev/null for example and the caller did not
		 *    intend to feed us a patch but wanted to continue
		 *    unattended.
		 */
		if (argc || (resume_mode == RESUME_FALSE && !isatty(0)))
			die(_("previous rebase directory %s still exists but mbox given."),
				state.dir);

		if (resume_mode == RESUME_FALSE)
			resume_mode = RESUME_APPLY;
		[...]

So if no resume command is given, then we require that stdin be a tty,
and otherwise complain about (potentially) receiving an mbox on stdin.
But of course you might not actually have a terminal available! And
sadly there is no explicit way to hit this same code path; this is the
only place that sets RESUME_APPLY. So you're stuck, and scripts like our
test suite have to bend over backwards to create a pseudo-tty.

Let's provide an explicit option to trigger this mode. The code turns
out to be quite simple; just setting "resume_mode" to RESUME_FALSE is
enough to dodge the tty check, and then our state is the same as it
would be with the heuristic case (which we'll continue to allow).

When we don't have a session in progress, there's already code to
complain when resume_mode is set (but we'll add a new test to cover
that).

To test the new option, we'll convert the existing tests that rely on
the fake stdin tty. That lets us test them on more platforms, and will
let us simplify test_terminal a bit in a future patch.

It does, however, mean we're not testing the tty heuristic at all.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-06-06 10:07:41 -07:00
..
add.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
am.c am: add explicit "--retry" option 2024-06-06 10:07:41 -07:00
annotate.c strvec: rename struct fields 2020-07-30 19:18:06 -07:00
apply.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
archive.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:33 -08:00
bisect.c Merge branch 'en/header-cleanup' into maint-2.43 2024-02-08 16:22:10 -08:00
blame.c Merge branch 'en/header-cleanup' into maint-2.43 2024-02-08 16:22:10 -08:00
branch.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
bugreport.c bugreport: reject positional arguments 2023-10-29 08:56:17 +09:00
bundle.c Merge branch 'rs/bundle-parseopt-cleanup' 2023-08-07 11:57:18 -07:00
cat-file.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
check-attr.c check-attr: integrate with sparse-index 2023-08-11 09:44:52 -07:00
check-ignore.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
check-mailmap.c builtin.h: remove unneccessary includes 2023-06-21 13:39:54 -07:00
check-ref-format.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
checkout--worker.c git-compat-util: move alloc macros to git-compat-util.h 2023-07-05 11:42:31 -07:00
checkout-index.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
checkout.c Merge branch 'en/header-cleanup' into maint-2.43 2024-02-08 16:22:10 -08:00
clean.c clean: factorize incompatibility message 2023-12-09 07:41:03 +09:00
clone.c Merge branch 'fixes/2.45.1/2.42' into fixes/2.45.1/2.43 2024-05-24 16:58:11 -07:00
column.c Merge branch 'rs/column-leakfix' into maint-2.43 2024-02-08 16:22:06 -08:00
commit-graph.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:33 -08:00
commit-tree.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
commit.c Merge branch 'en/header-cleanup' into maint-2.43 2024-02-08 16:22:10 -08:00
config.c Merge branch 'cw/compat-util-header-cleanup' 2023-07-17 11:30:42 -07:00
count-objects.c count-objects: mark unused parameter in alternates callback 2023-07-13 17:24:00 -07:00
credential-cache--daemon.c git-compat-util: move alloc macros to git-compat-util.h 2023-07-05 11:42:31 -07:00
credential-cache.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
credential-store.c Merge branch 'cw/strbuf-cleanup' 2023-07-06 11:54:46 -07:00
credential.c builtins: mark unused prefix parameters 2023-03-28 14:11:24 -07:00
describe.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
diagnose.c object-file.h: move declarations for object-file.c functions from cache.h 2023-04-11 08:52:10 -07:00
diff-files.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
diff-index.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
diff-tree.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
diff.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
difftool.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
fast-export.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
fast-import.c fast-import: use mem_pool_calloc() 2023-12-26 11:06:23 -08:00
fetch-pack.c git-compat-util: move alloc macros to git-compat-util.h 2023-07-05 11:42:31 -07:00
fetch.c Merge branch 'en/header-cleanup' into maint-2.43 2024-02-08 16:22:10 -08:00
fmt-merge-msg.c treewide: remove unnecessary includes for wrapper.h 2023-07-05 11:41:59 -07:00
for-each-ref.c treewide: add direct includes currently only pulled in transitively 2023-12-26 12:04:32 -08:00
for-each-repo.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
fsck.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:33 -08:00
fsmonitor--daemon.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:33 -08:00
gc.c Merge branch 'tb/repack-max-cruft-size' 2023-10-18 13:25:41 -07:00
get-tar-commit-id.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
grep.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:33 -08:00
hash-object.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
help.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
hook.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
index-pack.c Merge branch 'jk/index-pack-lsan-false-positive-fix' into maint-2.43 2024-02-08 16:22:12 -08:00
init-db.c Sync with 2.40.2 2024-04-19 12:38:42 +02:00
interpret-trailers.c Merge branch 'la/trailer-test-and-doc-updates' 2023-10-13 14:18:27 -07:00
log.c Merge branch 'en/header-cleanup' into maint-2.43 2024-02-08 16:22:10 -08:00
ls-files.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
ls-remote.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
ls-tree.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
mailinfo.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
mailsplit.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
merge-base.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
merge-file.c merge-file: add an option to process object IDs 2023-11-02 08:51:40 +09:00
merge-index.c read-cache*.h: move declarations for read-cache.c functions from cache.h 2023-06-21 13:39:53 -07:00
merge-ours.c diff.h: remove unnecessary include of oidset.h 2023-06-21 13:39:53 -07:00
merge-recursive.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
merge-tree.c Merge branch 'en/header-cleanup' into maint-2.43 2024-02-08 16:22:10 -08:00
merge.c Merge branch 'en/header-cleanup' into maint-2.43 2024-02-08 16:22:10 -08:00
mktag.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:33 -08:00
mktree.c git-compat-util: move alloc macros to git-compat-util.h 2023-07-05 11:42:31 -07:00
multi-pack-index.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
mv.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
name-rev.c name-rev: use OPT_HIDDEN_BOOL for --peel-tag 2023-09-05 14:58:44 -07:00
notes.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
pack-objects.c Merge branch 'en/header-cleanup' into maint-2.43 2024-02-08 16:22:10 -08:00
pack-redundant.c object-store-ll.h: split this header out of object-store.h 2023-06-21 13:39:54 -07:00
pack-refs.c pack-refs: teach pack-refs --include option 2023-05-12 14:54:14 -07:00
patch-id.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
prune-packed.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
prune.c Merge branch 'en/header-split-cache-h-part-3' 2023-06-29 16:43:21 -07:00
pull.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
push.c Merge branch 'en/header-cleanup' into maint-2.43 2024-02-08 16:22:10 -08:00
range-diff.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
read-tree.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
rebase.c Merge branch 'en/header-cleanup' into maint-2.43 2024-02-08 16:22:10 -08:00
receive-pack.c Merge branch 'en/header-cleanup' into maint-2.43 2024-02-08 16:22:10 -08:00
reflog.c Merge branch 'jb/reflog-expire-delete-dry-run-options' into maint-2.43 2024-02-08 16:22:05 -08:00
remote-ext.c builtins: annotate always-empty prefix parameters 2023-03-28 14:11:24 -07:00
remote-fd.c builtins: annotate always-empty prefix parameters 2023-03-28 14:11:24 -07:00
remote.c Merge branch 'jc/parse-options-short-help' 2023-08-04 10:52:31 -07:00
repack.c Merge branch 'en/header-cleanup' into maint-2.43 2024-02-08 16:22:10 -08:00
replace.c replace: mark unused parameter in each_mergetag_fn callback 2023-07-13 17:24:00 -07:00
rerere.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
reset.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
rev-list.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:33 -08:00
rev-parse.c revision, rev-parse: factorize incompatibility messages about - -exclude-hidden 2023-12-09 07:41:03 +09:00
revert.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
rm.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
send-pack.c Merge branch 'en/header-cleanup' into maint-2.43 2024-02-08 16:22:10 -08:00
shortlog.c diff.h: remove unnecessary include of oidset.h 2023-06-21 13:39:53 -07:00
show-branch.c Merge branch 'jc/parse-options-show-branch' 2023-07-27 15:26:37 -07:00
show-index.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
show-ref.c Merge branch 'tc/show-ref-exists-fix' into maint-2.43 2024-02-13 14:44:47 -08:00
sparse-checkout.c Merge branch 'en/header-cleanup' into maint-2.43 2024-02-08 16:22:10 -08:00
stash.c Merge branch 'ps/report-failure-from-git-stash' into maint-2.43 2024-02-13 14:44:49 -08:00
stripspace.c Merge branch 'cw/strbuf-cleanup' 2023-07-06 11:54:46 -07:00
submodule--helper.c Sync with 2.42.2 2024-04-19 12:38:50 +02:00
symbolic-ref.c git-compat-util: move strbuf.c funcs to its header 2023-07-05 11:41:18 -07:00
tag.c Merge branch 'jc/sign-buffer-failure-propagation-fix' into maint-2.43 2024-02-13 14:44:48 -08:00
unpack-file.c treewide: remove unnecessary includes for wrapper.h 2023-07-05 11:41:59 -07:00
unpack-objects.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
update-index.c Merge branch 'jc/unresolve-removal' 2023-10-02 11:20:00 -07:00
update-ref.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
update-server-info.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
upload-archive.c repository: remove unnecessary include of path.h 2023-06-21 13:39:53 -07:00
upload-pack.c Sync with 2.41.1 2024-04-19 12:38:46 +02:00
var.c Merge branch 'bc/more-git-var' into maint-2.42 2023-11-02 16:53:23 +09:00
verify-commit.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
verify-pack.c builtin.h: remove unneccessary includes 2023-06-21 13:39:54 -07:00
verify-tag.c treewide: remove unnecessary includes in source files 2023-12-26 12:04:31 -08:00
worktree.c Merge branch 'jc/comment-style-fixes' into maint-2.43 2024-02-13 14:44:48 -08:00
write-tree.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00