Merge branch 'mp/for-each-ref-missing-name-or-email'
[gitweb.git] / builtin / rev-list.c
index 9f31837d303f1f302266fdd03298ddce73867ba0..301ccb970bb36340bc6b4a136a3029811f252aa2 100644 (file)
@@ -49,6 +49,7 @@ static const char rev_list_usage[] =
 "    --objects | --objects-edge\n"
 "    --unpacked\n"
 "    --header | --pretty\n"
+"    --[no-]object-names\n"
 "    --abbrev=<n> | --no-abbrev\n"
 "    --abbrev-commit\n"
 "    --left-right\n"
@@ -75,9 +76,12 @@ enum missing_action {
 };
 static enum missing_action arg_missing_action;
 
+/* display only the oid of each object encountered */
+static int arg_show_object_names = 1;
+
 #define DEFAULT_OIDSET_SIZE     (16*1024)
 
-static void finish_commit(struct commit *commit, void *data);
+static void finish_commit(struct commit *commit);
 static void show_commit(struct commit *commit, void *data)
 {
        struct rev_list_info *info = data;
@@ -86,7 +90,7 @@ static void show_commit(struct commit *commit, void *data)
        display_progress(progress, ++progress_counter);
 
        if (info->flags & REV_LIST_QUIET) {
-               finish_commit(commit, data);
+               finish_commit(commit);
                return;
        }
 
@@ -99,7 +103,7 @@ static void show_commit(struct commit *commit, void *data)
                        revs->count_left++;
                else
                        revs->count_right++;
-               finish_commit(commit, data);
+               finish_commit(commit);
                return;
        }
 
@@ -188,10 +192,10 @@ static void show_commit(struct commit *commit, void *data)
                        putchar('\n');
        }
        maybe_flush_or_die(stdout, "stdout");
-       finish_commit(commit, data);
+       finish_commit(commit);
 }
 
-static void finish_commit(struct commit *commit, void *data)
+static void finish_commit(struct commit *commit)
 {
        if (commit->parents) {
                free_commit_list(commit->parents);
@@ -255,7 +259,10 @@ static void show_object(struct object *obj, const char *name, void *cb_data)
        display_progress(progress, ++progress_counter);
        if (info->flags & REV_LIST_QUIET)
                return;
-       show_object_with_name(stdout, obj, name);
+       if (arg_show_object_names)
+               show_object_with_name(stdout, obj, name);
+       else
+               printf("%s\n", oid_to_hex(&obj->oid));
 }
 
 static void show_edge(struct commit *commit)
@@ -484,6 +491,16 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
                if (skip_prefix(arg, "--missing=", &arg))
                        continue; /* already handled above */
 
+               if (!strcmp(arg, ("--no-object-names"))) {
+                       arg_show_object_names = 0;
+                       continue;
+               }
+
+               if (!strcmp(arg, ("--object-names"))) {
+                       arg_show_object_names = 1;
+                       continue;
+               }
+
                usage(rev_list_usage);
 
        }