From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.0 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id C6DF51F404 for ; Sun, 28 Jan 2018 00:13:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753146AbeA1ANi (ORCPT ); Sat, 27 Jan 2018 19:13:38 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:42375 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752352AbeA1ANg (ORCPT ); Sat, 27 Jan 2018 19:13:36 -0500 Received: by mail-lf0-f67.google.com with SMTP id q17so5017968lfa.9 for ; Sat, 27 Jan 2018 16:13:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:in-reply-to :references; bh=V0ifA3oPEOS05sBUgw/zzcgOyAtZ+wqHy7M8Szjm8Fw=; b=G29aQGTBlhrNyYW1eeQRlHIe9C7K0X28PrhjauRVZiazeP1+qvA1j7h/MOzNG163GD 74iDrLxe8z32jqKe8HjsHV9pGuNXrvMj0bOepZFJIvMsyHdWzQ3cms3F06zEz/qgtFcR n9AZilmrA6A4H4UeXhMhnyS+miIqe/f6ggepkeswhkmvfjHvDE/KvYeJzlhVU+RF/69Q 8CdS57v3WsIzlP9YPqW14qHhVfLXD5OCn4TpceUVGqpEvdGbzQ7+UhiSkJ1eSEbsqmRg rj0PoJoCG7YM0qxnPlPTY4mVEAkvn23SUcBmshrVjO4QASb1FPVWgkh7o1llmsmvsRa1 G4Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=V0ifA3oPEOS05sBUgw/zzcgOyAtZ+wqHy7M8Szjm8Fw=; b=QgKo/WZLeCFDs0MD72akmv5xu/CNTD+BPgghSkUT+b3ZiaYhQhViIbbcj+pOjrStmy rfGoMj/3hfg5bV1ULA6DztjmmFZDO/EQ3JGeSeWFWnsoFRr3wmX+eYfQO4VSw0/uLsNQ ycHDlicJ6VQKtKK5Nmh/kMYVmimGoAJjXUd7qB9T5yNZXGB2uoFWnRtvfOwP3eT9APHl uFlBDWr4nPs2qNbkjHNWni2btfjssxhFacaUZJzcfcR+psxWWU1AHhn3svRQbmKn9jd/ Du/Se0PMHxv5StWbvwWp7q9ZbEljiPl4+n8eORkduV6+4GETy92qe2bww6H4piBn9cVT FlBw== X-Gm-Message-State: AKwxytdJCVsTd9fFblSJQtYesm/03659WOb0j7XPSh9pPlw8qZyS0tSh EPNMhyl84WdRq2jc69Y4D2BtXCWv X-Google-Smtp-Source: AH8x224bvCeKH5IlTeEDMNa/ajS9mPFLnxfendGXC3tWd7wOzCa+JfYHiLh4iGPqa54LDhqrYOAu1A== X-Received: by 10.25.143.12 with SMTP id r12mr11463697lfd.30.1517098414911; Sat, 27 Jan 2018 16:13:34 -0800 (PST) Received: from localhost.localdomain ([188.121.16.104]) by smtp.gmail.com with ESMTPSA id y26sm2144695lfk.30.2018.01.27.16.13.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 27 Jan 2018 16:13:33 -0800 (PST) From: Patryk Obara To: git@vger.kernel.org, Junio C Hamano , "brian m . carlson" , =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Subject: [PATCH v4 08/12] notes: convert write_notes_tree to object_id Date: Sun, 28 Jan 2018 01:13:18 +0100 Message-Id: <5e4e97a31b3cdf96e40853d48628dfcc7d7339c8.1517097306.git.patryk.obara@gmail.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Convert the definition and declaration of write_notes_tree to struct object_id and adjust usage of this function. Additionally, improve style of small part of this function, as old formatting made it hard to understand at glance what this part of code is doing. Signed-off-by: Patryk Obara --- notes-cache.c | 2 +- notes-utils.c | 2 +- notes.c | 16 +++++++++------- notes.h | 4 ++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/notes-cache.c b/notes-cache.c index d2f87147cc..010ad236cb 100644 --- a/notes-cache.c +++ b/notes-cache.c @@ -54,7 +54,7 @@ int notes_cache_write(struct notes_cache *c) if (!c->tree.dirty) return 0; - if (write_notes_tree(&c->tree, tree_oid.hash)) + if (write_notes_tree(&c->tree, &tree_oid)) return -1; if (commit_tree(c->validity, strlen(c->validity), &tree_oid, NULL, &commit_oid, NULL, NULL) < 0) diff --git a/notes-utils.c b/notes-utils.c index 058c642dac..02407fe2a7 100644 --- a/notes-utils.c +++ b/notes-utils.c @@ -12,7 +12,7 @@ void create_notes_commit(struct notes_tree *t, struct commit_list *parents, assert(t->initialized); - if (write_notes_tree(t, tree_oid.hash)) + if (write_notes_tree(t, &tree_oid)) die("Failed to write notes tree to database"); if (!parents) { diff --git a/notes.c b/notes.c index 3f4f94507a..09ef1ce33a 100644 --- a/notes.c +++ b/notes.c @@ -1123,11 +1123,12 @@ int for_each_note(struct notes_tree *t, int flags, each_note_fn fn, return for_each_note_helper(t, t->root, 0, 0, flags, fn, cb_data); } -int write_notes_tree(struct notes_tree *t, unsigned char *result) +int write_notes_tree(struct notes_tree *t, struct object_id *result) { struct tree_write_stack root; struct write_each_note_data cb_data; int ret; + int flags; if (!t) t = &default_notes_tree; @@ -1141,12 +1142,13 @@ int write_notes_tree(struct notes_tree *t, unsigned char *result) cb_data.next_non_note = t->first_non_note; /* Write tree objects representing current notes tree */ - ret = for_each_note(t, FOR_EACH_NOTE_DONT_UNPACK_SUBTREES | - FOR_EACH_NOTE_YIELD_SUBTREES, - write_each_note, &cb_data) || - write_each_non_note_until(NULL, &cb_data) || - tree_write_stack_finish_subtree(&root) || - write_sha1_file(root.buf.buf, root.buf.len, tree_type, result); + flags = FOR_EACH_NOTE_DONT_UNPACK_SUBTREES | + FOR_EACH_NOTE_YIELD_SUBTREES; + ret = for_each_note(t, flags, write_each_note, &cb_data) || + write_each_non_note_until(NULL, &cb_data) || + tree_write_stack_finish_subtree(&root) || + write_sha1_file(root.buf.buf, root.buf.len, tree_type, + result->hash); strbuf_release(&root.buf); return ret; } diff --git a/notes.h b/notes.h index 88da38b5f4..0433f45db5 100644 --- a/notes.h +++ b/notes.h @@ -217,7 +217,7 @@ int for_each_note(struct notes_tree *t, int flags, each_note_fn fn, * Write the given notes_tree structure to the object database * * Creates a new tree object encapsulating the current state of the given - * notes_tree, and stores its SHA1 into the 'result' argument. + * notes_tree, and stores its object id into the 'result' argument. * * Returns zero on success, non-zero on failure. * @@ -225,7 +225,7 @@ int for_each_note(struct notes_tree *t, int flags, each_note_fn fn, * this function has returned zero. Please also remember to create a * corresponding commit object, and update the appropriate notes ref. */ -int write_notes_tree(struct notes_tree *t, unsigned char *result); +int write_notes_tree(struct notes_tree *t, struct object_id *result); /* Flags controlling the operation of prune */ #define NOTES_PRUNE_VERBOSE 1 -- 2.14.3