Commit 2417344cc53b6a209f122d9506f0f6070110e5db

Stefan Sperling 2019-08-23T13:19:31

tweak the way 'got tag -l' displays tagged objectsI

diff --git a/got/got.c b/got/got.c
index 091fe91..7f0160e 100644
--- a/got/got.c
+++ b/got/got.c
@@ -3346,32 +3346,32 @@ list_tags(struct got_repository *repo, struct got_worktree *worktree)
 		free(id);
 		if (err)
 			break;
+		printf("from: %s\n", got_object_tag_get_tagger(tag));
+		tagger_time = got_object_tag_get_tagger_time(tag);
+		datestr = get_datestr(&tagger_time, datebuf);
+		if (datestr)
+			printf("date: %s UTC\n", datestr);
 		err = got_object_id_str(&id_str,
 		    got_object_tag_get_object_id(tag));
 		if (err)
 			break;
 		switch (got_object_tag_get_object_type(tag)) {
 		case GOT_OBJ_TYPE_BLOB:
-			printf("%s: %s\n", GOT_OBJ_LABEL_BLOB, id_str);
+			printf("object: %s %s\n", GOT_OBJ_LABEL_BLOB, id_str);
 			break;
 		case GOT_OBJ_TYPE_TREE:
-			printf("%s: %s\n", GOT_OBJ_LABEL_TREE, id_str);
+			printf("object: %s %s\n", GOT_OBJ_LABEL_TREE, id_str);
 			break;
 		case GOT_OBJ_TYPE_COMMIT:
-			printf("%s: %s\n", GOT_OBJ_LABEL_COMMIT, id_str);
+			printf("object: %s %s\n", GOT_OBJ_LABEL_COMMIT, id_str);
 			break;
 		case GOT_OBJ_TYPE_TAG:
-			printf("%s: %s\n", GOT_OBJ_LABEL_TAG, id_str);
+			printf("object: %s %s\n", GOT_OBJ_LABEL_TAG, id_str);
 			break;
 		default:
 			break;
 		}
 		free(id_str);
-		printf("from: %s\n", got_object_tag_get_tagger(tag));
-		tagger_time = got_object_tag_get_tagger_time(tag);
-		datestr = get_datestr(&tagger_time, datebuf);
-		if (datestr)
-			printf("date: %s UTC\n", datestr);
 		tagmsg0 = strdup(got_object_tag_get_message(tag));
 		got_object_tag_close(tag);
 		if (tagmsg0 == NULL) {
diff --git a/regress/cmdline/tag.sh b/regress/cmdline/tag.sh
index 6662a98..053f3a2 100755
--- a/regress/cmdline/tag.sh
+++ b/regress/cmdline/tag.sh
@@ -145,18 +145,18 @@ function test_tag_list {
 	echo "-----------------------------------------------" \
 		> $testroot/stdout.expected
 	echo "tag $tag $tag_id" >> $testroot/stdout.expected
-	echo "commit: $commit_id" >> $testroot/stdout.expected
 	echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
 	echo "date: $d1" >> $testroot/stdout.expected
+	echo "object: commit $commit_id" >> $testroot/stdout.expected
 	echo " " >> $testroot/stdout.expected
 	echo " test" >> $testroot/stdout.expected
 	echo " " >> $testroot/stdout.expected
 	echo "-----------------------------------------------" \
 		>> $testroot/stdout.expected
 	echo "tag $tag2 $tag_id2" >> $testroot/stdout.expected
-	echo "commit: $commit_id" >> $testroot/stdout.expected
 	echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
 	echo "date: $d2" >> $testroot/stdout.expected
+	echo "object: commit $commit_id" >> $testroot/stdout.expected
 	echo " " >> $testroot/stdout.expected
 	echo " test" >> $testroot/stdout.expected
 	echo " " >> $testroot/stdout.expected