git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git: fix paginate handling for commands with DELAY_PAGER_CONFIG
@ 2024-11-20 10:17 Matthew Bystrin
  2024-11-21 21:50 ` Martin Ågren
  2024-11-22 18:50 ` Kristoffer Haugsbakk
  0 siblings, 2 replies; 8+ messages in thread
From: Matthew Bystrin @ 2024-11-20 10:17 UTC (permalink / raw)
  To: git
  Cc: Lessley Dennington, Ævar Arnfjörð Bjarmason,
	Junio C Hamano, Elijah Newren, Phillip Wood, idriss fekir,
	Joey Salazar

Calling commands using editor in terminal with `--paginate` option will
break things. For example `git --paginate config --edit`. Add extra
check to ignore paginate flag in case command have DELAY_PAGER_CONFIG
set.

Relates: cd878a206e8c (t7006: add tests for how git config paginates)
Signed-off-by: Matthew Bystrin <dev.mbstr@gmail.com>
---
Hi!

Some time ago I've sent RFC patch [1], which was not quite ready, and I didn't
receive any feedback. Now I'm sending a more complete version of it. Fixing
mentioned behaviour of `note` command can be done in separate patch series.

Link: https://lore.kernel.org/git/20241104140536.4970-1-dev.mbstr@gmail.com/

 git.c            | 5 +++--
 t/t7006-pager.sh | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/git.c b/git.c
index c2c1b8e22c..2b3b049f4a 100644
--- a/git.c
+++ b/git.c
@@ -464,11 +464,12 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv, struct
 	}
 	assert(!prefix || *prefix);
 	precompose_argv_prefix(argc, argv, NULL);
-	if (use_pager == -1 && run_setup &&
-		!(p->option & DELAY_PAGER_CONFIG))
+	if (use_pager == -1 && run_setup && !(p->option & DELAY_PAGER_CONFIG))
 		use_pager = check_pager_config(p->cmd);
 	if (use_pager == -1 && p->option & USE_PAGER)
 		use_pager = 1;
+	if (use_pager == 1 && (p->option & DELAY_PAGER_CONFIG))
+		use_pager = 0;
 	if (run_setup && startup_info->have_repository)
 		/* get_git_dir() may set up repo, avoid that */
 		trace_repo_setup();
diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh
index a0296d6ca4..218c5093d3 100755
--- a/t/t7006-pager.sh
+++ b/t/t7006-pager.sh
@@ -188,11 +188,11 @@ test_expect_success TTY 'git tag -a ignores pager.tag' '
 	test_path_is_missing paginated.out
 '
 
-test_expect_success TTY 'git tag -a respects --paginate' '
+test_expect_success TTY 'git tag -a do not respects --paginate' '
 	test_when_finished "git tag -d newtag" &&
 	rm -f paginated.out &&
 	test_terminal git --paginate tag -am message newtag &&
-	test_path_is_file paginated.out
+	test_path_is_missing paginated.out
 '
 
 test_expect_success TTY 'git tag as alias ignores pager.tag with -a' '
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-11-28 22:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-20 10:17 [PATCH] git: fix paginate handling for commands with DELAY_PAGER_CONFIG Matthew Bystrin
2024-11-21 21:50 ` Martin Ågren
2024-11-22 17:21   ` Junio C Hamano
2024-11-22 18:13     ` Matthew Bystrin
2024-11-25  2:21       ` Junio C Hamano
2024-11-25 10:55       ` Martin Ågren
2024-11-28 22:27         ` Matthew Bystrin
2024-11-22 18:50 ` Kristoffer Haugsbakk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).