unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* git replace --edit for updating commit messages (was: Is it time to drop ChangeLogs?)
@ 2016-07-28  1:35 Noam Postavsky
  2016-07-28  8:07 ` git replace --edit for updating commit messages Andreas Schwab
  2016-07-28 14:43 ` git replace --edit for updating commit messages (was: Is it time to drop ChangeLogs?) Eli Zaretskii
  0 siblings, 2 replies; 6+ messages in thread
From: Noam Postavsky @ 2016-07-28  1:35 UTC (permalink / raw)
  To: Sven Axelsson; +Cc: Robert Weiner, Stefan Monnier, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 2119 bytes --]

On Wed, Jul 13, 2016 at 1:47 PM, Sven Axelsson <sven.axelsson@gmail.com> wrote:
>> Yes, this is a common need and Git should be changed to allow editing
>> of commit log entries even though this could be said to change the
>> state of the prior releases.
>
>
> A couple of months ago it was suggested to use `git replace --edit` for
> that.
> Did anyone try it out to see if it could be used in the Emacs workflow?

There were some questions raised, the 2 main ones were

1. How to deal with the fact git replace is powerful enough to replace
the actual content of the commit.

This is easy enough to stop with a hook, see attached pre-receive.

2. Performance implications of having many replacements.

This appears to be a more serious problem. The git replace command
creates a ref per replacement. Since we expect our number of
replacements to be some fraction of the commits, we could end up with
quite a few. To get a sense of the worst case timing I wrote a script
to replace the message of every commit in the repository with an
upcased SHOUTY version. After running it on an Emacs repo clone, my
.git/refs/replace directory was 8.5M in size. I tried git pack-refs
--all which emptied the the replace directory, and resulted in a 12M
packed-refs file.

Doing git log became dramatically slower (packing the refs did not
make much difference).

Original repository:

~/src/emacs/emacs-master$ time git log --oneline | wc -l
126614

real    0m5.435s
user    0m3.157s
sys    0m2.780s

~/src/emacs/emacs-master$ time git log --oneline | head >/dev/null

real    0m0.009s
user    0m0.003s
sys    0m0.003s


Repository with all commit messages replaced: (almost all, there were
a few messages that lacked letters, so my upcasing script had no
effect)

~/src/emacs/emacs-clone$ time git log --oneline | wc -l
126614

real    0m49.337s
user    0m8.270s
sys    0m39.680s

~/src/emacs/emacs-clone$ time git log --oneline | head >/dev/null

real    0m0.520s
user    0m0.237s
sys    0m0.250s


I attached the scripts used (upcase-commit-message.sh and
git-replace-all.sh), in case anyone wants to replicate my experiments.

[-- Attachment #2: pre-receive --]
[-- Type: application/octet-stream, Size: 470 bytes --]

#!/bin/sh

# Print hashes of tree and parent.  This is the data we don't want to
# allow replacements for.
commit_data () {
    git --no-replace-objects show --no-patch --format='%T:%P' "$@"
}

while read old new name ; do
    case $name in
        (refs/replace/*)
            if [ "$(commit_data $(basename $name))" != "$(commit_data $new)" ] ; then
                echo "$name changes commit diff/parentage!" >&2
                exit 1
            fi;;
    esac
done

[-- Attachment #3: upcase-commit-message.sh --]
[-- Type: application/x-sh, Size: 94 bytes --]

[-- Attachment #4: git-replace-all.sh --]
[-- Type: application/x-sh, Size: 171 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-08-03  6:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-28  1:35 git replace --edit for updating commit messages (was: Is it time to drop ChangeLogs?) Noam Postavsky
2016-07-28  8:07 ` git replace --edit for updating commit messages Andreas Schwab
2016-08-02 23:37   ` John Wiegley
2016-08-03  6:49     ` Andreas Schwab
2016-07-28 14:43 ` git replace --edit for updating commit messages (was: Is it time to drop ChangeLogs?) Eli Zaretskii
2016-07-30 23:18   ` Noam Postavsky

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).