# [PATCH] git log -g: Complain, but do not fail, when no reflogs are there

7 messages from 2007-07-23 to 2007-07-24. Participants: Johannes Schindelin, Junio C Hamano, Alex Riesen.
Thread: https://gitlist.dev/t/9188

## Johannes Schindelin, 2007-07-23 23:39

Subject: [PATCH] git log -g: Complain, but do not fail, when no reflogs are there
Message-ID: <Pine.LNX.4.64.0707240039300.14781@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0707240039300.14781%40racer.site

```

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>
---
 reflog-walk.c |    7 ++++---
 reflog-walk.h |    2 +-
 revision.c    |    7 ++++---
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/reflog-walk.c b/reflog-walk.c
index c983858..7809fad 100644
--- a/reflog-walk.c
+++ b/reflog-walk.c
@@ -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 error("No reflogs found for '%s'", branch);
 		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 error("No reflog found for '%s'", name);
 		}
 	} 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)
diff --git a/reflog-walk.h b/reflog-walk.h
index a4f7015..7ca1438 100644
--- a/reflog-walk.h
+++ b/reflog-walk.h
@@ -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);
diff --git a/revision.c b/revision.c
index 16f35c7..038693c 100644
--- a/revision.c
+++ b/revision.c
@@ -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)
-- 
1.5.3.rc2.31.gf7d7-dirty

```

## Junio C Hamano, 2007-07-24 05:37

Subject: Re: [PATCH] git log -g: Complain, but do not fail, when no reflogs are there
Message-ID: <7vbqe2jr9m.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vbqe2jr9m.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <Pine.LNX.4.64.0707240039300.14781@racer.site>

```
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> 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.

Hmph, do we even want to error(), I wonder...

Can you tell, at that point, if there were explicit branch
names given originally on the command line, or the refs came
from --all?

```

## Alex Riesen, 2007-07-24 07:26

Subject: Re: [PATCH] git log -g: Complain, but do not fail, when no reflogs are there
Message-ID: <81b0412b0707240026v4321a709wcbbbd7b67a4c506b@mail.gmail.com>
URL: https://gitlist.dev/e/81b0412b0707240026v4321a709wcbbbd7b67a4c506b%40mail.gmail.com
In-Reply-To: <Pine.LNX.4.64.0707240039300.14781@racer.site>

```
On 7/24/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
>
> 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.
>

I believe you wont even see these complaints: the pager will start shortly
afterwards and fill the screen with commits, completely hiding the errors.

```

## Johannes Schindelin, 2007-07-24 09:14

Subject: Re: [PATCH] git log -g: Complain, but do not fail, when no reflogs are there
Message-ID: <Pine.LNX.4.64.0707241011090.14781@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0707241011090.14781%40racer.site
In-Reply-To: <7vbqe2jr9m.fsf@assigned-by-dhcp.cox.net>

```
Hi,

On Mon, 23 Jul 2007, Junio C Hamano wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > 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.
> 
> Hmph, do we even want to error(), I wonder...

Maybe not.  I thought it was some useful information, though.

> Can you tell, at that point, if there were explicit branch names given 
> originally on the command line, or the refs came
> from --all?

No:

                        if (!strcmp(arg, "--all")) {
                                handle_all(revs, flags);
                                continue;
                        }

which calls

static void handle_all(struct rev_info *revs, unsigned flags)
{
        struct all_refs_cb cb;
        cb.all_revs = revs;
        cb.all_flags = flags;
        for_each_ref(handle_one_ref, &cb);
}

which in turn calls

static int handle_one_ref(const char *path, const unsigned char *sha1, int flag,
 void *cb_data)
{
        struct all_refs_cb *cb = cb_data;
        struct object *object = get_reference(cb->all_revs, path, sha1,
                                              cb->all_flags);
        add_pending_object(cb->all_revs, object, path);
        return 0;
}

If you do not say --all, handle_revision_arg() is called, which calls 
add_pending_object thus:

                        add_pending_object(revs, &a->object, this);
                        add_pending_object(revs, &b->object, next);

or thus

        add_pending_object_with_mode(revs, object, arg, mode);

So no, there is not really a chance to see how the refs were specified at 
the time add_pending_object() is called.

Ciao,
Dscho

```

