From: Johannes Schindelin <johannes.schindelin@gmx.de>
To: git@vger.kernel.org
Cc: Johannes Schindelin <johannes.schindelin@gmx.de>,
Junio C Hamano <gitster@pobox.com>,
Alban Gruin <alban.gruin@gmail.com>,
Pratik Karki <predatoramigo@gmail.com>,
Christian Couder <christian.couder@gmail.com>,
Stefan Beller <sbeller@google.com>,
Wink Saville <wink@saville.com>
Subject: [PATCH v2 1/6] sequencer: extract helper to update active_cache_tree
Date: Fri, 4 May 2018 01:01:15 +0200 [thread overview]
Message-ID: <ad31aab8e735f7de813860cacb32abbc406f43d1.1525388472.git.johannes.schindelin@gmx.de> (raw)
In-Reply-To: <cover.1525388472.git.johannes.schindelin@gmx.de>
This patch extracts the code from is_index_unchanged() to initialize or
update the index' cache tree (i.e. a tree object reflecting the current
index' top-level tree).
The new helper will be used in the upcoming code to support `git rebase
-i --root` via the sequencer.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
sequencer.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/sequencer.c b/sequencer.c
index e2f83942843..90c8218aa9a 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -562,9 +562,23 @@ static int do_recursive_merge(struct commit *base, struct commit *next,
return !clean;
}
+static struct object_id *get_cache_tree_oid(void)
+{
+ if (!active_cache_tree)
+ active_cache_tree = cache_tree();
+
+ if (!cache_tree_fully_valid(active_cache_tree))
+ if (cache_tree_update(&the_index, 0)) {
+ error(_("unable to update cache tree"));
+ return NULL;
+ }
+
+ return &active_cache_tree->oid;
+}
+
static int is_index_unchanged(void)
{
- struct object_id head_oid;
+ struct object_id head_oid, *cache_tree_oid;
struct commit *head_commit;
if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, &head_oid, NULL))
@@ -583,15 +597,10 @@ static int is_index_unchanged(void)
if (parse_commit(head_commit))
return -1;
- if (!active_cache_tree)
- active_cache_tree = cache_tree();
-
- if (!cache_tree_fully_valid(active_cache_tree))
- if (cache_tree_update(&the_index, 0))
- return error(_("unable to update cache tree"));
+ if (!(cache_tree_oid = get_cache_tree_oid()))
+ return -1;
- return !oidcmp(&active_cache_tree->oid,
- &head_commit->tree->object.oid);
+ return !oidcmp(cache_tree_oid, &head_commit->tree->object.oid);
}
static int write_author_script(const char *message)
--
2.17.0.windows.1.38.g05ca542f78d
next prev parent reply other threads:[~2018-05-03 23:01 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-27 22:29 [PATCH 0/6] Let the sequencer handle `git rebase -i --root` Johannes Schindelin
2018-04-27 22:30 ` [PATCH 1/6] sequencer: extract helper to update active_cache_tree Johannes Schindelin
2018-04-28 15:28 ` Stefan Beller
2018-04-27 22:31 ` [PATCH 2/6] sequencer: learn about the special "fake root commit" handling Johannes Schindelin
2018-04-28 16:11 ` Stefan Beller
2018-04-29 12:33 ` Johannes Schindelin
2018-04-29 21:44 ` Stefan Beller
2018-04-27 22:31 ` [PATCH 3/6] rebase -i --root: let the sequencer handle even the initial part Johannes Schindelin
2018-04-28 16:19 ` Stefan Beller
2018-04-29 12:34 ` Johannes Schindelin
2018-04-27 22:31 ` [PATCH 4/6] sequencer: allow introducing new root commits Johannes Schindelin
2018-04-27 22:31 ` [PATCH 5/6] rebase --rebase-merges: a "merge" into a new root is a fast-forward Johannes Schindelin
2018-04-27 22:31 ` [PATCH 6/6] rebase --rebase-merges: root commits can be cousins, too Johannes Schindelin
2018-05-03 23:01 ` [PATCH v2 0/6] Let the sequencer handle `git rebase -i --root` Johannes Schindelin
2018-05-03 23:01 ` Johannes Schindelin [this message]
2018-05-03 23:01 ` [PATCH v2 2/6] sequencer: learn about the special "fake root commit" handling Johannes Schindelin
2018-05-03 23:01 ` [PATCH v2 3/6] rebase -i --root: let the sequencer handle even the initial part Johannes Schindelin
2018-05-03 23:01 ` [PATCH v2 4/6] sequencer: allow introducing new root commits Johannes Schindelin
2018-05-03 23:01 ` [PATCH v2 5/6] rebase --rebase-merges: a "merge" into a new root is a fast-forward Johannes Schindelin
2018-05-03 23:01 ` [PATCH v2 6/6] rebase --rebase-merges: root commits can be cousins, too Johannes Schindelin
2018-05-04 19:55 ` [PATCH v2 0/6] Let the sequencer handle `git rebase -i --root` Stefan Beller
2018-05-05 19:24 ` Johannes Schindelin
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ad31aab8e735f7de813860cacb32abbc406f43d1.1525388472.git.johannes.schindelin@gmx.de \
--to=johannes.schindelin@gmx.de \
--cc=alban.gruin@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=predatoramigo@gmail.com \
--cc=sbeller@google.com \
--cc=wink@saville.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).