From: Johan Herland Date: Mon, 05 Jan 2015 03:39:37 GMT Subject: [RFC/PATCHv0 3/4] fast-import: Support adding notes to non-commits Message-ID: <1420429178-20336-3-git-send-email-johan@herland.net> In-Reply-To: <1420429178-20336-1-git-send-email-johan@herland.net> "git notes" allows adding notes to non-commit objects, but fast-import restricts the 'notemodify' command to only add notes for commit objects. Remove that silly restriction from fast-import. Suggested-by: Mike Hommey Signed-off-by: Johan Herland --- fast-import.c | 12 ++++------ t/t9301-fast-import-notes.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 8 deletions(-) diff --git a/fast-import.c b/fast-import.c index aa7b64e..b6df00b 100644 --- a/fast-import.c +++ b/fast-import.c @@ -2498,16 +2498,12 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa } else if (*p == ':') { uintmax_t commit_mark = parse_mark_ref_eol(p); struct object_entry *commit_oe = find_mark(commit_mark); - if (commit_oe->type != OBJ_COMMIT) - die("Mark :%" PRIuMAX " not a commit", commit_mark); hashcpy(commit_sha1, commit_oe->idx.sha1); } else if (!get_sha1(p, commit_sha1)) { - unsigned long size; - char *buf = read_object_with_reference(commit_sha1, - commit_type, &size, commit_sha1); - if (!buf || size < 46) - die("Not a valid commit: %s", p); - free(buf); + if (!find_object(commit_sha1)) { + if (sha1_object_info(commit_sha1, NULL) < 0) + die("Not a valid object: %s", p); + } } else die("Invalid ref name or SHA1 expression: %s", p); diff --git a/t/t9301-fast-import-notes.sh b/t/t9301-fast-import-notes.sh index 83acf68..b8ff673 100755 --- a/t/t9301-fast-import-notes.sh +++ b/t/t9301-fast-import-notes.sh @@ -679,4 +679,60 @@ test_expect_success "add notes to $num_commits commits in each of $num_notes_ref ' +tree4=$(git rev-parse refs/heads/master^{tree}) +blob4=$(git rev-parse refs/heads/master:bar) + +test_tick +cat >input < $GIT_COMMITTER_DATE +data <expect && + git notes --ref noncommits show $tree4 >actual && + test_cmp expect actual && + echo 'note for blob object' >expect && + git notes --ref noncommits show $blob4 >actual && + test_cmp expect actual + +" + +test_tick +cat >input < $GIT_COMMITTER_DATE +data <