878
return commitable ? 0 : 1;
879
}
880
881
-static char *get_commit_format_string(void)
882
-{
883
- unsigned char sha[20];
884
- const char *head = resolve_ref("HEAD", sha, 0, NULL);
885
- struct strbuf buf = STRBUF_INIT;
886
-
887
- /* use shouty-caps if we're on detached HEAD */
888
- strbuf_addf(&buf, "format:%s", strcmp("HEAD", head) ? "" : "DETACHED commit");
889
- strbuf_addstr(&buf, "%h (%s)");
890
-
891
- if (!prefixcmp(head, "refs/heads/")) {
892
- const char *cp;
893
- strbuf_addstr(&buf, " on ");
894
- for (cp = head + 11; *cp; cp++) {
895
- if (*cp == '%')
896
- strbuf_addstr(&buf, "%x25");
897
- else
898
- strbuf_addch(&buf, *cp);
899
- }
900
- }
901
-
902
- return strbuf_detach(&buf, NULL);
903
-}
904
-
881
static void print_summary(const char *prefix, const unsigned char *sha1)
882
{
883
struct rev_info rev;
884
struct commit *commit;
909
- char *format = get_commit_format_string();
885
+ static const char *format = "format:%h: \"%s\"";
886
+ unsigned char junk_sha1[20];
887
+ const char *head = resolve_ref("HEAD", junk_sha1, 0, NULL);
888
889
commit = lookup_commit(sha1);
890
if (!commit)
909
rev.diffopt.break_opt = 0;
910
diff_setup_done(&rev.diffopt);
911
934
- printf("Created %s", initial_commit ? "root-commit " : "");
912
+ printf("[%s%s]: created ",
913
+ !prefixcmp(head, "refs/heads/") ?
914
+ head + 11 :
915
+ !strcmp(head, "HEAD") ?
916
+ "detached HEAD" :
917
+ head,
918
+ initial_commit ? " (root-commit)" : "");
919
920
if (!log_tree_commit(&rev, commit)) {
921
struct strbuf buf = STRBUF_INIT;
923
printf("%s\n", buf.buf);
924
strbuf_release(&buf);
925
}
942
- free(format);
926
}
927
928
static int git_commit_config(const char *k, const char *v, void *cb)