Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
read-cache: refactor read_index_from()
author
Christian Couder
<christian.couder@gmail.com>
Mon, 6 Mar 2017 09:42:00 +0000
(10:42 +0100)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 6 Mar 2017 20:09:28 +0000
(12:09 -0800)
It looks better and is simpler to review when we don't compute
the same things many times in the function.
It will also help make the following commit simpler.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
read-cache.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
c0441f7
)
diff --git
a/read-cache.c
b/read-cache.c
index 39002bc1b13ac298b76750fc00e533305f869cdd..ace3fc515b8c85c751e003b4ae66a86468cc6fdc 100644
(file)
--- a/
read-cache.c
+++ b/
read-cache.c
@@
-1699,6
+1699,8
@@
int read_index_from(struct index_state *istate, const char *path)
{
struct split_index *split_index;
int ret;
{
struct split_index *split_index;
int ret;
+ char *base_sha1_hex;
+ const char *base_path;
/* istate->initialized covers both .git/index and .git/sharedindex.xxx */
if (istate->initialized)
/* istate->initialized covers both .git/index and .git/sharedindex.xxx */
if (istate->initialized)
@@
-1716,15
+1718,15
@@
int read_index_from(struct index_state *istate, const char *path)
discard_index(split_index->base);
else
split_index->base = xcalloc(1, sizeof(*split_index->base));
discard_index(split_index->base);
else
split_index->base = xcalloc(1, sizeof(*split_index->base));
- ret = do_read_index(split_index->base,
- git_path("sharedindex.%s",
- sha1_to_hex(split_index->base_sha1)), 1);
+
+ base_sha1_hex = sha1_to_hex(split_index->base_sha1);
+ base_path = git_path("sharedindex.%s", base_sha1_hex);
+ ret = do_read_index(split_index->base, base_path, 1);
if (hashcmp(split_index->base_sha1, split_index->base->sha1))
die("broken index, expect %s in %s, got %s",
if (hashcmp(split_index->base_sha1, split_index->base->sha1))
die("broken index, expect %s in %s, got %s",
- sha1_to_hex(split_index->base_sha1),
- git_path("sharedindex.%s",
- sha1_to_hex(split_index->base_sha1)),
+ base_sha1_hex, base_path,
sha1_to_hex(split_index->base->sha1));
sha1_to_hex(split_index->base->sha1));
+
merge_base_index(istate);
post_read_index_from(istate);
return ret;
merge_base_index(istate);
post_read_index_from(istate);
return ret;