summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 71b9979)
raw | patch | inline | side by side (parent: 71b9979)
author | Karl Hasselström <kha@treskal.com> | |
Fri, 8 Aug 2008 20:48:23 +0000 (22:48 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 11 Aug 2008 08:35:47 +0000 (01:35 -0700) |
Into a first half that determines what operation to do, and a second
half that does it.
Currently the only operation is diffing one or more commits, but a
later patch will add diffing of trees, at which point this refactoring
will pay off.
Signed-off-by: Karl Hasselström <kha@treskal.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
half that does it.
Currently the only operation is diffing one or more commits, but a
later patch will add diffing of trees, at which point this refactoring
will pay off.
Signed-off-by: Karl Hasselström <kha@treskal.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-diff-tree.c | patch | blob | history |
diff --git a/builtin-diff-tree.c b/builtin-diff-tree.c
index 415cb1612f5322da89850874ba81885e41808678..ebbd6317c3b2a38a79a9e8f6605a6596a5d9d45e 100644 (file)
--- a/builtin-diff-tree.c
+++ b/builtin-diff-tree.c
return log_tree_commit(&log_tree_opt, commit);
}
-static int diff_tree_stdin(char *line)
+/* Diff one or more commits. */
+static int stdin_diff_commit(struct commit *commit, char *line, int len)
{
- int len = strlen(line);
unsigned char sha1[20];
- struct commit *commit;
-
- if (!len || line[len-1] != '\n')
- return -1;
- line[len-1] = 0;
- if (get_sha1_hex(line, sha1))
- return -1;
- commit = lookup_commit(sha1);
- if (!commit || parse_commit(commit))
- return -1;
if (isspace(line[40]) && !get_sha1_hex(line+41, sha1)) {
/* Graft the fake parents locally to the commit */
int pos = 41;
return log_tree_commit(&log_tree_opt, commit);
}
+static int diff_tree_stdin(char *line)
+{
+ int len = strlen(line);
+ unsigned char sha1[20];
+ struct commit *commit;
+
+ if (!len || line[len-1] != '\n')
+ return -1;
+ line[len-1] = 0;
+ if (get_sha1_hex(line, sha1))
+ return -1;
+ commit = lookup_commit(sha1);
+ if (!commit || parse_commit(commit))
+ return -1;
+ return stdin_diff_commit(commit, line, len);
+}
+
static const char diff_tree_usage[] =
"git diff-tree [--stdin] [-m] [-c] [--cc] [-s] [-v] [--pretty] [-t] [-r] [--root] "
"[<common diff options>] <tree-ish> [<tree-ish>] [<path>...]\n"