Skip to content

Commit 37c00e5

Browse files
committed
sha1_name.c: allow get_short_sha1() to take other flags
Instead of a separate "int quietly" argument, make it take "unsigned flags" so that we can pass other options to it. The bit assignment of this flag word is exposed in cache.h because the mechanism will be exposed to callers of the higher layer in later commits in this series. Signed-off-by: Junio C Hamano <[email protected]>
1 parent c005e98 commit 37c00e5

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

cache.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,8 @@ struct object_context {
811811
unsigned mode;
812812
};
813813

814+
#define GET_SHA1_QUIETLY 01
815+
814816
extern int get_sha1(const char *str, unsigned char *sha1);
815817
extern void maybe_die_on_misspelt_object_name(const char *name, const char *prefix);
816818
extern int get_sha1_with_context(const char *str, unsigned char *sha1, struct object_context *orc);

sha1_name.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,13 @@ static int finish_object_disambiguation(struct disambiguate_state *ds,
219219
}
220220

221221
static int get_short_sha1(const char *name, int len, unsigned char *sha1,
222-
int quietly)
222+
unsigned flags)
223223
{
224224
int i, status;
225225
char hex_pfx[40];
226226
unsigned char bin_pfx[20];
227227
struct disambiguate_state ds;
228+
int quietly = !!(flags & GET_SHA1_QUIETLY);
228229

229230
if (len < MINIMUM_ABBREV || len > 40)
230231
return -1;
@@ -272,7 +273,7 @@ const char *find_unique_abbrev(const unsigned char *sha1, int len)
272273
return hex;
273274
while (len < 40) {
274275
unsigned char sha1_ret[20];
275-
status = get_short_sha1(hex, len, sha1_ret, 1);
276+
status = get_short_sha1(hex, len, sha1_ret, GET_SHA1_QUIETLY);
276277
if (exists
277278
? !status
278279
: status == SHORT_NAME_NOT_FOUND) {
@@ -603,7 +604,7 @@ static int get_describe_name(const char *name, int len, unsigned char *sha1)
603604
if (ch == 'g' && cp[-1] == '-') {
604605
cp++;
605606
len -= cp - name;
606-
return get_short_sha1(cp, len, sha1, 1);
607+
return get_short_sha1(cp, len, sha1, GET_SHA1_QUIETLY);
607608
}
608609
}
609610
}

0 commit comments

Comments
 (0)