aaafd603
|
38
|
static int disable_bits(tcflag_t bits)
|
aaafd603
|
49
|
t.c_lflag &= ~bits;
|
aaafd603
|
59
|
static int disable_echo(void)
|
aaafd603
|
61
|
return disable_bits(ECHO);
|
74e42899
|
64
|
static int enable_non_canonical(void)
|
74e42899
|
66
|
return disable_bits(ICANON | ECHO);
|
61131685
|
255
|
static int sequence_entry_cmp(const void *hashmap_cmp_fn_data,
|
61131685
|
260
|
return strcmp(e1->sequence, keydata ? keydata : e2->sequence);
|
61131685
|
263
|
static int is_known_escape_sequence(const char *sequence)
|
61131685
|
268
|
if (!initialized) {
|
61131685
|
269
|
struct child_process cp = CHILD_PROCESS_INIT;
|
61131685
|
270
|
struct strbuf buf = STRBUF_INIT;
|
61131685
|
273
|
hashmap_init(&sequences, (hashmap_cmp_fn)sequence_entry_cmp,
|
61131685
|
276
|
argv_array_pushl(&cp.args, "infocmp", "-L", "-1", NULL);
|
61131685
|
277
|
if (pipe_command(&cp, NULL, 0, &buf, 0, NULL, 0))
|
61131685
|
278
|
strbuf_setlen(&buf, 0);
|
61131685
|
280
|
for (eol = p = buf.buf; *p; p = eol + 1) {
|
61131685
|
281
|
p = strchr(p, '=');
|
61131685
|
282
|
if (!p)
|
61131685
|
283
|
break;
|
61131685
|
284
|
p++;
|
61131685
|
285
|
eol = strchrnul(p, '\n');
|
61131685
|
287
|
if (starts_with(p, "\\E")) {
|
61131685
|
288
|
char *comma = memchr(p, ',', eol - p);
|
61131685
|
291
|
p[0] = '^';
|
61131685
|
292
|
p[1] = '[';
|
61131685
|
293
|
FLEX_ALLOC_MEM(e, sequence, p, comma - p);
|
61131685
|
294
|
hashmap_entry_init(&e->entry,
|
61131685
|
295
|
strhash(e->sequence));
|
61131685
|
296
|
hashmap_add(&sequences, &e->entry);
|
61131685
|
298
|
if (!*eol)
|
61131685
|
299
|
break;
|
61131685
|
301
|
initialized = 1;
|
61131685
|
304
|
return !!hashmap_get_from_hash(&sequences, strhash(sequence), sequence);
|
74e42899
|
307
|
int read_key_without_echo(struct strbuf *buf)
|
74e42899
|
312
|
if (warning_displayed || enable_non_canonical() < 0) {
|
74e42899
|
313
|
if (!warning_displayed) {
|
74e42899
|
316
|
warning_displayed = 1;
|
74e42899
|
319
|
return strbuf_getline(buf, stdin);
|
74e42899
|
322
|
strbuf_reset(buf);
|
74e42899
|
323
|
ch = getchar();
|
74e42899
|
324
|
if (ch == EOF) {
|
74e42899
|
325
|
restore_term();
|
74e42899
|
326
|
return EOF;
|
74e42899
|
328
|
strbuf_addch(buf, ch);
|
53fa2153
|
330
|
if (ch == '\033' /* ESC */) {
|
53fa2153
|
338
|
strbuf_splice(buf, buf->len - 1, 1, "^[", 2);
|
61131685
|
345
|
while (!is_known_escape_sequence(buf->buf)) {
|
53fa2153
|
346
|
struct pollfd pfd = { .fd = 0, .events = POLLIN };
|
53fa2153
|
348
|
if (poll(&pfd, 1, 500) < 1)
|
53fa2153
|
349
|
break;
|
53fa2153
|
351
|
ch = getchar();
|
53fa2153
|
352
|
if (ch == EOF)
|
53fa2153
|
353
|
return 0;
|
53fa2153
|
354
|
strbuf_addch(buf, ch);
|
74e42899
|
358
|
restore_term();
|
74e42899
|
359
|
return 0;
|
Denton Liu
|
38ac131a
|
sequencer: extract perform_autostash() from rebase
|
Denton Liu
|
daf6b9e4
|
sequencer: use file strbuf for read_oneliner()
|
Denton Liu
|
f2096173
|
reset: extract reset_head() from rebase
|
Denton Liu
|
afc27b82
|
rebase: use read_oneliner()
|
Denton Liu
|
d4e8a655
|
rebase: generify reset_head()
|
Denton Liu
|
82c638ef
|
rebase: use apply_autostash() from sequencer.c
|
Emily Shaffer
|
fae9bc5a
|
grep: support the --pathspec-from-file option
|
Johannes Schindelin
|
53fa2153
|
built-in add -p: handle Escape sequences in interactive.singlekey mode
|
Johannes Schindelin
|
61131685
|
built-in add -p: handle Escape sequences more efficiently
|
Johannes Schindelin
|
74e42899
|
terminal: add a new function to read a single keystroke
|
Johannes Schindelin
|
aaafd603
|
terminal: make the code of disable_echo() reusable
|
Johannes Schindelin
|
6610e462
|
built-in stash: use the built-in `git add -p` if so configured
|
Johannes Schindelin
|
90a6bb98
|
legacy stash -p: respect the add.interactive.usebuiltin setting
|
Johannes Schindelin
|
d2a233cb
|
built-in add -p: prepare for patch modes other than "stage"
|
Johannes Schindelin
|
52628f94
|
built-in add -p: implement the "checkout" patch modes
|
Johannes Schindelin
|
60b7e674
|
built-in add -p: respect the `interactive.singlekey` config setting
|
Johannes Schindelin
|
ad9af7e8
|
built-in add -p: support interactive.diffFilter
|
Jonathan Nieder
|
ee70c128
|
index: offer advice for unknown index extensions
|
Josh Steadmon
|
6da1f1a9
|
protocol: advertise multiple supported versions
|
Matheus Tavares
|
beebb9d2
|
object-store: allow threaded access to object reading
|
Phillip Wood
|
430b75f7
|
commit: give correct advice for empty commit during a rebase
|
Phillip Wood
|
012ecfce
|
rebase: fix advice when a fixup creates an empty commit
|
7584dd3c
|
52
|
static void err(struct add_p_state *s, const char *fmt, ...)
|
7584dd3c
|
56
|
va_start(args, fmt);
|
7584dd3c
|
57
|
fputs(s->s.error_color, stderr);
|
7584dd3c
|
58
|
vfprintf(stderr, fmt, args);
|
7584dd3c
|
59
|
fputs(s->s.reset_color, stderr);
|
7584dd3c
|
60
|
fputc('\n', stderr);
|
7584dd3c
|
61
|
va_end(args);
|
7584dd3c
|
62
|
}
|
25ea47af
|
87
|
return -1;
|
25ea47af
|
104
|
eol = s->plain.buf + s->plain.len;
|
25ea47af
|
127
|
eol = s->colored.buf + s->colored.len;
|
5906d5de
|
146
|
return 0;
|
5906d5de
|
150
|
return 0;
|
e3bd11b4
|
175
|
argv_array_clear(&args);
|
f6aa7ecc
|
209
|
eol = pend;
|
510aeca1
|
235
|
hunk->splittable_into++;
|
25ea47af
|
250
|
return -1;
|
5906d5de
|
277
|
file_diff->hunk->colored_start =
|
5906d5de
|
278
|
colored_p - colored->buf;
|
e3bd11b4
|
320
|
colored_p = colored_pend;
|
510aeca1
|
356
|
return sb->len;
|
25ea47af
|
393
|
strbuf_addf(out, "%s\n", GIT_COLOR_RESET);
|
5906d5de
|
425
|
const char *p = s->colored.buf;
|
5906d5de
|
427
|
strbuf_add(out, p + head->colored_start,
|
5906d5de
|
428
|
first->colored_start - head->colored_start);
|
5906d5de
|
429
|
strbuf_add(out, p + first->colored_end,
|
5906d5de
|
430
|
head->colored_end - first->colored_end);
|
11f2c0da
|
449
|
return 0;
|
510aeca1
|
618
|
return 0;
|
510aeca1
|
629
|
memmove(file_diff->hunk + hunk_index + splittable_into,
|
510aeca1
|
630
|
file_diff->hunk + hunk_index + 1,
|
510aeca1
|
631
|
(file_diff->hunk_nr - hunk_index - splittable_into)
|
510aeca1
|
642
|
colored_current = hunk->colored_start;
|
510aeca1
|
660
|
hunk[1].colored_start = colored_current;
|
510aeca1
|
675
|
ch = marker ? marker : ' ';
|
510aeca1
|
689
|
colored_current =
|
510aeca1
|
690
|
find_next_line(&s->colored,
|
510aeca1
|
732
|
hunk->colored_end = colored_current;
|
510aeca1
|
757
|
hunk->colored_end = colored_end;
|
bcdd297b
|
770
|
hunk->colored_start = s->colored.len;
|
bcdd297b
|
771
|
for (current = hunk->start; current < hunk->end; ) {
|
bcdd297b
|
772
|
for (eol = current; eol < hunk->end; eol++)
|
bcdd297b
|
773
|
if (plain[eol] == '\n')
|
bcdd297b
|
774
|
break;
|
bcdd297b
|
775
|
next = eol + (eol < hunk->end);
|
bcdd297b
|
776
|
if (eol > current && plain[eol - 1] == '\r')
|
bcdd297b
|
777
|
eol--;
|
bcdd297b
|
779
|
strbuf_addstr(&s->colored,
|
bcdd297b
|
780
|
plain[current] == '-' ?
|
bcdd297b
|
782
|
plain[current] == '+' ?
|
bcdd297b
|
785
|
strbuf_add(&s->colored, plain + current, eol - current);
|
bcdd297b
|
786
|
strbuf_addstr(&s->colored, GIT_COLOR_RESET);
|
bcdd297b
|
787
|
if (next > eol)
|
bcdd297b
|
788
|
strbuf_add(&s->colored, plain + eol, next - eol);
|
bcdd297b
|
789
|
current = next;
|
bcdd297b
|
791
|
hunk->colored_end = s->colored.len;
|
bcdd297b
|
825
|
return -1;
|
bcdd297b
|
840
|
return 0;
|
bcdd297b
|
906
|
return -1;
|
bcdd297b
|
910
|
case 'y': return 1;
|
bcdd297b
|
912
|
}
|
bcdd297b
|
927
|
*hunk = backup;
|
bcdd297b
|
928
|
return -1;
|
9254bdfb
|
981
|
strbuf_setlen(out, len + SUMMARY_LINE_WIDTH);
|
f6aa7ecc
|
1051
|
undecided_previous = i;
|
f6aa7ecc
|
1052
|
break;
|
f6aa7ecc
|
1073
|
strbuf_addstr(&s->buf, ",k");
|
f6aa7ecc
|
1107
|
continue;
|
80399aec
|
1118
|
for (; hunk_index < file_diff->hunk_nr; hunk_index++) {
|
80399aec
|
1119
|
hunk = file_diff->hunk + hunk_index;
|
f6aa7ecc
|
1120
|
if (hunk->use == UNDECIDED_HUNK)
|
f6aa7ecc
|
1121
|
hunk->use = USE_HUNK;
|
7584dd3c
|
1134
|
if (hunk_index)
|
7584dd3c
|
1135
|
hunk_index--;
|
7584dd3c
|
1137
|
err(s, _("No previous hunk"));
|
80399aec
|
1139
|
if (hunk_index + 1 < file_diff->hunk_nr)
|
7584dd3c
|
1140
|
hunk_index++;
|
7584dd3c
|
1142
|
err(s, _("No next hunk"));
|
7584dd3c
|
1144
|
if (undecided_previous >= 0)
|
7584dd3c
|
1145
|
hunk_index = undecided_previous;
|
7584dd3c
|
1147
|
err(s, _("No previous hunk"));
|
7584dd3c
|
1149
|
if (undecided_next >= 0)
|
7584dd3c
|
1150
|
hunk_index = undecided_next;
|
7584dd3c
|
1152
|
err(s, _("No next hunk"));
|
9254bdfb
|
1158
|
err(s, _("No other hunks to goto"));
|
9254bdfb
|
1159
|
continue;
|
9254bdfb
|
1174
|
break;
|
9254bdfb
|
1181
|
err(s, _("Invalid number: '%s'"),
|
9254bdfb
|
1189
|
(int)file_diff->hunk_nr);
|
d6cf8733
|
1195
|
err(s, _("No other hunks to search"));
|
d6cf8733
|
1196
|
continue;
|
d6cf8733
|
1201
|
printf("%s", _("search for regex? "));
|
d6cf8733
|
1202
|
fflush(stdout);
|
d6cf8733
|
1203
|
if (strbuf_getline(&s->answer,
|
d6cf8733
|
1205
|
break;
|
d6cf8733
|
1206
|
strbuf_trim_trailing_newline(&s->answer);
|
d6cf8733
|
1207
|
if (s->answer.len == 0)
|
d6cf8733
|
1208
|
continue;
|
d6cf8733
|
1216
|
err(s, _("Malformed search regexp %s: %s"),
|
d6cf8733
|
1218
|
continue;
|
d6cf8733
|
1233
|
err(s, _("No hunk matches the given pattern"));
|
d6cf8733
|
1234
|
break;
|
510aeca1
|
1240
|
err(s, _("Sorry, cannot split this hunk"));
|
bcdd297b
|
1248
|
err(s, _("Sorry, cannot edit this hunk"));
|
54d9d9b2
|
1254
|
const char *p = _(help_patch_remainder), *eol = p;
|
54d9d9b2
|
1256
|
color_fprintf(stdout, s->s.help_color, "%s",
|
54d9d9b2
|
1263
|
for (; *p; p = eol + (*eol == '\n')) {
|
54d9d9b2
|
1264
|
eol = strchrnul(p, '\n');
|
54d9d9b2
|
1271
|
if (*p != '?' && !strchr(s->buf.buf, *p))
|
54d9d9b2
|
1272
|
continue;
|
54d9d9b2
|
1274
|
color_fprintf_ln(stdout, s->s.help_color,
|
54d9d9b2
|
1275
|
"%.*s", (int)(eol - p), p);
|
25ea47af
|
1296
|
repo_refresh_and_write_index(s->s.r, REFRESH_QUIET, 0,
|
f6aa7ecc
|
1317
|
strbuf_release(&s.plain);
|
e3bd11b4
|
1318
|
strbuf_release(&s.colored);
|
f6aa7ecc
|
1319
|
return -1;
|
Alexandr Miloslavskiy
|
bebb5d6d
|
add: support the --pathspec-from-file option
|
Alexandr Miloslavskiy
|
a9aecc7a
|
checkout, restore: support the --pathspec-from-file option
|
Derrick Stolee
|
96cc8ab5
|
sparse-checkout: use hashmaps for cone patterns
|
Derrick Stolee
|
94c0956b
|
sparse-checkout: create builtin with 'list' subcommand
|
Derrick Stolee
|
72918c1a
|
sparse-checkout: create 'disable' subcommand
|
Derrick Stolee
|
af09ce24
|
sparse-checkout: init and set in cone mode
|
Derrick Stolee
|
190a65f9
|
sparse-checkout: respect core.ignoreCase in cone mode
|
Derrick Stolee
|
416adc87
|
sparse-checkout: update working directory in-process for 'init'
|
Derrick Stolee
|
bab3c359
|
sparse-checkout: create 'init' subcommand
|
Derrick Stolee
|
e091228e
|
sparse-checkout: update working directory in-process
|
Derrick Stolee
|
d89f09c8
|
clone: add --sparse mode
|
Johannes Schindelin
|
5906d5de
|
built-in app -p: allow selecting a mode change as a "hunk"
|
Johannes Schindelin
|
25ea47af
|
built-in add -p: adjust hunk headers as needed
|
Johannes Schindelin
|
7584dd3c
|
built-in add -p: offer a helpful error message when hunk navigation failed
|
Johannes Schindelin
|
54d9d9b2
|
built-in add -p: only show the applicable parts of the help text
|
Johannes Schindelin
|
d6cf8733
|
built-in add -p: implement the '/' ("search regex") command
|
Johannes Schindelin
|
80399aec
|
built-in add -p: support multi-file diffs
|
Johannes Schindelin
|
9254bdfb
|
built-in add -p: implement the 'g' ("goto") command
|
Johannes Schindelin
|
bcdd297b
|
built-in add -p: implement hunk editing
|
Johannes Schindelin
|
11f2c0da
|
built-in add -p: coalesce hunks after splitting them
|
Johannes Schindelin
|
510aeca1
|
built-in add -p: implement the hunk splitting feature
|
Johannes Schindelin
|
f6aa7ecc
|
built-in add -i: start implementing the `patch` functionality in C
|
Johannes Schindelin
|
e3bd11b4
|
built-in add -p: show colored hunks by default
|
Johannes Schindelin
|
b38dd9e7
|
strbuf: add a helper function to call the editor "on an strbuf"
|
Tanushree Tumane
|
51a0a4ed
|
bisect--helper: avoid use-after-free
|