Skip to content

Commit

Permalink
Clean up find_unique_abbrev() callers
Browse files Browse the repository at this point in the history
Now find_unique_abbrev() never returns NULL, there is no need for callers
to prepare for seeing NULL and fall back to giving the full 40-hexdigits.

While we are at it, drop "..." in the "git reset" output that reports the
location of the new HEAD, between the abbreviated commit object name and
the one line commit summary.  Because we are always showing the HEAD
(which cannot be missing!), we never had a case where we show the full 40
hexdigits that is not followed by three dots, and these three dots were
stealing 3 columns from the precious horizontal screen real estate out of
80 that can better be used for the one line commit summary.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Mar 2, 2008
1 parent b66fde9 commit 2efb3b0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
8 changes: 2 additions & 6 deletions builtin-reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,10 @@ static int reset_index_file(const unsigned char *sha1, int is_hard_reset)

static void print_new_head_line(struct commit *commit)
{
const char *hex, *dots = "...", *body;
const char *hex, *body;

hex = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);
if (!hex) {
hex = sha1_to_hex(commit->object.sha1);
dots = "";
}
printf("HEAD is now at %s%s", hex, dots);
printf("HEAD is now at %s", hex);
body = strstr(commit->buffer, "\n\n");
if (body) {
const char *eol;
Expand Down
4 changes: 1 addition & 3 deletions builtin-send-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,7 @@ static void print_ref_status(char flag, const char *summary, struct ref *to, str

static const char *status_abbrev(unsigned char sha1[20])
{
const char *abbrev;
abbrev = find_unique_abbrev(sha1, DEFAULT_ABBREV);
return abbrev ? abbrev : sha1_to_hex(sha1);
return find_unique_abbrev(sha1, DEFAULT_ABBREV);
}

static void print_ok_ref_status(struct ref *ref)
Expand Down
2 changes: 0 additions & 2 deletions diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -2581,8 +2581,6 @@ const char *diff_unique_abbrev(const unsigned char *sha1, int len)
return sha1_to_hex(sha1);

abbrev = find_unique_abbrev(sha1, len);
if (!abbrev)
return sha1_to_hex(sha1);
abblen = strlen(abbrev);
if (abblen < 37) {
static char hex[41];
Expand Down

0 comments on commit 2efb3b0

Please sign in to comment.