From: Johan Herland <johan@herland.net>
To: Mike Hommey <mh@glandium.org>
Cc: Git mailing list <git@vger.kernel.org>,
Johan Herland <johan@herland.net>
Subject: [RFC/PATCHv0 4/4] fast-import.c:note_change_n(): Rename commit_* to target_*
Date: Mon, 5 Jan 2015 04:39:38 +0100 [thread overview]
Message-ID: <1420429178-20336-4-git-send-email-johan@herland.net> (raw)
In-Reply-To: <1420429178-20336-1-git-send-email-johan@herland.net>
Since we now allow adding notes to any kind of object (not just commits),
rename the related variables from "commit_*" to "target_*".
TODO: Also replace "commit-ish" with something more suitable in the
documentation. However, the same needs to be done for the 'tag' command,
and we also the BNF at the top of fast-import.c needs corresponding updates.
Signed-off-by: Johan Herland <johan@herland.net>
---
fast-import.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/fast-import.c b/fast-import.c
index b6df00b..4ef7a95 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -2451,7 +2451,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
static struct strbuf uq = STRBUF_INIT;
struct object_entry *oe;
struct branch *s;
- unsigned char sha1[20], commit_sha1[20];
+ unsigned char sha1[20], target_sha1[20];
char path[60];
uint16_t inline_data = 0;
unsigned char new_fanout;
@@ -2489,19 +2489,19 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
die("Missing space after SHA1: %s", command_buf.buf);
}
- /* <commit-ish> */
+ /* <object> */
s = lookup_branch(p);
if (s) {
if (is_null_sha1(s->sha1))
die("Can't add a note on empty branch.");
- hashcpy(commit_sha1, s->sha1);
+ hashcpy(target_sha1, s->sha1);
} else if (*p == ':') {
- uintmax_t commit_mark = parse_mark_ref_eol(p);
- struct object_entry *commit_oe = find_mark(commit_mark);
- hashcpy(commit_sha1, commit_oe->idx.sha1);
- } else if (!get_sha1(p, commit_sha1)) {
- if (!find_object(commit_sha1)) {
- if (sha1_object_info(commit_sha1, NULL) < 0)
+ uintmax_t target_mark = parse_mark_ref_eol(p);
+ struct object_entry *target_oe = find_mark(target_mark);
+ hashcpy(target_sha1, target_oe->idx.sha1);
+ } else if (!get_sha1(p, target_sha1)) {
+ if (!find_object(target_sha1)) {
+ if (sha1_object_info(target_sha1, NULL) < 0)
die("Not a valid object: %s", p);
}
} else
@@ -2527,7 +2527,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
typename(type), command_buf.buf);
}
- construct_path_with_fanout(sha1_to_hex(commit_sha1), *old_fanout, path);
+ construct_path_with_fanout(sha1_to_hex(target_sha1), *old_fanout, path);
if (tree_content_remove(&b->branch_tree, path, NULL, 0))
b->num_notes--;
@@ -2536,7 +2536,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
b->num_notes++;
new_fanout = convert_num_notes_to_fanout(b->num_notes);
- construct_path_with_fanout(sha1_to_hex(commit_sha1), new_fanout, path);
+ construct_path_with_fanout(sha1_to_hex(target_sha1), new_fanout, path);
tree_content_set(&b->branch_tree, path, sha1, S_IFREG | 0644, NULL);
}
--
2.1.1.392.g062cc5d
prev parent reply other threads:[~2015-01-05 3:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-23 0:06 fast-import's notemodify doesn't work the same as git notes Mike Hommey
2015-01-05 3:37 ` Johan Herland
2015-01-05 3:39 ` [RFC/PATCHv0 1/4] fast-import.c:do_change_note_fanout(): Remove unneeded local var 't' Johan Herland
2015-01-05 3:39 ` [RFC/PATCHv0 2/4] fast-import.c:do_change_note_fanout(): Also apply load_tree() to initial root Johan Herland
2015-01-05 3:39 ` [RFC/PATCHv0 3/4] fast-import: Support adding notes to non-commits Johan Herland
2015-01-05 3:39 ` Johan Herland [this message]
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=1420429178-20336-4-git-send-email-johan@herland.net \
--to=johan@herland.net \
--cc=git@vger.kernel.org \
--cc=mh@glandium.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 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 NNTP newsgroup(s).