Introduce a new --show-new-head-line command line option, that determines whether the "HEAD is now at ..." message is printed or not. It is enabled by default to preserve the current behaviour. It will be used in a subsequent commit to disable printing the "HEAD is now at ..." line in 'git worktree add', so it can be replaced with a custom one, that explains the behaviour better. We cannot just pass the --quite flag from 'git worktree add', as that would also hide progress output when checking out large working trees, which is undesirable. As this option is only for internal use, which we probably don't want to advertise to our users, at least until there's a need for it, make it a hidden flag. Signed-off-by: Thomas Gummerer <t.gummerer@xxxxxxxxx> --- builtin/reset.c | 5 ++++- t/t7102-reset.sh | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/builtin/reset.c b/builtin/reset.c index e15f595799..54b2576449 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -288,6 +288,7 @@ static int git_reset_config(const char *var, const char *value, void *cb) int cmd_reset(int argc, const char **argv, const char *prefix) { int reset_type = NONE, update_ref_status = 0, quiet = 0; + int show_new_head_line = 1; int patch_mode = 0, unborn; const char *rev; struct object_id oid; @@ -310,6 +311,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix) OPT_BOOL('p', "patch", &patch_mode, N_("select hunks interactively")), OPT_BOOL('N', "intent-to-add", &intent_to_add, N_("record only the fact that removed paths will be added later")), + OPT_HIDDEN_BOOL(0, "show-new-head-line", &show_new_head_line, N_("show information on the new HEAD")), OPT_END() }; @@ -403,7 +405,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix) * switched to, saving the previous head in ORIG_HEAD before. */ update_ref_status = reset_refs(rev, &oid); - if (reset_type == HARD && !update_ref_status && !quiet) + if (reset_type == HARD && !update_ref_status && !quiet && + show_new_head_line) print_new_head_line(lookup_commit_reference(&oid)); } if (!pathspec.nr) diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh index 95653a08ca..a160f78aba 100755 --- a/t/t7102-reset.sh +++ b/t/t7102-reset.sh @@ -568,4 +568,9 @@ test_expect_success 'reset --mixed sets up work tree' ' test_cmp expect actual ' +test_expect_success 'reset --no-show-new-head-line suppresses "HEAD is now at" output' ' + git reset --hard --no-show-new-head-line HEAD >actual && + ! grep "HEAD is now at" <actual +' + test_done -- 2.16.1.78.ga2082135d8