Thomas Rast <trast@xxxxxxxxxxxxxxx> writes: > +static const char post_rewrite_hook[] = "hooks/post-rewrite"; > + > +static int run_rewrite_hook(const unsigned char *oldsha1, > + const unsigned char *newsha1) > +{ > +... > +} > + > int cmd_commit(int argc, const char **argv, const char *prefix) > { > struct strbuf sb = STRBUF_INIT; > @@ -1303,6 +1339,13 @@ int cmd_commit(int argc, const char **argv, const char *prefix) > > rerere(0); > run_hook(get_index_file(), "post-commit", NULL); > + if (amend && !no_post_rewrite) { > + struct commit *commit; > + commit = lookup_commit(head_sha1); > + if (!commit || parse_commit(commit)) > + die("HEAD commit disappeared right under my eyes?"); > + run_rewrite_hook(commit->object.sha1, commit_sha1); Why aren't you passing head_sha1 to run_rewrite_hook() in the first place, and instead run lookup_commit() only to get its object.sha1? This is merely a "post" hook, so failure to run it should not cause the main program to fail. By not looking it up you do not even have to check and call die(). Let the dying be done in the hook instead ;-). -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html