summaryrefslogtreecommitdiff
path: root/fast-import.c
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2018-11-16 07:59:56 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-11-17 09:43:52 (GMT)
commita965bb31166d04f3e5c8f7a93569fb73f9a9d749 (patch)
tree385913d97dba601ccc48903a5867bb54b92c5a60 /fast-import.c
parent25dd3e4889a41a1ee40fbf961209e55d208382f0 (diff)
downloadgit-a965bb31166d04f3e5c8f7a93569fb73f9a9d749.zip
git-a965bb31166d04f3e5c8f7a93569fb73f9a9d749.tar.gz
git-a965bb31166d04f3e5c8f7a93569fb73f9a9d749.tar.bz2
fast-export: add a --show-original-ids option to show original names
Knowing the original names (hashes) of commits can sometimes enable post-filtering that would otherwise be difficult or impossible. In particular, the desire to rewrite commit messages which refer to other prior commits (on top of whatever other filtering is being done) is very difficult without knowing the original names of each commit. In addition, knowing the original names (hashes) of blobs can allow filtering by blob-id without requiring re-hashing the content of the blob, and is thus useful as a small optimization. Once we add original ids for both commits and blobs, we may as well add them for tags too for completeness. Perhaps someone will have a use for them. This commit teaches a new --show-original-ids option to fast-export which will make it add a 'original-oid <hash>' line to blob, commits, and tags. It also teaches fast-import to parse (and ignore) such lines. Signed-off-by: Elijah Newren <newren@gmail.com> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fast-import.c')
-rw-r--r--fast-import.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/fast-import.c b/fast-import.c
index 555d49a..71b6cba 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1814,6 +1814,13 @@ static void parse_mark(void)
next_mark = 0;
}
+static void parse_original_identifier(void)
+{
+ const char *v;
+ if (skip_prefix(command_buf.buf, "original-oid ", &v))
+ read_next_command();
+}
+
static int parse_data(struct strbuf *sb, uintmax_t limit, uintmax_t *len_res)
{
const char *data;
@@ -1956,6 +1963,7 @@ static void parse_new_blob(void)
{
read_next_command();
parse_mark();
+ parse_original_identifier();
parse_and_store_blob(&last_blob, NULL, next_mark);
}
@@ -2579,6 +2587,7 @@ static void parse_new_commit(const char *arg)
read_next_command();
parse_mark();
+ parse_original_identifier();
if (skip_prefix(command_buf.buf, "author ", &v)) {
author = parse_ident(v);
read_next_command();
@@ -2711,6 +2720,9 @@ static void parse_new_tag(const char *arg)
die("Invalid ref name or SHA1 expression: %s", from);
read_next_command();
+ /* original-oid ... */
+ parse_original_identifier();
+
/* tagger ... */
if (skip_prefix(command_buf.buf, "tagger ", &v)) {
tagger = parse_ident(v);