author | Junio C Hamano <gitster@pobox.com> | |
Sun, 2 Mar 2008 07:35:32 +0000 (23:35 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 2 Mar 2008 07:52:13 +0000 (23:52 -0800) | ||
commit | b66fde9a287f64ed81d4d4a1639997ad5eedb432 | |
tree | ac5c9a4c288458cce1f893452ff54804e3c135ca | tree | snapshot |
parent | 48411d2233aec65b612ac2b1f50540ec60f0f568 | commit | diff |
find_unique_abbrev(): redefine semantics
The function returned NULL when no object that matches the name
was found, but that made the callers more complicated, as nobody
used that NULL return as an indication that no object with such
a name exists. They (at least the careful ones) instead took
the full 40-hexdigit and used in such a case, and the careless
ones segfaulted.
With this "git rev-parse --short 5555555555555555555555555555555555555555"
would stop segfaulting.
This is based on Jeff King's rewrite to my RFC patch, but "missing"
logic swapped to "exists". The final logic reads:
For existing objects, make sure the abbreviated string uniquely
identifies it. Otherwise, make sure the abbreviated string is
long enough so that it would not name any existing object.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
The function returned NULL when no object that matches the name
was found, but that made the callers more complicated, as nobody
used that NULL return as an indication that no object with such
a name exists. They (at least the careful ones) instead took
the full 40-hexdigit and used in such a case, and the careless
ones segfaulted.
With this "git rev-parse --short 5555555555555555555555555555555555555555"
would stop segfaulting.
This is based on Jeff King's rewrite to my RFC patch, but "missing"
logic swapped to "exists". The final logic reads:
For existing objects, make sure the abbreviated string uniquely
identifies it. Otherwise, make sure the abbreviated string is
long enough so that it would not name any existing object.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1_name.c | diff | blob | history |