• Jens Lehmann's avatar
    commit -v: strip diffs and submodule shortlogs from the commit message · 1a72cfd7
    Jens Lehmann authored
    When using the '-v' option of "git commit" the diff added to the commit
    message temporarily for editing is stripped off after the user exited the
    editor by searching for "\ndiff --git " and truncating the commmit message
    there if it is found.
    But this approach has two problems:
    - when the commit message itself contains a line starting with
      "diff --git" it will be truncated there prematurely; and
    - when the "diff.submodule" setting is set to "log", the diff may
      start with "Submodule <hash1>..<hash2>", which will be left in
      the commit message while it shouldn't.
    Fix that by introducing a special scissor separator line starting with the
    comment character ('#' or the core.commentChar config if set) followed by
    two lines describing what it is for. The scissor line - which will not be
    translated - is used to reliably detect the start of the diff so it can be
    chopped off from the commit message, no matter what the user enters there.
    Turn a known test failure fixed by this change into a successful test;
    also add one for a diff starting with a submodule log and another one for
    proper handling of the comment char.
    Reported-by: default avatarAri Pollak <[email protected]>
    Signed-off-by: default avatarJens Lehmann <[email protected]>
    Signed-off-by: default avatarJunio C Hamano <[email protected]>
wt-status.h 2.6 KB