Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15

Re: [RFC PATCH] commit -v: strip diffs and submodule shortlogs from the commit message

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:59:16

Possibly related (same subject, not in this thread)

Jeff King [off-list ref] writes:
I found this hard to parse, I think because of the "keeping" (why would
I not keep it?), and because you are talking about lines above and
below. It is not as accurate to say:

  # ------------------ >8 --------------------
  # Everything below this line will be removed.

because it is technically the line above that is the cutoff. But I think
the meaning is clear, and it is simpler to parse.

I do think it would be simpler with a single line. I know handling the
i18n was a question there, but I think we should be fine as long as we
check for the exact bytes we wrote. Surely gettext can do something
like:

  magic = _("# Everything below this line will be removed");
  fprintf(fh, "%s", magic);
  ...
  p = strstr(magic);

I don't know what guarantees on string lifetime gettext gives us, but
the worst case is that we simply strdup the result.

I suppose it's possible that the translated string could have utf8 with
multiple representations, and the user's editor normalizes the text in a
different way than we wrote it when it saves the result. I don't know if
that is worth caring about or not; it seems kind of insane.
I agree with your rewording suggestion.  It might make it even more
robust to do something like

    const char cut_here[] = "# --- cut here --- >8 --- cut here ---";

    fprintf(fh, "%s\n", cut_here);
    fputs(_("# Everything below this line will be removed\n"), fh);
    ...
    p = strstr(cut_here);

i.e. a real marker line that will never be translated, with an
explanation immediately below that can be translated.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help