From: Junio C Hamano Date: Fri, 9 Sep 2016 04:35:59 +0000 (-0700) Subject: Merge branch 'rs/use-strbuf-add-unique-abbrev' into maint X-Git-Tag: v2.9.4~7 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/5e469ab66c86d5178aae71cacf9f55c3b378de03?hp=-c Merge branch 'rs/use-strbuf-add-unique-abbrev' into maint A small code clean-up. * rs/use-strbuf-add-unique-abbrev: use strbuf_add_unique_abbrev() for adding short hashes --- 5e469ab66c86d5178aae71cacf9f55c3b378de03 diff --combined builtin/checkout.c index 91bafdaef4,fa08b73c0f..d3b296880e --- a/builtin/checkout.c +++ b/builtin/checkout.c @@@ -655,8 -655,7 +655,8 @@@ static void update_refs_for_switch(cons update_ref(msg.buf, "HEAD", new->commit->object.oid.hash, NULL, REF_NODEREF, UPDATE_REFS_DIE_ON_ERR); if (!opts->quiet) { - if (old->path && advice_detached_head) + if (old->path && + advice_detached_head && !opts->force_detach) detach_advice(new->name); describe_detached_head(_("HEAD is now at"), new->commit); } @@@ -704,8 -703,7 +704,7 @@@ static int add_pending_uninteresting_re static void describe_one_orphan(struct strbuf *sb, struct commit *commit) { strbuf_addstr(sb, " "); - strbuf_addstr(sb, - find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV)); + strbuf_add_unique_abbrev(sb, commit->object.oid.hash, DEFAULT_ABBREV); strbuf_addch(sb, ' '); if (!parse_commit(commit)) pp_commit_easy(CMIT_FMT_ONELINE, commit, sb); diff --combined transport.c index be4a63ec19,7ef84b9820..41eb82c6f3 --- a/transport.c +++ b/transport.c @@@ -321,11 -321,6 +321,6 @@@ static void print_ref_status(char flag } } - static const char *status_abbrev(unsigned char sha1[20]) - { - return find_unique_abbrev(sha1, DEFAULT_ABBREV); - } - static void print_ok_ref_status(struct ref *ref, int porcelain) { if (ref->deletion) @@@ -340,7 -335,8 +335,8 @@@ char type; const char *msg; - strbuf_addstr(&quickref, status_abbrev(ref->old_oid.hash)); + strbuf_add_unique_abbrev(&quickref, ref->old_oid.hash, + DEFAULT_ABBREV); if (ref->forced_update) { strbuf_addstr(&quickref, "..."); type = '+'; @@@ -350,7 -346,8 +346,8 @@@ type = ' '; msg = NULL; } - strbuf_addstr(&quickref, status_abbrev(ref->new_oid.hash)); + strbuf_add_unique_abbrev(&quickref, ref->new_oid.hash, + DEFAULT_ABBREV); print_ref_status(type, quickref.buf, ref, ref->peer_ref, msg, porcelain); strbuf_release(&quickref); @@@ -359,11 -356,8 +356,11 @@@ static int print_one_push_status(struct ref *ref, const char *dest, int count, int porcelain) { - if (!count) - fprintf(porcelain ? stdout : stderr, "To %s\n", dest); + if (!count) { + char *url = transport_anonymize_url(dest); + fprintf(porcelain ? stdout : stderr, "To %s\n", url); + free(url); + } switch(ref->status) { case REF_STATUS_NONE: