Merge branch 'ks/branch-list-detached-rebase-i'
authorJunio C Hamano <gitster@pobox.com>
Wed, 25 Apr 2018 04:28:53 +0000 (13:28 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Apr 2018 04:28:54 +0000 (13:28 +0900)
"git branch --list" during an interrupted "rebase -i" now lets
users distinguish the case where a detached HEAD is being rebased
and a normal branch is being rebased.

* ks/branch-list-detached-rebase-i:
t3200: verify "branch --list" sanity when rebasing from detached HEAD
branch --list: print useful info whilst interactive rebasing a detached HEAD

1  2 
ref-filter.c
diff --combined ref-filter.c
index 9a333e21b51a0583415e23f905876291dd2ef349,d9ef7f0748366ae9e0f14a25b87d3a37cea8e7af..a8478384844bb17a50ba8aa1da463d54342d7f82
@@@ -728,7 -728,7 +728,7 @@@ int verify_ref_format(struct ref_forma
  static void *get_obj(const struct object_id *oid, struct object **obj, unsigned long *sz, int *eaten)
  {
        enum object_type type;
 -      void *buf = read_sha1_file(oid->hash, &type, sz);
 +      void *buf = read_object_file(oid, &type, sz);
  
        if (buf)
                *obj = parse_object_buffer(oid, type, *sz, buf, eaten);
        return buf;
  }
  
 -static int grab_objectname(const char *name, const unsigned char *sha1,
 +static int grab_objectname(const char *name, const struct object_id *oid,
                           struct atom_value *v, struct used_atom *atom)
  {
        if (starts_with(name, "objectname")) {
                if (atom->u.objectname.option == O_SHORT) {
 -                      v->s = xstrdup(find_unique_abbrev(sha1, DEFAULT_ABBREV));
 +                      v->s = xstrdup(find_unique_abbrev(oid, DEFAULT_ABBREV));
                        return 1;
                } else if (atom->u.objectname.option == O_FULL) {
 -                      v->s = xstrdup(sha1_to_hex(sha1));
 +                      v->s = xstrdup(oid_to_hex(oid));
                        return 1;
                } else if (atom->u.objectname.option == O_LENGTH) {
 -                      v->s = xstrdup(find_unique_abbrev(sha1, atom->u.objectname.length));
 +                      v->s = xstrdup(find_unique_abbrev(oid, atom->u.objectname.length));
                        return 1;
                } else
                        die("BUG: unknown %%(objectname) option");
@@@ -775,7 -775,7 +775,7 @@@ static void grab_common_values(struct a
                        v->s = xstrfmt("%lu", sz);
                }
                else if (deref)
 -                      grab_objectname(name, obj->oid.hash, v, &used_atom[i]);
 +                      grab_objectname(name, &obj->oid, v, &used_atom[i]);
        }
  }
  
@@@ -1309,10 -1309,14 +1309,14 @@@ char *get_head_description(void
        memset(&state, 0, sizeof(state));
        wt_status_get_state(&state, 1);
        if (state.rebase_in_progress ||
-           state.rebase_interactive_in_progress)
-               strbuf_addf(&desc, _("(no branch, rebasing %s)"),
-                           state.branch);
-       else if (state.bisect_in_progress)
+           state.rebase_interactive_in_progress) {
+               if (state.branch)
+                       strbuf_addf(&desc, _("(no branch, rebasing %s)"),
+                                   state.branch);
+               else
+                       strbuf_addf(&desc, _("(no branch, rebasing detached HEAD %s)"),
+                                   state.detached_from);
+       } else if (state.bisect_in_progress)
                strbuf_addf(&desc, _("(no branch, bisect started on %s)"),
                            state.branch);
        else if (state.detached_from) {
@@@ -1455,7 -1459,7 +1459,7 @@@ static void populate_value(struct ref_a
                                v->s = xstrdup(buf + 1);
                        }
                        continue;
 -              } else if (!deref && grab_objectname(name, ref->objectname.hash, v, atom)) {
 +              } else if (!deref && grab_objectname(name, &ref->objectname, v, atom)) {
                        continue;
                } else if (!strcmp(name, "HEAD")) {
                        if (atom->u.head && !strcmp(ref->refname, atom->u.head))