Anonymous committed 5a82b4f

Error message from get_sha1() on ambiguous short SHA1.

Unlike cases where "no such object exists", the case where specified
prefix is ambiguous would confuse the user if we say "no such commit"
or such. Give an extra error message from the uniqueness check if
there are more than one objects that match the given prefix.

Signed-off-by: Junio C Hamano <>

Comments (0)

Files changed (1)

 	/* Both have unique ones -- do they match? */
 	if (memcmp(packed_sha1, unpacked_sha1, 20))
-		return -1;
+		return error("short SHA1 %.*s is ambiguous.", len, canonical);
 	memcpy(sha1, packed_sha1, 20);
 	return 0;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.