Re: [PATCH v2 1/4] builtin-add.c: restructure the code for maintainability

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Junio C Hamano
Date: Monday, July 21, 2008 - 12:52 am

Junio C Hamano <gitster@pobox.com> writes:


Thinking about this issue a bit more, I realize that the earlier "git add -A"
change was done in a quite inefficient way (i.e. it is as unefficient as
"git add -u && git add ." modulo one fork/exec and read/write index).  For
that matter, the original "git add ." could probably be more efficient
than it currently is.

The thing is, when the user asks "git add .", we do not have to examine
all paths we encounter and perform the excluded() and dir_add_name()
processing, both of which are slower code and use slower data structure by
git standard, especially when the index is already populated.

Instead, we should be able to implement "git add $pathspec..." as:

 - read the index;

 - read_directory() to process untracked, unignored files the current way,
   that is, recursively doing readdir(), filtering them by pathspec and
   excluded(), queueing them via dir_add_name() and finally do
   add_files(); and

 - iterate over the index, filtering them by pathspec, and update only the
   modified/type changed paths but not deleted ones.

And "git add -A" will become exactly the same as above, modulo:

 - missing $pathspec means "." instead of being an error; and 

 - "interate over the index" part handles deleted ones as well,
   i.e. exactly what the current update_callback() in builtin-add.c does.

It is likely that I am too tired to do this right tonight, so I'll go to
bed and expect to find a nicely done patch in my mailbox by somebody else
;-).
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH v2 2/4] git-add --all: add all files, Junio C Hamano, (Sat Jul 19, 11:09 pm)
[PATCH v2 3/4] git-add --all: tests, Junio C Hamano, (Sat Jul 19, 11:09 pm)
[PATCH v2 4/4] git-add --all: documentation, Junio C Hamano, (Sat Jul 19, 11:09 pm)
Re: [PATCH v2 1/4] builtin-add.c: restructure the code for ..., Johannes Schindelin, (Sun Jul 20, 5:56 pm)
[PATCH/RFC] git add: do not add files from a submodule, Johannes Schindelin, (Sun Jul 20, 5:58 pm)
Re: [PATCH v2 1/4] builtin-add.c: restructure the code for ..., Junio C Hamano, (Mon Jul 21, 12:52 am)
Re: [PATCH/RFC] git add: do not add files from a submodule, Johannes Schindelin, (Tue Jul 22, 2:32 pm)
Re: [PATCH/RFC] git add: do not add files from a submodule, Junio C Hamano, (Tue Jul 22, 11:40 pm)
Re: [PATCH/RFC] git add: do not add files from a submodule, Pierre Habouzit, (Wed Jul 23, 1:13 am)
Re: [PATCH/RFC] git add: do not add files from a submodule, Junio C Hamano, (Wed Jul 23, 11:31 am)
Re: [PATCH/RFC] git add: do not add files from a submodule, Pierre Habouzit, (Wed Jul 23, 12:02 pm)
Re: [PATCH/RFC] git add: do not add files from a submodule, Johannes Schindelin, (Wed Jul 23, 12:10 pm)
Re: [PATCH/RFC] git add: do not add files from a submodule, Pierre Habouzit, (Wed Jul 23, 12:11 pm)