Code

git log -g: Complain, but do not fail, when no reflogs are there
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>
Mon, 23 Jul 2007 23:39:50 +0000 (00:39 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Jul 2007 00:28:10 +0000 (17:28 -0700)
When asking "git log -g --all", clearly you want to see only those refs
that do have reflogs, but you do not want it to fail, either.

So instead of die()ing, complain about it, but move on to the other refs.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reflog-walk.c
reflog-walk.h
revision.c

index c983858259f717b3ed9d0f00921aec92219c1ad3..ee1456b45a2e1bfe08564400c12015889e57cf12 100644 (file)
@@ -136,7 +136,7 @@ void init_reflog_walk(struct reflog_walk_info** info)
        *info = xcalloc(sizeof(struct reflog_walk_info), 1);
 }
 
-void add_reflog_for_walk(struct reflog_walk_info *info,
+int add_reflog_for_walk(struct reflog_walk_info *info,
                struct commit *commit, const char *name)
 {
        unsigned long timestamp = 0;
@@ -188,7 +188,7 @@ void add_reflog_for_walk(struct reflog_walk_info *info,
                        }
                }
                if (!reflogs || reflogs->nr == 0)
-                       die("No reflogs found for '%s'", branch);
+                       return -1;
                path_list_insert(branch, &info->complete_reflogs)->util
                        = reflogs;
        }
@@ -200,13 +200,14 @@ void add_reflog_for_walk(struct reflog_walk_info *info,
                if (commit_reflog->recno < 0) {
                        free(branch);
                        free(commit_reflog);
-                       return;
+                       return -1;
                }
        } else
                commit_reflog->recno = reflogs->nr - recno - 1;
        commit_reflog->reflogs = reflogs;
 
        add_commit_info(commit, commit_reflog, &info->reflogs);
+       return 0;
 }
 
 void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)
index a4f7015d3e77b7f59ac5bf1e01713b8d277bc879..7ca1438f4d74b652f962c6bdfddd08fe0d75802d 100644 (file)
@@ -2,7 +2,7 @@
 #define REFLOG_WALK_H
 
 extern void init_reflog_walk(struct reflog_walk_info** info);
-extern void add_reflog_for_walk(struct reflog_walk_info *info,
+extern int add_reflog_for_walk(struct reflog_walk_info *info,
                struct commit *commit, const char *name);
 extern void fake_reflog_parent(struct reflog_walk_info *info,
                struct commit *commit);
index 16f35c7c18713aab991f04f6dcb787a73d15957d..038693caba69a9274b632510c9ee8a14a87b6eee 100644 (file)
@@ -118,10 +118,11 @@ static void add_pending_object_with_mode(struct rev_info *revs, struct object *o
 {
        if (revs->no_walk && (obj->flags & UNINTERESTING))
                die("object ranges do not make sense when not walking revisions");
+       if (revs->reflog_info && obj->type == OBJ_COMMIT &&
+                       add_reflog_for_walk(revs->reflog_info,
+                               (struct commit *)obj, name))
+               return;
        add_object_array_with_mode(obj, name, &revs->pending, mode);
-       if (revs->reflog_info && obj->type == OBJ_COMMIT)
-               add_reflog_for_walk(revs->reflog_info,
-                               (struct commit *)obj, name);
 }
 
 void add_pending_object(struct rev_info *revs, struct object *obj, const char *name)