summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 72276a3)
raw | patch | inline | side by side (parent: 72276a3)
author | Junio C Hamano <gitster@pobox.com> | |
Thu, 3 Apr 2008 05:17:53 +0000 (22:17 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 13 Apr 2008 02:41:29 +0000 (19:41 -0700) |
After parsing the command line, we have a long loop to compute the commit
object to start annotating from. Move the logic to a separate function,
so that later patches become easier to read.
It also makes fill_origin_blob() return void; the check is always done
on !file->ptr, and nobody looks at the return value from the function.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
object to start annotating from. Move the logic to a separate function,
so that later patches become easier to read.
It also makes fill_origin_blob() return void; the check is always done
on !file->ptr, and nobody looks at the return value from the function.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-blame.c | patch | blob | history |
diff --git a/builtin-blame.c b/builtin-blame.c
index bfd562d7d2b897ad4ab3d35dda33701e315b7d5d..996f5357676fab39ef27e0aa3d37b49c882e0819 100644 (file)
--- a/builtin-blame.c
+++ b/builtin-blame.c
* Given an origin, prepare mmfile_t structure to be used by the
* diff machinery
*/
-static char *fill_origin_blob(struct origin *o, mmfile_t *file)
+static void fill_origin_blob(struct origin *o, mmfile_t *file)
{
if (!o->file.ptr) {
enum object_type type;
}
else
*file = o->file;
- return file->ptr;
}
/*
return git_default_config(var, value);
}
+/*
+ * Prepare a dummy commit that represents the work tree (or staged) item.
+ * Note that annotating work tree item never works in the reverse.
+ */
static struct commit *fake_working_tree_commit(const char *path, const char *contents_from)
{
struct commit *commit;
@@ -2122,6 +2125,33 @@ static struct commit *fake_working_tree_commit(const char *path, const char *con
return commit;
}
+static const char *prepare_final(struct scoreboard *sb, struct rev_info *revs)
+{
+ int i;
+ const char *final_commit_name = NULL;
+
+ /*
+ * There must be one and only one positive commit in the
+ * revs->pending array.
+ */
+ for (i = 0; i < revs->pending.nr; i++) {
+ struct object *obj = revs->pending.objects[i].item;
+ if (obj->flags & UNINTERESTING)
+ continue;
+ while (obj->type == OBJ_TAG)
+ obj = deref_tag(obj, NULL, 0);
+ if (obj->type != OBJ_COMMIT)
+ die("Non commit %s?", revs->pending.objects[i].name);
+ if (sb->final)
+ die("More than one commit to dig from %s and %s?",
+ revs->pending.objects[i].name,
+ final_commit_name);
+ sb->final = (struct commit *) obj;
+ final_commit_name = revs->pending.objects[i].name;
+ }
+ return final_commit_name;
+}
+
int cmd_blame(int argc, const char **argv, const char *prefix)
{
struct rev_info revs;
setup_revisions(unk, argv, &revs, NULL);
memset(&sb, 0, sizeof(sb));
- /*
- * There must be one and only one positive commit in the
- * revs->pending array.
- */
- for (i = 0; i < revs.pending.nr; i++) {
- struct object *obj = revs.pending.objects[i].item;
- if (obj->flags & UNINTERESTING)
- continue;
- while (obj->type == OBJ_TAG)
- obj = deref_tag(obj, NULL, 0);
- if (obj->type != OBJ_COMMIT)
- die("Non commit %s?",
- revs.pending.objects[i].name);
- if (sb.final)
- die("More than one commit to dig from %s and %s?",
- revs.pending.objects[i].name,
- final_commit_name);
- sb.final = (struct commit *) obj;
- final_commit_name = revs.pending.objects[i].name;
- }
-
+ final_commit_name = prepare_final(&sb, &revs);
if (!sb.final) {
/*
* "--not A B -- path" without anything positive;