@@ -190,17 +190,14 @@ static void find_short_packed_object(struct disambiguate_state *ds)
190190 unique_in_pack (p , ds );
191191}
192192
193- #define SHORT_NAME_NOT_FOUND (-1)
194- #define SHORT_NAME_AMBIGUOUS (-2)
195-
196193static int finish_object_disambiguation (struct disambiguate_state * ds ,
197194 struct object_id * oid )
198195{
199196 if (ds -> ambiguous )
200197 return SHORT_NAME_AMBIGUOUS ;
201198
202199 if (!ds -> candidate_exists )
203- return SHORT_NAME_NOT_FOUND ;
200+ return MISSING_OBJECT ;
204201
205202 if (!ds -> candidate_checked )
206203 /*
@@ -414,8 +411,9 @@ static int sort_ambiguous(const void *a, const void *b)
414411 return a_type_sort > b_type_sort ? 1 : -1 ;
415412}
416413
417- static int get_short_oid (const char * name , int len , struct object_id * oid ,
418- unsigned flags )
414+ static enum get_oid_result get_short_oid (const char * name , int len ,
415+ struct object_id * oid ,
416+ unsigned flags )
419417{
420418 int status ;
421419 struct disambiguate_state ds ;
@@ -733,7 +731,7 @@ static inline int push_mark(const char *string, int len)
733731 return at_mark (string , len , suffix , ARRAY_SIZE (suffix ));
734732}
735733
736- static int get_oid_1 (const char * name , int len , struct object_id * oid , unsigned lookup_flags );
734+ static enum get_oid_result get_oid_1 (const char * name , int len , struct object_id * oid , unsigned lookup_flags );
737735static int interpret_nth_prior_checkout (const char * name , int namelen , struct strbuf * buf );
738736
739737static int get_oid_basic (const char * str , int len , struct object_id * oid ,
@@ -883,36 +881,38 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,
883881 return 0 ;
884882}
885883
886- static int get_parent (const char * name , int len ,
887- struct object_id * result , int idx )
884+ static enum get_oid_result get_parent (const char * name , int len ,
885+ struct object_id * result , int idx )
888886{
889887 struct object_id oid ;
890- int ret = get_oid_1 (name , len , & oid , GET_OID_COMMITTISH );
888+ enum get_oid_result ret = get_oid_1 (name , len , & oid ,
889+ GET_OID_COMMITTISH );
891890 struct commit * commit ;
892891 struct commit_list * p ;
893892
894893 if (ret )
895894 return ret ;
896895 commit = lookup_commit_reference (the_repository , & oid );
897896 if (parse_commit (commit ))
898- return -1 ;
897+ return MISSING_OBJECT ;
899898 if (!idx ) {
900899 oidcpy (result , & commit -> object .oid );
901- return 0 ;
900+ return FOUND ;
902901 }
903902 p = commit -> parents ;
904903 while (p ) {
905904 if (!-- idx ) {
906905 oidcpy (result , & p -> item -> object .oid );
907- return 0 ;
906+ return FOUND ;
908907 }
909908 p = p -> next ;
910909 }
911- return -1 ;
910+ return MISSING_OBJECT ;
912911}
913912
914- static int get_nth_ancestor (const char * name , int len ,
915- struct object_id * result , int generation )
913+ static enum get_oid_result get_nth_ancestor (const char * name , int len ,
914+ struct object_id * result ,
915+ int generation )
916916{
917917 struct object_id oid ;
918918 struct commit * commit ;
@@ -923,15 +923,15 @@ static int get_nth_ancestor(const char *name, int len,
923923 return ret ;
924924 commit = lookup_commit_reference (the_repository , & oid );
925925 if (!commit )
926- return -1 ;
926+ return MISSING_OBJECT ;
927927
928928 while (generation -- ) {
929929 if (parse_commit (commit ) || !commit -> parents )
930- return -1 ;
930+ return MISSING_OBJECT ;
931931 commit = commit -> parents -> item ;
932932 }
933933 oidcpy (result , & commit -> object .oid );
934- return 0 ;
934+ return FOUND ;
935935}
936936
937937struct object * peel_to_type (const char * name , int namelen ,
@@ -1077,7 +1077,9 @@ static int get_describe_name(const char *name, int len, struct object_id *oid)
10771077 return -1 ;
10781078}
10791079
1080- static int get_oid_1 (const char * name , int len , struct object_id * oid , unsigned lookup_flags )
1080+ static enum get_oid_result get_oid_1 (const char * name , int len ,
1081+ struct object_id * oid ,
1082+ unsigned lookup_flags )
10811083{
10821084 int ret , has_suffix ;
10831085 const char * cp ;
@@ -1111,16 +1113,16 @@ static int get_oid_1(const char *name, int len, struct object_id *oid, unsigned
11111113
11121114 ret = peel_onion (name , len , oid , lookup_flags );
11131115 if (!ret )
1114- return 0 ;
1116+ return FOUND ;
11151117
11161118 ret = get_oid_basic (name , len , oid , lookup_flags );
11171119 if (!ret )
1118- return 0 ;
1120+ return FOUND ;
11191121
11201122 /* It could be describe output that is "SOMETHING-gXXXX" */
11211123 ret = get_describe_name (name , len , oid );
11221124 if (!ret )
1123- return 0 ;
1125+ return FOUND ;
11241126
11251127 return get_short_oid (name , len , oid , lookup_flags );
11261128}
@@ -1664,11 +1666,11 @@ static char *resolve_relative_path(const char *rel)
16641666 rel );
16651667}
16661668
1667- static int get_oid_with_context_1 (const char * name ,
1668- unsigned flags ,
1669- const char * prefix ,
1670- struct object_id * oid ,
1671- struct object_context * oc )
1669+ static enum get_oid_result get_oid_with_context_1 (const char * name ,
1670+ unsigned flags ,
1671+ const char * prefix ,
1672+ struct object_id * oid ,
1673+ struct object_context * oc )
16721674{
16731675 int ret , bracket_depth ;
16741676 int namelen = strlen (name );
0 commit comments