From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 4/8] resolve-undo.c: dump "REUC" extension as json
Date: Wed, 19 Jun 2019 16:58:54 +0700 [thread overview]
Message-ID: <20190619095858.30124-5-pclouds@gmail.com> (raw)
In-Reply-To: <20190619095858.30124-1-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
read-cache.c | 2 +-
resolve-undo.c | 36 +++++++++++++++++++++++++++++++++++-
resolve-undo.h | 4 +++-
3 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/read-cache.c b/read-cache.c
index eec030b3bb..3b5c63f53a 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1701,7 +1701,7 @@ static int read_index_extension(struct index_state *istate,
istate->cache_tree = cache_tree_read(data, sz);
break;
case CACHE_EXT_RESOLVE_UNDO:
- istate->resolve_undo = resolve_undo_read(data, sz);
+ istate->resolve_undo = resolve_undo_read(data, sz, istate->jw);
break;
case CACHE_EXT_LINK:
if (read_link_extension(istate, data, sz))
diff --git a/resolve-undo.c b/resolve-undo.c
index 236320f179..999020bc40 100644
--- a/resolve-undo.c
+++ b/resolve-undo.c
@@ -1,5 +1,6 @@
#include "cache.h"
#include "dir.h"
+#include "json-writer.h"
#include "resolve-undo.h"
#include "string-list.h"
@@ -49,7 +50,8 @@ void resolve_undo_write(struct strbuf *sb, struct string_list *resolve_undo)
}
}
-struct string_list *resolve_undo_read(const char *data, unsigned long size)
+struct string_list *resolve_undo_read(const char *data, unsigned long size,
+ struct json_writer *jw)
{
struct string_list *resolve_undo;
size_t len;
@@ -59,6 +61,11 @@ struct string_list *resolve_undo_read(const char *data, unsigned long size)
resolve_undo = xcalloc(1, sizeof(*resolve_undo));
resolve_undo->strdup_strings = 1;
+ if (jw) {
+ jw_object_inline_begin_object(jw, "resolve-undo");
+ jw_object_intmax(jw, "ext-size", size);
+ jw_object_inline_begin_array(jw, "entries");
+ }
while (size) {
struct string_list_item *lost;
@@ -94,6 +101,33 @@ struct string_list *resolve_undo_read(const char *data, unsigned long size)
size -= rawsz;
data += rawsz;
}
+
+ if (jw) {
+ struct strbuf sb = STRBUF_INIT;
+
+ jw_array_inline_begin_object(jw);
+ jw_object_string(jw, "path", lost->string);
+
+ jw_object_inline_begin_array(jw, "mode");
+ for (i = 0; i < 3; i++) {
+ strbuf_addf(&sb, "%06o", ui->mode[i]);
+ jw_array_string(jw, sb.buf);
+ strbuf_reset(&sb);
+ }
+ jw_end(jw);
+
+ jw_object_inline_begin_array(jw, "oid");
+ for (i = 0; i < 3; i++)
+ jw_array_string(jw, oid_to_hex(&ui->oid[i]));
+ jw_end(jw);
+
+ jw_end(jw);
+ strbuf_release(&sb);
+ }
+ }
+ if (jw) {
+ jw_end(jw); /* entries */
+ jw_end(jw); /* resolve-undo */
}
return resolve_undo;
diff --git a/resolve-undo.h b/resolve-undo.h
index 2b3f0f901e..46b4e93a7e 100644
--- a/resolve-undo.h
+++ b/resolve-undo.h
@@ -3,6 +3,8 @@
#include "cache.h"
+struct json_writer;
+
struct resolve_undo_info {
unsigned int mode[3];
struct object_id oid[3];
@@ -10,7 +12,7 @@ struct resolve_undo_info {
void record_resolve_undo(struct index_state *, struct cache_entry *);
void resolve_undo_write(struct strbuf *, struct string_list *);
-struct string_list *resolve_undo_read(const char *, unsigned long);
+struct string_list *resolve_undo_read(const char *, unsigned long, struct json_writer *);
void resolve_undo_clear_index(struct index_state *);
int unmerge_index_entry_at(struct index_state *, int);
void unmerge_index(struct index_state *, const struct pathspec *);
--
2.22.0.rc0.322.g2b0371e29a
next prev parent reply other threads:[~2019-06-19 9:59 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-19 9:58 [PATCH 0/8] Add 'ls-files --json' to dump the index in json Nguyễn Thái Ngọc Duy
2019-06-19 9:58 ` [PATCH 1/8] ls-files: add --json to dump the index Nguyễn Thái Ngọc Duy
2019-06-19 10:30 ` Ævar Arnfjörð Bjarmason
2019-06-19 13:03 ` Derrick Stolee
2019-06-21 13:04 ` Johannes Schindelin
2019-06-24 12:50 ` Duy Nguyen
2019-06-19 9:58 ` [PATCH 2/8] split-index.c: dump "link" extension as json Nguyễn Thái Ngọc Duy
2019-06-19 9:58 ` [PATCH 3/8] fsmonitor.c: dump "FSMN" " Nguyễn Thái Ngọc Duy
2019-06-19 9:58 ` Nguyễn Thái Ngọc Duy [this message]
2019-06-19 13:16 ` [PATCH 4/8] resolve-undo.c: dump "REUC" " Derrick Stolee
2019-06-19 9:58 ` [PATCH 5/8] read-cache.c: dump "EOIE" " Nguyễn Thái Ngọc Duy
2019-06-19 9:58 ` [PATCH 6/8] read-cache.c: dump "IEOT" " Nguyễn Thái Ngọc Duy
2019-06-19 13:18 ` Derrick Stolee
2019-06-19 13:24 ` Duy Nguyen
2019-06-19 14:26 ` Derrick Stolee
2019-06-19 9:58 ` [PATCH 7/8] cache-tree.c: dump "TREE" " Nguyễn Thái Ngọc Duy
2019-06-19 9:58 ` [PATCH 8/8] dir.c: dump "UNTR" " Nguyễn Thái Ngọc Duy
2019-06-19 11:58 ` [PATCH 0/8] Add 'ls-files --json' to dump the index in json Derrick Stolee
2019-06-19 12:42 ` Duy Nguyen
2019-06-19 12:48 ` Derrick Stolee
2019-06-19 19:17 ` Jeff King
2019-06-21 8:37 ` Duy Nguyen
2019-06-21 20:48 ` Jeff King
2019-06-21 13:16 ` Johannes Schindelin
2019-06-21 13:49 ` Duy Nguyen
2019-06-21 15:10 ` Junio C Hamano
2019-06-21 20:52 ` Jeff King
2019-06-24 9:35 ` Johannes Schindelin
2019-06-24 9:33 ` Johannes Schindelin
2019-06-24 9:35 ` Duy Nguyen
2019-06-21 20:51 ` Jeff King
2019-06-24 9:52 ` Johannes Schindelin
2019-06-20 4:00 ` Junio C Hamano
2019-06-20 19:12 ` Jeff Hostetler
2019-06-21 23:30 ` brian m. carlson
2019-06-22 2:54 ` Duy Nguyen
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=20190619095858.30124-5-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.