Merge branch 'rs/use-strbuf-add-unique-abbrev' into maint
authorJunio C Hamano <gitster@pobox.com>
Fri, 9 Sep 2016 04:35:59 +0000 (21:35 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 9 Sep 2016 04:36:00 +0000 (21:36 -0700)
A small code clean-up.

* rs/use-strbuf-add-unique-abbrev:
use strbuf_add_unique_abbrev() for adding short hashes

1  2 
builtin/checkout.c
transport.c
diff --combined builtin/checkout.c
index 91bafdaef4295eaf5d241020a21432f58985a460,fa08b73c0f57d0453fe7054586d12012d4267168..d3b296880e7643cdc34b8f8aed4a377ea28d14fc
@@@ -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 be4a63ec1952f7eeb59ea24cdc6835e7d0ba70f9,7ef84b9820f3354031c4fa1d2218f8936d42ef10..41eb82c6f3f4de956225eb8afd65d0684be68eec
@@@ -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)
                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 = '+';
                        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);
  
  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: