Re: [RFC/PATCH] commit: update the index after running the pre-commit hook

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ævar Arnfjörð Bjarmason wrote:

> +++ b/builtin/commit.c
> @@ -565,6 +579,16 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
>  	if (!no_verify && run_hook(index_file, "pre-commit", NULL))
>  		return 0;
>  
> +	/* Update the index after we run the pre-commit hook, but before
> +	 * we construct the message we're sending to the editor. The
> +	 * pre-commit hook may e.g. create a new file and add it to the
> +	 * index.
> +	 *
> +	 * Having that file show up as modified but not staged is confusing.
> +	 */
> +	if (!update_index(index_file))
> +		return 0;
> +
>  	if (message.len) {
>  		strbuf_addbuf(&sb, &message);
>  		hook_arg1 = "message";
> @@ -728,15 +752,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
>  	 * and write it out as a tree.  We must do this before we invoke
>  	 * the editor and after we invoke run_status above.
>  	 */
> -	discard_cache();
> -	read_cache_from(index_file);
> -	if (!active_cache_tree)
> -		active_cache_tree = cache_tree();
> -	if (cache_tree_update(active_cache_tree,
> -			      active_cache, active_nr, 0, 0) < 0) {
> -		error("Error building trees");
> +	if (!update_index(index_file))
>  		return 0;
> -	}
>  
>  	if (run_hook(index_file, "prepare-commit-msg",

Before, "commit" updated the index once, and after, twice.  How does
this affect the running time on, say, the linux-2.6 tree?  Could one
of the update_index() calls be suppressed when there is no hook to
run?
--
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


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]