line-log: convert to using diff_tree_sha1()

Since diff_tree_sha1() can now accept empty trees via NULL sha1, we could just call it without manually reading trees into tree_desc and duplicating code. Cc: Thomas Rast <tr@thomasrast.ch> Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Kirill Smelkov committed Feb 5, 2014 at 20:57 UTC 7bc4ec01dde22be0156d64ef77db7364a11cb859
1 file changed +2 -24
line-log.c
+2 -24
@@ -766,16 +766,6 @@ void line_log_init(struct rev_info *rev, const char *prefix, struct string_list
766 }
767 }
768
769 -static void load_tree_desc(struct tree_desc *desc, void **tree,
770 - const unsigned char *sha1)
771 -{
772 - unsigned long size;
773 - *tree = read_object_with_reference(sha1, tree_type, &size, NULL);
774 - if (!*tree)
775 - die("Unable to read tree (%s)", sha1_to_hex(sha1));
776 - init_tree_desc(desc, *tree, size);
777 -}
778 -
769 static int count_parents(struct commit *commit)
770 {
771 struct commit_list *parents = commit->parents;
@@ -842,18 +832,11 @@ static void queue_diffs(struct line_log_data *range,
832 struct diff_queue_struct *queue,
833 struct commit *commit, struct commit *parent)
834 {
845 - void *tree1 = NULL, *tree2 = NULL;
846 - struct tree_desc desc1, desc2;
847 -
835 assert(commit);
849 - load_tree_desc(&desc2, &tree2, commit->tree->object.sha1);
850 - if (parent)
851 - load_tree_desc(&desc1, &tree1, parent->tree->object.sha1);
852 - else
853 - init_tree_desc(&desc1, "", 0);
836
837 DIFF_QUEUE_CLEAR(&diff_queued_diff);
856 - diff_tree(&desc1, &desc2, "", opt);
838 + diff_tree_sha1(parent ? parent->tree->object.sha1 : NULL,
839 + commit->tree->object.sha1, "", opt);
840 if (opt->detect_rename) {
841 filter_diffs_for_paths(range, 1);
842 if (diff_might_be_rename())
@@ -861,11 +844,6 @@ static void queue_diffs(struct line_log_data *range,
844 filter_diffs_for_paths(range, 0);
845 }
846 move_diff_queue(queue, &diff_queued_diff);
864 -
865 - if (tree1)
866 - free(tree1);
867 - if (tree2)
868 - free(tree2);
847 }
848
849 static char *get_nth_line(long line, unsigned long *ends, void *data)