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. > + */