Dovrebbe darti qualcosa del genere:
$ git log cee157
error: short SHA1 cee157 is ambiguous.
error: short SHA1 cee157 is ambiguous.
fatal: ambiguous argument 'cee157': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Ho appena provato questo su un vero repository Git, trovando commit con prefissi duplicati come questo:
git rev-list master | cut -c-4 | sort | uniq -c | sort -nr | head
Questo prende l'elenco delle revisioni master
, ritaglia i primi 4 caratteri e butta via il resto, conta i duplicati e ordina numericamente. In un mio repository relativamente piccolo di ~ 1500 commit ho trovato alcune revisioni con un prefisso comune a 4 cifre. Ho scelto un prefisso di 4 cifre perché sembra essere la lunghezza legale più breve supportata da Git. (Non funziona con 3 cifre o meno, anche se non ambiguo.)
A proposito, questo non era un errore di battitura, non so perché il messaggio di errore su SHA1 ambiguo appare due volte, indipendentemente dal numero di SHA1 duplicato (provato con 2 e 3):
error: short SHA1 cee157 is ambiguous.
error: short SHA1 cee157 is ambiguous.
(Entrambi stderr
attivi. In realtà l'intero output è attivo stderr
, niente attivo stdout
.)
Testato su Windows:
$ git --version
git version 1.8.1.msysgit.1
Penso che sia sicuro dire che se la tua versione è> = 1.8.1, Git ti avvertirà dei duplicati. (Rifiuterà di operare con i duplicati.) Immagino che anche versioni molto più vecchie funzionassero in questo modo.
AGGIORNARE
Quando si verifica questo, è necessario un minimo di 4 cifre SHA1, a causa di int minimum_abbrev = 4
in environment.c . (Grazie @devnull per averlo sottolineato!)
man gitrevisions
, che almeno implica che verrà dato un avvertimento poiché afferma che puoi nominare una revisione con il suo nome SHA1-1 completo o "una sottostringa iniziale unica nel repository".