Skip to content

Commit 181dc77

Browse files
author
Junio C Hamano
committed
describe: omit clearing marks on the last one.
When describing more than one, we need to clear the commit marks before handling the next one, but most of the time we are running it for only one commit, and in such a case this clearing phase is totally unnecessary. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 7cb038a commit 181dc77

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

commit.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,10 @@ void clear_commit_marks(struct commit *commit, unsigned int mark)
359359
parents = commit->parents;
360360
commit->object.flags &= ~mark;
361361
while (parents) {
362-
if (parents->item && parents->item->object.parsed)
363-
clear_commit_marks(parents->item, mark);
362+
struct commit *parent = parents->item;
363+
if (parent && parent->object.parsed &&
364+
(parent->object.flags & mark))
365+
clear_commit_marks(parent, mark);
364366
parents = parents->next;
365367
}
366368
}

describe.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static int compare_names(const void *_a, const void *_b)
9898
return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
9999
}
100100

101-
static void describe(struct commit *cmit)
101+
static void describe(struct commit *cmit, int last_one)
102102
{
103103
struct commit_list *list;
104104
static int initialized = 0;
@@ -124,7 +124,8 @@ static void describe(struct commit *cmit)
124124
if (n) {
125125
printf("%s-g%s\n", n->path,
126126
find_unique_abbrev(cmit->object.sha1, abbrev));
127-
clear_commit_marks(cmit, SEEN);
127+
if (!last_one)
128+
clear_commit_marks(cmit, SEEN);
128129
return;
129130
}
130131
}
@@ -159,7 +160,7 @@ int main(int argc, char **argv)
159160
cmit = lookup_commit_reference(sha1);
160161
if (!cmit)
161162
usage(describe_usage);
162-
describe(cmit);
163+
describe(cmit, i == argc - 1);
163164
}
164165
return 0;
165166
}

0 commit comments

Comments
 (0)