Skip to content

Commit 6e7baf2

Browse files
peffgitster
authored andcommitted
am: drop tty requirement for --interactive
We have required that the stdin of "am --interactive" be a tty since a145110 (git-am: interactive should fail gracefully., 2005-10-12). However, this isn't strictly necessary, and makes the tool harder to test (and is unlike all of our other --interactive commands). The goal of that commit was to make sure that somebody does not do: git am --interactive <mbox and cause us to read commands from the mbox. But we can simply check up front for this case and complain before entering the interactive loop. Technically this disallows: git am --interactive </dev/null where our lack of patches means we would never prompt for anything, and so the old code would not notice our lack of tty (and now we'd die early). But since such a command is totally pointless, it's no loss. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 97387c8 commit 6e7baf2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

builtin/am.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,9 +1640,6 @@ static int do_interactive(struct am_state *state)
16401640
{
16411641
assert(state->msg);
16421642

1643-
if (!isatty(0))
1644-
die(_("cannot be interactive without stdin connected to a terminal."));
1645-
16461643
for (;;) {
16471644
char reply[64];
16481645

@@ -2327,6 +2324,9 @@ int cmd_am(int argc, const char **argv, const char *prefix)
23272324
argv_array_push(&paths, mkpath("%s/%s", prefix, argv[i]));
23282325
}
23292326

2327+
if (state.interactive && !paths.argc)
2328+
die(_("interactive mode requires patches on the command line"));
2329+
23302330
am_setup(&state, patch_format, paths.argv, keep_cr);
23312331

23322332
argv_array_clear(&paths);

0 commit comments

Comments
 (0)