summaryrefslogtreecommitdiff
path: root/rev-list.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-29 17:40:14 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-29 17:40:14 (GMT)
commit3c90f03d3206cb2c2bff6e20f7477bbfcd624887 (patch)
tree45d3b105b21e13927424d55d47c425b1ce1300cc /rev-list.c
parente06eb4c6f50ece75f210a91bfcb776e537aafaae (diff)
downloadgit-3c90f03d3206cb2c2bff6e20f7477bbfcd624887.zip
git-3c90f03d3206cb2c2bff6e20f7477bbfcd624887.tar.gz
git-3c90f03d3206cb2c2bff6e20f7477bbfcd624887.tar.bz2
Prepare git-rev-list for tracking tag objects too
We want to be able to just say "give a difference between these objects", rather than limiting it to commits only. This isn't there yet, but it sets things up to be a bit easier.
Diffstat (limited to 'rev-list.c')
-rw-r--r--rev-list.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/rev-list.c b/rev-list.c
index bf61b74..ca8cc92 100644
--- a/rev-list.c
+++ b/rev-list.c
@@ -19,6 +19,7 @@ static const char rev_list_usage[] =
" --merge-order [ --show-breaks ]";
static int bisect_list = 0;
+static int tag_objects = 0;
static int tree_objects = 0;
static int blob_objects = 0;
static int verbose_header = 0;
@@ -307,6 +308,20 @@ struct commit_list *limit_list(struct commit_list *list)
return newlist;
}
+static struct commit *get_commit_reference(const char *name, unsigned int flags)
+{
+ unsigned char sha1[20];
+ struct commit *commit;
+
+ if (get_sha1(name, sha1))
+ usage(rev_list_usage);
+ commit = lookup_commit_reference(sha1);
+ if (!commit || parse_commit(commit) < 0)
+ die("bad commit object %s", name);
+ commit->object.flags |= flags;
+ return commit;
+}
+
int main(int argc, char **argv)
{
struct commit_list *list = NULL;
@@ -315,7 +330,6 @@ int main(int argc, char **argv)
for (i = 1 ; i < argc; i++) {
int flags;
char *arg = argv[i];
- unsigned char sha1[20];
struct commit *commit;
if (!strncmp(arg, "--max-count=", 12)) {
@@ -350,6 +364,7 @@ int main(int argc, char **argv)
continue;
}
if (!strcmp(arg, "--objects")) {
+ tag_objects = 1;
tree_objects = 1;
blob_objects = 1;
continue;
@@ -369,12 +384,11 @@ int main(int argc, char **argv)
arg++;
limited = 1;
}
- if (get_sha1(arg, sha1) || (show_breaks && !merge_order))
+ if (show_breaks && !merge_order)
usage(rev_list_usage);
- commit = lookup_commit_reference(sha1);
- if (!commit || parse_commit(commit) < 0)
- die("bad commit object %s", arg);
- commit->object.flags |= flags;
+ commit = get_commit_reference(arg, flags);
+ if (!commit)
+ continue;
commit_list_insert(commit, &list);
}