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>
Junio C Hamano committed
Jan 15, 2006 at 22:15 UTC
181dc776956b4d265891ac70514ed214e4b7564a
2 files changed
+8
-5
commit.c
+4
-2
@@ -359,8 +359,10 @@ void clear_commit_marks(struct commit *commit, unsigned int mark)
359
parents = commit->parents;
360
commit->object.flags &= ~mark;
361
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);
366
parents = parents->next;
367
}
368
}
describe.c
+4
-3
@@ -98,7 +98,7 @@ static int compare_names(const void *_a, const void *_b)
98
return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
99
}
100
101
-static void describe(struct commit *cmit)
101
+static void describe(struct commit *cmit, int last_one)
102
{
103
struct commit_list *list;
104
static int initialized = 0;
@@ -124,7 +124,8 @@ static void describe(struct commit *cmit)
124
if (n) {
125
printf("%s-g%s\n", n->path,
126
find_unique_abbrev(cmit->object.sha1, abbrev));
127
- clear_commit_marks(cmit, SEEN);
127
+ if (!last_one)
128
+ clear_commit_marks(cmit, SEEN);
129
return;
130
}
131
}
@@ -159,7 +160,7 @@ int main(int argc, char **argv)
160
cmit = lookup_commit_reference(sha1);
161
if (!cmit)
162
usage(describe_usage);
162
- describe(cmit);
163
+ describe(cmit, i == argc - 1);
164
}
165
return 0;
166
}