Re: [PATCH v2 1/3] notes.c: introduce "--blank-line" option
- From
Teng Long <dyroneteng@gmail.com>
- Date
- Nov 8, 2022, 13:06 UTC
- Message-ID
- <20221108130606.82005-1-tenglong.tl@alibaba-inc.com>
- In-Reply-To
- <221107.864jvax1hz.gmgdl@evledraar.gmail.com>
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com> writes:
Show 16 quoted lines
> > int allow_empty = 0;
> > + int blankline = 1;
>
> So keep this...
>
> > const char *object_ref;
> >G struct notes_tree *t;
> > struct object_id object, new_note;
> > @@ -584,6 +585,8 @@ static int append_edit(int argc, const char **argv, const char *prefix)
> > parse_reuse_arg),
> > OPT_BOOL(0, "allow-empty", &allow_empty,
> > N_("allow storing empty note")),
> > + OPT_BOOL(0, "blank-line", &blankline,
>
> ...and just make this "no-blank-line", and parse_options() will do the
> right thing. I.e. PARSE_OPT_NONEG is implied.Sorry for another question. By the explanation of "api-parse-options.txt" :
`OPT_BOOL(short, long, &int_var, description)`:: Introduce a boolean option. `int_var` is set to one with `--option` and set to zero with `--no-option`
I think it means the same as "parse_options() will do right thing" as you said to me , but...after the modification the effect is opposite:
diff --git a/builtin/notes.c b/builtin/notes.c index a6273781fb8..73427ea8dff 100644 --- a/builtin/notes.c +++ b/builtin/notes.c @@ -562,6 +562,7 @@ static int copy(int argc, const char **argv, const char *prefix) static int append_edit(int argc, const char **argv, const char *prefix) { int allow_empty = 0; + int blankline = 1; const char *object_ref; struct notes_tree *t; struct object_id object, new_note; @@ -584,6 +585,8 @@ static int append_edit(int argc, const char **argv, const char *prefix) parse_reuse_arg), OPT_BOOL(0, "allow-empty", &allow_empty, N_("allow storing empty note")), + OPT_BOOL(0, "no-blank-line", &blankline, + N_("insert paragraph break before appending to an existing note")), OPT_END() }; int edit = !strcmp(argv[0], "edit"); @@ -618,7 +621,7 @@ static int append_edit(int argc, const char **argv, const char *prefix) enum object_type type; char *prev_buf = read_object_file(note, &type, &size); - if (d.buf.len && prev_buf && size) + if (blankline && d.buf.len && prev_buf && size) strbuf_insertstr(&d.buf, 0, "\n"); if (prev_buf && size) strbuf_insert(&d.buf, 0, prev_buf, size); ---- So, I am a bit confused and I guess maybe somewhere I misunderstood or didn't notice some details. Thanks.