git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] log: decorate "replaced" on to replaced commits

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Aug 19, 2011, 12:43 UTC
Message-ID
<1313757830-30640-1-git-send-email-pclouds@gmail.com>
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
Previous: Junio C Hamano
Message 14 of 14 in “log: decorate grafted commits with "grafted"”
  1. log: decorate grafted commits with "grafted"Nguyễn Thái Ngọc Duy, Aug 17, 2011
  2. Junio C HamanoAug 17, 2011
  3. Nguyen Thai Ngoc DuyAug 18, 2011
  4. 0/5 Decorate grafts and replacesNguyễn Thái Ngọc Duy, Aug 18, 2011
  5. 1/5 decoration: do not mis-decorate refs with same prefixNguyễn Thái Ngọc Duy, Aug 18, 2011
  6. Junio C HamanoAug 18, 2011
  7. 2/5 Add for_each_commit_graft() to iterate all graftsNguyễn Thái Ngọc Duy, Aug 18, 2011
  8. 3/5 Move write_shallow_commits to fetch-pack.cNguyễn Thái Ngọc Duy, Aug 18, 2011
  9. Junio C HamanoAug 18, 2011
  10. 4/5 log: decorate grafted commits with "grafted"Nguyễn Thái Ngọc Duy, Aug 18, 2011
  11. Junio C HamanoAug 18, 2011
  12. 5/5 log: decorate "replaced" on to replaced commitsNguyễn Thái Ngọc Duy, Aug 18, 2011
  13. Junio C HamanoAug 18, 2011
  14. log: decorate "replaced" on to replaced commitsNguyễn Thái Ngọc Duy, Aug 19, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.