- return find_unique_short_object(i, canonical, res, sha1);
+ status = find_unique_short_object(i, canonical, res, sha1);
+ if (!quietly && (status == SHORT_NAME_AMBIGUOUS))
+ return error("short SHA1 %.*s is ambiguous.", len, canonical);
+ return status;
+}
+
+const char *find_unique_abbrev(const unsigned char *sha1, int len)
+{
+ int status, is_null;
+ static char hex[41];
+
+ is_null = !memcmp(sha1, null_sha1, 20);
+ memcpy(hex, sha1_to_hex(sha1), 40);
+ if (len == 40)
+ return hex;
+ while (len < 40) {
+ unsigned char sha1_ret[20];
+ status = get_short_sha1(hex, len, sha1_ret, 1);
+ if (!status ||
+ (is_null && status != SHORT_NAME_AMBIGUOUS)) {
+ hex[len] = 0;
+ return hex;
+ }
+ if (status != SHORT_NAME_AMBIGUOUS)
+ return NULL;
+ len++;
+ }
+ return NULL;
+}
+
+static int ambiguous_path(const char *path, int len)
+{
+ int slash = 1;
+ int cnt;
+
+ for (cnt = 0; cnt < len; cnt++) {
+ switch (*path++) {
+ case '\0':
+ break;
+ case '/':
+ if (slash)
+ break;
+ slash = 1;
+ continue;
+ case '.':
+ continue;
+ default:
+ slash = 0;
+ continue;
+ }
+ break;
+ }
+ return slash;