From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH] log: decorate "replaced" on to replaced commits
Date: Fri, 19 Aug 2011 19:43:50 +0700 [thread overview]
Message-ID: <1313757830-30640-1-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <7vippua433.fsf@alter.siamese.dyndns.org>
Old code also decorates "new" commits with "refs/replace/SHA1". This
is now gone, but I guess no one will miss it.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
2011/8/19 Junio C Hamano <gitster@pobox.com>:
> If the argument is "we know only commits and tags are listed and blobs and
> trees are not shown with --decorate option" and "excluding the decoration
> that we know will never be used will avoid bloating the decorate hashtable
> with unused cruft", then add_name_decoration() should be doing the check
> for all of its callers, not just this one, no?
Makes sense. Moreover replacing blobs and trees are generally not safe.
If people do that, they may have more issues to worry about than this.
Let's keep it simple. We can fix add_name_decoration() later if it becomes
a real problem.
log-tree.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/log-tree.c b/log-tree.c
index e945701..d73e69c 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -92,8 +92,22 @@ static void add_name_decoration(enum decoration_type type, const char *name, str
static int add_ref_decoration(const char *refname, const unsigned char *sha1, int flags, void *cb_data)
{
- struct object *obj = parse_object(sha1);
+ struct object *obj;
enum decoration_type type = DECORATION_NONE;
+
+ if (!prefixcmp(refname, "refs/replace/")) {
+ unsigned char original_sha1[20];
+ if (get_sha1_hex(refname + 13, original_sha1)) {
+ warning("invalid replace ref %s", refname);
+ return 0;
+ }
+ obj = parse_object(original_sha1);
+ if (obj)
+ add_name_decoration(DECORATION_GRAFTED, "replaced", obj);
+ return 0;
+ }
+
+ obj = parse_object(sha1);
if (!obj)
return 0;
--
1.7.4.74.g639db
prev parent reply other threads:[~2011-08-19 12:44 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-17 15:02 [PATCH] log: decorate grafted commits with "grafted" Nguyễn Thái Ngọc Duy
2011-08-17 18:48 ` Junio C Hamano
2011-08-18 2:02 ` Nguyen Thai Ngoc Duy
2011-08-18 12:29 ` [PATCH v2 0/5] Decorate grafts and replaces Nguyễn Thái Ngọc Duy
2011-08-18 12:29 ` [PATCH 1/5] decoration: do not mis-decorate refs with same prefix Nguyễn Thái Ngọc Duy
2011-08-18 17:58 ` Junio C Hamano
2011-08-18 12:29 ` [PATCH 2/5] Add for_each_commit_graft() to iterate all grafts Nguyễn Thái Ngọc Duy
2011-08-18 12:29 ` [PATCH 3/5] Move write_shallow_commits to fetch-pack.c Nguyễn Thái Ngọc Duy
2011-08-18 18:01 ` Junio C Hamano
2011-08-18 12:29 ` [PATCH 4/5] log: decorate grafted commits with "grafted" Nguyễn Thái Ngọc Duy
2011-08-18 18:10 ` Junio C Hamano
2011-08-18 12:29 ` [PATCH 5/5] log: decorate "replaced" on to replaced commits Nguyễn Thái Ngọc Duy
2011-08-18 18:16 ` Junio C Hamano
2011-08-19 12:43 ` Nguyễn Thái Ngọc Duy [this message]
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=1313757830-30640-1-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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 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 NNTP newsgroup(s).