Skip to content

Commit 7b69b87

Browse files
dschogitster
authored andcommitted
git log -g: Complain, but do not fail, when no reflogs are there
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>
1 parent 2d8ae40 commit 7b69b87

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

reflog-walk.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ void init_reflog_walk(struct reflog_walk_info** info)
136136
*info = xcalloc(sizeof(struct reflog_walk_info), 1);
137137
}
138138

139-
void add_reflog_for_walk(struct reflog_walk_info *info,
139+
int add_reflog_for_walk(struct reflog_walk_info *info,
140140
struct commit *commit, const char *name)
141141
{
142142
unsigned long timestamp = 0;
@@ -188,7 +188,7 @@ void add_reflog_for_walk(struct reflog_walk_info *info,
188188
}
189189
}
190190
if (!reflogs || reflogs->nr == 0)
191-
die("No reflogs found for '%s'", branch);
191+
return -1;
192192
path_list_insert(branch, &info->complete_reflogs)->util
193193
= reflogs;
194194
}
@@ -200,13 +200,14 @@ void add_reflog_for_walk(struct reflog_walk_info *info,
200200
if (commit_reflog->recno < 0) {
201201
free(branch);
202202
free(commit_reflog);
203-
return;
203+
return -1;
204204
}
205205
} else
206206
commit_reflog->recno = reflogs->nr - recno - 1;
207207
commit_reflog->reflogs = reflogs;
208208

209209
add_commit_info(commit, commit_reflog, &info->reflogs);
210+
return 0;
210211
}
211212

212213
void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)

reflog-walk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define REFLOG_WALK_H
33

44
extern void init_reflog_walk(struct reflog_walk_info** info);
5-
extern void add_reflog_for_walk(struct reflog_walk_info *info,
5+
extern int add_reflog_for_walk(struct reflog_walk_info *info,
66
struct commit *commit, const char *name);
77
extern void fake_reflog_parent(struct reflog_walk_info *info,
88
struct commit *commit);

revision.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,11 @@ static void add_pending_object_with_mode(struct rev_info *revs, struct object *o
118118
{
119119
if (revs->no_walk && (obj->flags & UNINTERESTING))
120120
die("object ranges do not make sense when not walking revisions");
121+
if (revs->reflog_info && obj->type == OBJ_COMMIT &&
122+
add_reflog_for_walk(revs->reflog_info,
123+
(struct commit *)obj, name))
124+
return;
121125
add_object_array_with_mode(obj, name, &revs->pending, mode);
122-
if (revs->reflog_info && obj->type == OBJ_COMMIT)
123-
add_reflog_for_walk(revs->reflog_info,
124-
(struct commit *)obj, name);
125126
}
126127

127128
void add_pending_object(struct rev_info *revs, struct object *obj, const char *name)

0 commit comments

Comments
 (0)