Skip to content

Commit 69020d0

Browse files
derrickstoleegitster
authored andcommitted
commit: add gentle reference lookup method
The lookup_commit_reference_by_name() method uses lookup_commit_reference() without an option to use lookup_commit_reference_gently(). Create a gentle version of the method so it can be used in locations where non-commits may be found but error messages should be silenced. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e32eaf7 commit 69020d0

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

commit.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,19 @@ struct commit *lookup_commit(struct repository *r, const struct object_id *oid)
8484
}
8585

8686
struct commit *lookup_commit_reference_by_name(const char *name)
87+
{
88+
return lookup_commit_reference_by_name_gently(name, 0);
89+
}
90+
91+
struct commit *lookup_commit_reference_by_name_gently(const char *name,
92+
int quiet)
8793
{
8894
struct object_id oid;
8995
struct commit *commit;
9096

9197
if (repo_get_oid_committish(the_repository, name, &oid))
9298
return NULL;
93-
commit = lookup_commit_reference(the_repository, &oid);
99+
commit = lookup_commit_reference_gently(the_repository, &oid, quiet);
94100
if (repo_parse_commit(the_repository, commit))
95101
return NULL;
96102
return commit;

commit.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ struct commit *lookup_commit_reference_gently(struct repository *r,
8181
const struct object_id *oid,
8282
int quiet);
8383
struct commit *lookup_commit_reference_by_name(const char *name);
84+
struct commit *lookup_commit_reference_by_name_gently(const char *name,
85+
int quiet);
8486

8587
/*
8688
* Look up object named by "oid", dereference tag as necessary,

0 commit comments

Comments
 (0)