From: Junio C Hamano <junkio@cox.net>
To: "Lars Hjemli" <lh@elementstorage.no>
Cc: git@vger.kernel.org, "Shawn Pearce" <spearce@spearce.org>
Subject: Re: [RFC] Teach git-branch howto rename a branch
Date: Sat, 25 Nov 2006 02:35:09 -0800 [thread overview]
Message-ID: <7vd57b3jc2.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <8c5c35580611250116h466e3649p2630ee6641b6e6f4@mail.gmail.com> (Lars Hjemli's message of "Sat, 25 Nov 2006 10:16:19 +0100")
"Lars Hjemli" <lh@elementstorage.no> writes:
> Is it ok to put
>
> static int log_ref_write(struct ref_lock *lock,
> const unsigned char *sha1, const char *msg)
>
> into refs.h?
I think a cleaner implementation that does not have such a
layering violation would involve defining rename_refs()
interface in refs.c, next to the delete_ref() that exists there.
The division of labor would be for builtin-branch.c to make sure
both oldname and newname are branch names, and rename_refs() to
rename the reflog (if exists) and the ref at the same time. To
deal with D/F conflicts sanely, I suspect it would involve a
call to rename(2) to move the reflog to a temporary location,
perhaps $GIT_DIR/.tmp-renamed-log, deletion of the old ref by
calling delete_ref(), and then another rename(2) to move that
temporary one to its final location, followed by the usual "ref
creation dance" of calling lock_any_ref_for_update() and
write_ref_sha1().
Side note:
If we do not mind losing the reflog of oldname, then "delete and
then create" would be sufficient, but that is not the case.
Unlike "git does not track individual files so we do not record
renames" mantra, branches, and more in general, refs, have
meaningful identity (at least locally), and unlike the file
contents, the "contents" of a ref does not migrate _partially_
from ref to ref. It would make sense to keep track of renames
for them.
next prev parent reply other threads:[~2006-11-25 10:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-24 23:03 [RFC] Teach git-branch howto rename a branch Lars Hjemli
2006-11-25 5:40 ` Junio C Hamano
2006-11-25 6:49 ` Shawn Pearce
2006-11-25 8:53 ` Jakub Narebski
2006-11-25 8:57 ` Shawn Pearce
2006-11-25 9:16 ` Lars Hjemli
2006-11-25 10:35 ` Junio C Hamano [this message]
2006-11-25 10:52 ` Lars Hjemli
2006-11-25 7:12 ` [PATCH] git-branch -D: make it work even when on a yet-to-be-born branch Junio C Hamano
2006-11-25 8:52 ` [RFC] Teach git-branch howto rename a branch Lars Hjemli
2006-11-25 10:39 ` Fredrik Kuivinen
2006-11-25 11:00 ` Lars Hjemli
2006-11-26 23:56 ` Josef Weidendorfer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vd57b3jc2.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=lh@elementstorage.no \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.