git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] builtin-commit: fix partial-commit support

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 18, 2007, 10:57 UTC
Message-ID
<7vr6inx1m8.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1195381287-26823-4-git-send-email-gitster@pobox.com>
Junio C Hamano <gitster@pobox.com> writes:
> ...
> Additionally:
   - read the index file after pre-commit hook returns, as the
     hook can modify it to affect the contents of the commit.
Show 9 quoted lines
>  - remove the temporary index file .git/next-index-* after
>    commit is done or aborted.
>
>  - run post-commit hook with the real index file to be used
>    after the commit (previously it gave the temporary commit if
>    a partial commit was made).
>
>  - resurrect the safety mechanism to refuse partial commits
>    during a merge to match the scripted version.
Show 11 quoted lines
>  static char *prepare_index(const char **files, const char *prefix)
>  {
>  	int fd;
>  	struct tree *tree;
> -	struct lock_file *next_index_lock;
> +	struct path_list partial;
> +	const char **pathspec = NULL;
>  
>  	if (interactive) {
>  		interactive_add();
> +		commit_style = COMMIT_NORMAL;
This should be COMMIT_AS_IS, to match the scripted version.
> +	/*
> +	 * A partial commit.
> +	 *
> +	 * (0) find the set of affected paths [NEEDSWORK]
This [NEEDSWORK] has been resolved.
Show 5 quoted lines
> +	 * (1) get lock on the real index file;
> +	 * (2) update the_index with the given paths;
> +	 * (3) write the_index out to the real index (still locked);
> +	 * (4) get lock on the false index file;
> +	 * (5) reset the_index from HEAD, but keep the addition;

This ", but keep the addition" is no longer necessary; the set of paths discovered in step (0) _will_ include the added paths that are named by the user in **files.

Show 5 quoted lines
> +	 * (6) update the_index the same way as (2);
> +	 * (7) write the_index out to the false index file;
> +	 * (8) return the name of the false index file (still locked);
> +	 *
> +	 * The caller should run hooks on the locked false index, and
 ... "create the commit using the false index", of course.
> +	 * (A) if all goes well, commit the real index;
> +	 * (B) on failure, rollback the real index;
> +	 * In either case, rollback the false index.
> +	 */
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 8 in “file_exists(): dangling symlinks do exist”
  1. file_exists(): dangling symlinks do existJunio C Hamano, Nov 18, 2007
  2. Export three helper functions from ls-filesJunio C Hamano, Nov 18, 2007
  3. Fix add_files_to_cache() to take pathspec, not user specified list of filesJunio C Hamano, Nov 18, 2007
  4. builtin-commit: fix partial-commit supportJunio C Hamano, Nov 18, 2007
  5. Junio C HamanoNov 18, 2007
  6. Junio C HamanoNov 18, 2007
  7. Junio C HamanoNov 18, 2007
  8. Kristian HøgsbergNov 19, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.