git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC/PATCHv0 4/4] fast-import.c:note_change_n(): Rename commit_* to target_*

From
Johan Herland <johan@herland.net>
Date
Jan 5, 2015, 03:39 UTC
Message-ID
<1420429178-20336-4-git-send-email-johan@herland.net>
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
Previous: Johan Herland
Message 5 of 5 in “Re: fast-import's notemodify doesn't work the same as git notes”
  1. Johan HerlandJan 5, 2015
  2. 1/4 fast-import.c:do_change_note_fanout(): Remove unneeded local var 't'Johan Herland, Jan 5, 2015
  3. 2/4 fast-import.c:do_change_note_fanout(): Also apply load_tree() to initial rootJohan Herland, Jan 5, 2015
  4. 3/4 fast-import: Support adding notes to non-commitsJohan Herland, Jan 5, 2015
  5. 4/4 fast-import.c:note_change_n(): Rename commit_* to target_*Johan Herland, Jan 5, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.