Skip to content

Commit d998a08

Browse files
Pavel RoskinJunio C Hamano
Pavel Roskin
authored and
Junio C Hamano
committed
[PATCH] Fix "prefix" mixup in git-rev-list
Recent changes in git have broken cg-log. git-rev-list no longer prints "commit" in front of commit hashes. It turn out a local "prefix" variable in main() shadows a file-scoped "prefix" variable. The patch removed the local "prefix" variable since its value is never used (in the intended way, that is). The call to setup_git_directory() is kept since it has useful side effects. The file-scoped "prefix" variable is renamed to "commit_prefix" just in case someone reintroduces "prefix" to hold the return value of setup_git_directory(). Signed-off-by: Pavel Roskin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ff84d32 commit d998a08

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

rev-list.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static int blob_objects = 0;
3333
static int verbose_header = 0;
3434
static int show_parents = 0;
3535
static int hdr_termination = 0;
36-
static const char *prefix = "";
36+
static const char *commit_prefix = "";
3737
static unsigned long max_age = -1;
3838
static unsigned long min_age = -1;
3939
static int max_count = -1;
@@ -48,14 +48,14 @@ static void show_commit(struct commit *commit)
4848
{
4949
commit->object.flags |= SHOWN;
5050
if (show_breaks) {
51-
prefix = "| ";
51+
commit_prefix = "| ";
5252
if (commit->object.flags & DISCONTINUITY) {
53-
prefix = "^ ";
53+
commit_prefix = "^ ";
5454
} else if (commit->object.flags & BOUNDARY) {
55-
prefix = "= ";
55+
commit_prefix = "= ";
5656
}
5757
}
58-
printf("%s%s", prefix, sha1_to_hex(commit->object.sha1));
58+
printf("%s%s", commit_prefix, sha1_to_hex(commit->object.sha1));
5959
if (show_parents) {
6060
struct commit_list *parents = commit->parents;
6161
while (parents) {
@@ -481,9 +481,9 @@ static void handle_one_commit(struct commit *com, struct commit_list **lst)
481481
int main(int argc, char **argv)
482482
{
483483
struct commit_list *list = NULL;
484-
const char *prefix = setup_git_directory();
485484
int i, limited = 0;
486485

486+
setup_git_directory();
487487
for (i = 1 ; i < argc; i++) {
488488
int flags;
489489
char *arg = argv[i];
@@ -511,9 +511,9 @@ int main(int argc, char **argv)
511511
verbose_header = 1;
512512
hdr_termination = '\n';
513513
if (commit_format == CMIT_FMT_ONELINE)
514-
prefix = "";
514+
commit_prefix = "";
515515
else
516-
prefix = "commit ";
516+
commit_prefix = "commit ";
517517
continue;
518518
}
519519
if (!strncmp(arg, "--no-merges", 11)) {

0 commit comments

Comments
 (0)