## Johannes Schindelin, 2007-07-24 09:16

Subject: Re: [PATCH] git log -g: Complain, but do not fail, when no reflogs are there
Message-ID: <Pine.LNX.4.64.0707241014500.14781@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0707241014500.14781%40racer.site
In-Reply-To: <81b0412b0707240026v4321a709wcbbbd7b67a4c506b@mail.gmail.com>

```
Hi,

On Tue, 24 Jul 2007, Alex Riesen wrote:

> On 7/24/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > 
> > 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.
> > 
> 
> I believe you wont even see these complaints: the pager will start shortly
> afterwards and fill the screen with commits, completely hiding the errors.

You can see it briefly, but it is hidden by default.  Which is a good 
thing.  If you set the pager to "cat" (which is happily not the default!) 
you can see them clearly.  Until you are swamped by the rest of the 
output.

Maybe this is a feature?

Ciao,
Dscho

```

## Alex Riesen, 2007-07-24 10:17

Subject: Re: [PATCH] git log -g: Complain, but do not fail, when no reflogs are there
Message-ID: <81b0412b0707240317q56e42a9bs44eb3e5ef9e796c6@mail.gmail.com>
URL: https://gitlist.dev/e/81b0412b0707240317q56e42a9bs44eb3e5ef9e796c6%40mail.gmail.com
In-Reply-To: <Pine.LNX.4.64.0707241014500.14781@racer.site>

```
On 7/24/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> On Tue, 24 Jul 2007, Alex Riesen wrote:
> > On 7/24/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > >
> > > 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.
> > >
> >
> > I believe you wont even see these complaints: the pager will start shortly
> > afterwards and fill the screen with commits, completely hiding the errors.
>
> You can see it briefly, but it is hidden by default.  Which is a good
> thing.  If you set the pager to "cat" (which is happily not the default!)
> you can see them clearly.  Until you are swamped by the rest of the
> output.
>
> Maybe this is a feature?
>

Maybe. I can't see it at all. Should I downgrade something or propose
a patch to put some delay after this error? I think not.

I think second Junios suggestion, but this is of course no
difference to me.

```

## Johannes Schindelin, 2007-07-24 11:11

Subject: Re: [PATCH] git log -g: Complain, but do not fail, when no reflogs are there
Message-ID: <Pine.LNX.4.64.0707241210170.14781@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0707241210170.14781%40racer.site
In-Reply-To: <81b0412b0707240317q56e42a9bs44eb3e5ef9e796c6@mail.gmail.com>

```
Hi,

On Tue, 24 Jul 2007, Alex Riesen wrote:

> On 7/24/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > On Tue, 24 Jul 2007, Alex Riesen wrote:
> > > On 7/24/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > > >
> > > > 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.
> > > >
> > >
> > > I believe you wont even see these complaints: the pager will start shortly
> > > afterwards and fill the screen with commits, completely hiding the errors.
> > 
> > You can see it briefly, but it is hidden by default.  Which is a good
> > thing.  If you set the pager to "cat" (which is happily not the default!)
> > you can see them clearly.  Until you are swamped by the rest of the
> > output.
> > 
> > Maybe this is a feature?
> > 
> 
> Maybe. I can't see it at all. Should I downgrade something or propose
> a patch to put some delay after this error? I think not.
> 
> I think second Junios suggestion, but this is of course no
> difference to me.

Okay, two votes are enough to make me reconsider.  Junio, could you please 
replace the two "error(...)"s by "-1"s?  Only if you apply the patch, of 
course...

Ciao,
Dscho

```
