MCPcopy Create free account
hub / github.com/git/git / setup_pager

Function setup_pager

pager.c:145–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145void setup_pager(struct repository *r)
146{
147 static int once = 0;
148 const char *pager = git_pager(r, isatty(1));
149
150 if (!pager)
151 return;
152
153 /*
154 * After we redirect standard output, we won't be able to use an ioctl
155 * to get the terminal size. Let's grab it now, and then set $COLUMNS
156 * to communicate it to any sub-processes.
157 */
158 {
159 char buf[64];
160 xsnprintf(buf, sizeof(buf), "%d", term_columns());
161 if (!term_columns_guessed)
162 setenv("COLUMNS", buf, 0);
163 }
164
165 setenv("GIT_PAGER_IN_USE", "true", 1);
166
167 child_process_init(&pager_process);
168
169 /* spawn the pager */
170 prepare_pager_args(&pager_process, pager);
171 pager_process.in = -1;
172 strvec_push(&pager_process.env, "GIT_PAGER_IN_USE");
173 if (start_command(&pager_process))
174 die("unable to execute pager '%s'", pager);
175
176 /* original process continues, but writes to the pipe */
177 old_fd1 = dup(1);
178 dup2(pager_process.in, 1);
179 if (isatty(2)) {
180 old_fd2 = dup(2);
181 dup2(pager_process.in, 2);
182 }
183 close(pager_process.in);
184
185 sigchain_push_common(wait_for_pager_signal);
186
187 if (!once) {
188 once++;
189 atexit(wait_for_pager_atexit);
190 }
191}
192
193int pager_in_use(void)
194{

Callers 9

commit_pager_choiceFunction · 0.85
patch_update_fileFunction · 0.85
setup_diff_pagerFunction · 0.85
cmd_helpFunction · 0.85
show_patchFunction · 0.85
cmd_log_init_finishFunction · 0.85
cmd_format_patchFunction · 0.85
cmd_grepFunction · 0.85
cmd_blameFunction · 0.85

Calls 9

git_pagerFunction · 0.85
xsnprintfFunction · 0.85
term_columnsFunction · 0.85
child_process_initFunction · 0.85
prepare_pager_argsFunction · 0.85
strvec_pushFunction · 0.85
start_commandFunction · 0.85
sigchain_push_commonFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected