Add "--all" flag to rev-parse that shows all refs

And make git-rev-list just silently ignore non-commit refs if we're not
asking for all objects.
This commit is contained in:
Linus Torvalds 2005-07-03 13:07:52 -07:00
Родитель dade09c226
Коммит 960bba0d8c
2 изменённых файлов: 14 добавлений и 3 удалений

Просмотреть файл

@ -377,7 +377,7 @@ static struct commit *get_commit_reference(const char *name, unsigned int flags)
if (object->type == tree_type) { if (object->type == tree_type) {
struct tree *tree = (struct tree *)object; struct tree *tree = (struct tree *)object;
if (!tree_objects) if (!tree_objects)
die("%s is a tree object, not a commit", name); return NULL;
if (flags & UNINTERESTING) { if (flags & UNINTERESTING) {
mark_tree_uninteresting(tree); mark_tree_uninteresting(tree);
return NULL; return NULL;
@ -392,7 +392,7 @@ static struct commit *get_commit_reference(const char *name, unsigned int flags)
if (object->type == blob_type) { if (object->type == blob_type) {
struct blob *blob = (struct blob *)object; struct blob *blob = (struct blob *)object;
if (!blob_objects) if (!blob_objects)
die("%s is a blob object, not a commit", name); return NULL;
if (flags & UNINTERESTING) { if (flags & UNINTERESTING) {
mark_blob_uninteresting(blob); mark_blob_uninteresting(blob);
return NULL; return NULL;

Просмотреть файл

@ -5,6 +5,7 @@
*/ */
#include "cache.h" #include "cache.h"
#include "commit.h" #include "commit.h"
#include "refs.h"
static char *def = NULL; static char *def = NULL;
static int no_revs = 0; static int no_revs = 0;
@ -46,7 +47,7 @@ static int is_rev_argument(const char *arg)
} }
} }
static void show_rev(int type, unsigned char *sha1) static void show_rev(int type, const unsigned char *sha1)
{ {
if (no_revs) if (no_revs)
return; return;
@ -142,6 +143,12 @@ static void show_default(void)
} }
} }
static int show_reference(const char *refname, const unsigned char *sha1)
{
show_rev(NORMAL, sha1);
return 0;
}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int i, as_is = 0; int i, as_is = 0;
@ -185,6 +192,10 @@ int main(int argc, char **argv)
show_type ^= REVERSED; show_type ^= REVERSED;
continue; continue;
} }
if (!strcmp(arg, "--all")) {
for_each_ref(show_reference);
continue;
}
show_arg(arg); show_arg(arg);
continue; continue;
} }