419
return 0;
420
}
421
422
+#define READ_ONELINER_SKIP_IF_EMPTY (1 << 0)
423
+
424
/*
425
* Reads a file that was presumably written by a shell script, i.e. with an
426
* end-of-line marker that needs to be stripped.
431
* Returns 1 if the file was read, 0 if it could not be read or does not exist.
432
*/
433
static int read_oneliner(struct strbuf *buf,
432
- const char *path, int skip_if_empty)
434
+ const char *path, unsigned flags)
435
{
436
int orig_len = buf->len;
437
447
buf->buf[buf->len] = '\0';
448
}
449
448
- if (skip_if_empty && buf->len == orig_len)
450
+ if ((flags & READ_ONELINER_SKIP_IF_EMPTY) && buf->len == orig_len)
451
return 0;
452
453
return 1;
2487
struct strbuf buf = STRBUF_INIT;
2488
int ret = 0;
2489
2488
- if (read_oneliner(&buf, rebase_path_gpg_sign_opt(), 1)) {
2490
+ if (read_oneliner(&buf, rebase_path_gpg_sign_opt(),
2491
+ READ_ONELINER_SKIP_IF_EMPTY)) {
2492
if (!starts_with(buf.buf, "-S"))
2493
strbuf_reset(&buf);
2494
else {
2498
strbuf_reset(&buf);
2499
}
2500
2498
- if (read_oneliner(&buf, rebase_path_allow_rerere_autoupdate(), 1)) {
2501
+ if (read_oneliner(&buf, rebase_path_allow_rerere_autoupdate(),
2502
+ READ_ONELINER_SKIP_IF_EMPTY)) {
2503
if (!strcmp(buf.buf, "--rerere-autoupdate"))
2504
opts->allow_rerere_auto = RERERE_AUTOUPDATE;
2505
else if (!strcmp(buf.buf, "--no-rerere-autoupdate"))
2531
strbuf_reset(&buf);
2532
2533
if (read_oneliner(&opts->current_fixups,
2530
- rebase_path_current_fixups(), 1)) {
2534
+ rebase_path_current_fixups(),
2535
+ READ_ONELINER_SKIP_IF_EMPTY)) {
2536
const char *p = opts->current_fixups.buf;
2537
opts->current_fixup_count = 1;
2538
while ((p = strchr(p, '\n'))) {
3673
struct child_process child = CHILD_PROCESS_INIT;
3674
int ret = 0;
3675
3671
- if (!read_oneliner(&stash_sha1, rebase_path_autostash(), 1)) {
3676
+ if (!read_oneliner(&stash_sha1, rebase_path_autostash(),
3677
+ READ_ONELINER_SKIP_IF_EMPTY)) {
3678
strbuf_release(&stash_sha1);
3679
return 0;
3680
}
4298
struct strbuf buf = STRBUF_INIT;
4299
struct object_id oid;
4300
4295
- if (read_oneliner(&buf, rebase_path_stopped_sha(), 1) &&
4301
+ if (read_oneliner(&buf, rebase_path_stopped_sha(),
4302
+ READ_ONELINER_SKIP_IF_EMPTY) &&
4303
!get_oid_committish(buf.buf, &oid))
4304
record_in_rewritten(&oid, peek_command(&todo_list, 0));
4305
strbuf_release(&buf);