Skip to content
  • Elijah Newren's avatar
    rebase: reinstate --no-keep-empty · b9cbd295
    Elijah Newren authored and Junio C Hamano's avatar Junio C Hamano committed
    Commit d48e5e21
    
     ("rebase (interactive-backend): make --keep-empty the
    default", 2020-02-15) turned --keep-empty (for keeping commits which
    start empty) into the default.  The logic underpinning that commit was:
    
      1) 'git commit' errors out on the creation of empty commits without an
         override flag
      2) Once someone determines that the override is worthwhile, it's
         annoying and/or harmful to required them to take extra steps in
         order to keep such commits around (and to repeat such steps with
         every rebase).
    
    While the logic on which the decision was made is sound, the result was
    a bit of an overcorrection.  Instead of jumping to having --keep-empty
    being the default, it jumped to making --keep-empty the only available
    behavior.  There was a simple workaround, though, which was thought to
    be good enough at the time.  People could still drop commits which
    started empty the same way the could drop any commits: by firing up an
    interactive rebase and picking out the commits they didn't want from the
    list.  However, there are cases where external tools might create enough
    empty commits that picking all of them out is painful.  As such, having
    a flag to automatically remove start-empty commits may be beneficial.
    
    Provide users a way to drop commits which start empty using a flag that
    existed for years: --no-keep-empty.  Interpret --keep-empty as
    countermanding any previous --no-keep-empty, but otherwise leaving
    --keep-empty as the default.
    
    This might lead to some slight weirdness since commands like
      git rebase --empty=drop --keep-empty
      git rebase --empty=keep --no-keep-empty
    look really weird despite making perfect sense (the first will drop
    commits which become empty, but keep commits that started empty; the
    second will keep commits which become empty, but drop commits which
    started empty).  However, --no-keep-empty was named years ago and we are
    predominantly keeping it for backward compatibility; also we suspect it
    will only be used rarely since folks already have a simple way to drop
    commits they don't want with an interactive rebase.
    
    Reported-by: default avatarBryan Turner <bturner@atlassian.com>
    Reported-by: default avatarSami Boukortt <sami@boukortt.com>
    Signed-off-by: default avatarElijah Newren <newren@gmail.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    b9cbd295