Thread (20 messages) flat view 20 messages, 3 authors, 2017-02-25
STALE3458d

[PATCH 0/3] delete_ref(): support reflog messages

From: Kyle Meyer <hidden>
Date: 2017-02-17 03:58:41

[Sorry for the slow response.]

Jeff King [off-list ref] writes:
On Mon, Jan 16, 2017 at 06:17:29PM -0500, Kyle Meyer wrote:
[...]
quoted
   $ cat .git/logs/refs/heads/new-master
   00000... 68730... Kyle Meyer [off-list ref] 1484607020 -0500	commit (initial): Add file.txt
   68730... 68730... Kyle Meyer [off-list ref] 1484607020 -0500	Branch: renamed refs/heads/master to refs/heads/new-master

   $ cat .git/logs/HEAD
   00000... 68730... Kyle Meyer [off-list ref] 1484607020 -0500	commit (initial): Add file.txt
   68730... 00000... Kyle Meyer [off-list ref] 1484607020 -0500

I expected the second line of .git/logs/HEAD to mirror the second line
of .git/logs/refs/heads/new-master.  Are the empty message and null sha1
in HEAD's entry intentional?
The null sha1 is correct, I think. The branch we were on went away, and
we use the null sha1 to indicate "no value" in both the creation and
deletion cases.
I see, thanks.
I'd say there are two potential improvements:

  - delete_ref() should take a reflog message argument, in case it
    updates the HEAD reflog (as a bonus, this will future-proof us for a
    day when we might keep reflogs for deleted refs).
I've tried to do this in the following patches.
  - "git branch -m" does seem to realize when we are renaming HEAD,
    because it updates HEAD to point to the new branch name. But it
    should probably insert another reflog entry mentioning the rename
    (we do for "git checkout foo", even when "foo" has the same sha1 as
    the current HEAD).
I haven't worked out how to do this part yet.  I'm guessing the change
will involve modifying split_head_update().

If this is added, should it be instead of, rather than in addition to,
the deletion entry?  If a "Branch: renamed ..." entry is present, it
doesn't seem like the deletion entry is providing any additional
information.

  delete_refs(): accept a reflog message argument
  update-ref: pass reflog message argument to delete_refs
  rename_ref: replace empty deletion message in HEAD's log

 builtin/am.c           |  4 ++--
 builtin/branch.c       |  2 +-
 builtin/notes.c        |  4 ++--
 builtin/remote.c       |  4 ++--
 builtin/replace.c      |  2 +-
 builtin/reset.c        |  2 +-
 builtin/symbolic-ref.c |  2 +-
 builtin/tag.c          |  2 +-
 builtin/update-ref.c   |  2 +-
 fast-import.c          |  2 +-
 refs.c                 |  4 ++--
 refs.h                 |  2 +-
 refs/files-backend.c   | 12 +++++++++---
 t/t1400-update-ref.sh  |  9 +++++++++
 t/t3200-branch.sh      |  4 ++++
 transport.c            |  2 +-
 16 files changed, 39 insertions(+), 20 deletions(-)

-- 
Kyle
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help