threads / discuss / 17835

git commit <path> scanning entire working tree?

Subject: git commit <path> scanning entire working tree?

## tl;dr

7 messages between Feb 16, 2009 and Feb 18, 2009.

replies: 6people: 3as markdown or json

skillzero@gmail.com· Feb 16, 2009, 22:58 UTC · lore

When I do a 'git commit <path to a single file>', git seems to scan the entire working tree. Since my tree is relatively large (and when on Windows, stat'ing is even slower), it takes quite a while (5 or so seconds) before I can even edit the commit message.

Is there a reason it needs to scan like this when the commit command specifies a specific path? It seems like it would only need to scan the path I've specified.

Junio C Hamano· Feb 17, 2009, 00:28 UTC · re: skillzero@gmail.com · lore

Re: git commit <path> scanning entire working tree?

skillzero@gmail.com writes:
> When I do a 'git commit <path to a single file>', git seems to scan
> the entire working tree. Since my tree is relatively large (and when
> on Windows, stat'ing is even slower), it takes quite a while (5 or so
> seconds) before I can even edit the commit message.

Do you mean you edit the commit message, starting from the message template "git commit" gives you?

The template lists "Changes to be committed" (which obviously would list only the path that matches the single pathspec you give to the command, and there is no need to scan the whole tree -- it only needs to check the file or a directory hierarchy if the pathspec matches a directory), but also "Changed but not updated" and "Untracked files". You cannot generate the latter two lists without checking with your work tree.

Boyd Stephen Smith Jr.· Feb 17, 2009, 02:57 UTC · re: Junio C Hamano · lore

Re: git commit <path> scanning entire working tree?

On Monday 16 February 2009 18:28:10 Junio C Hamano wrote:
Show 11 quoted lines
> skillzero@gmail.com writes:
> > When I do a 'git commit <path to a single file>', git seems to scan
> > the entire working tree.  [I]t takes quite a while (5 or so
> > seconds) before I can even edit the commit message.
>
> Do you mean you edit the commit message, starting from the message
> template "git commit" gives you?
>
> The template lists "Changes to be committed", but
> also "Changed but not updated" and "Untracked files".  You cannot generate
> the latter two lists without checking with your work tree.
So, specify one or more -m options and you shouldn't see the scan.
-- 
Boyd Stephen Smith Jr.                   ,= ,-_-. =.
bss@iguanasuicide.net                   ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy         `-'(. .)`-'
http://iguanasuicide.net/                    \_/
skillzero@gmail.com· Feb 17, 2009, 03:37 UTC · re: Junio C Hamano · lore

Re: git commit <path> scanning entire working tree?

On Mon, Feb 16, 2009 at 4:28 PM, Junio C Hamano <gitster@pobox.com> wrote:
>
> Do you mean you edit the commit message, starting from the message
> template "git commit" gives you?

Yes, there's a large delay from me entering 'git commit -a' and when the editor shows up.

Show 6 quoted lines
> The template lists "Changes to be committed" (which obviously would list
> only the path that matches the single pathspec you give to the command,
> and there is no need to scan the whole tree -- it only needs to check the
> file or a directory hierarchy if the pathspec matches a directory), but
> also "Changed but not updated" and "Untracked files".  You cannot generate
> the latter two lists without checking with your work tree.

It seems like it shouldn't scan/show things outside of the path. If I've specified a path on the command line, I most likely only care about things in that path. I think it would make committing specific paths much faster when you have a large tree. However, it would eliminate information (changed/untracked files outside that path), if people are relying on that.

Boyd Stephen Smith Jr.· Feb 17, 2009, 05:50 UTC · re: skillzero@gmail.com · lore

Re: git commit <path> scanning entire working tree?

On Monday 16 February 2009 21:37:57 you wrote:
Show 11 quoted lines
> On Mon, Feb 16, 2009 at 4:28 PM, Junio C Hamano <gitster@pobox.com> wrote:
> > The template lists "Changes to be committed", but
> > also "Changed but not updated" and "Untracked files".  You cannot
> > generate the latter two lists without checking with your work tree.
>
> It seems like it shouldn't scan/show things outside of the path. If
> I've specified a path on the command line, I most likely only care
> about things in that path. I think it would make committing specific
> paths much faster when you have a large tree. However, it would
> eliminate information (changed/untracked files outside that path), if
> people are relying on that.
Patches reviewed (and possibly accepted) here.
-- 
Boyd Stephen Smith Jr.                   ,= ,-_-. =.
bss@iguanasuicide.net                   ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy         `-'(. .)`-'
http://iguanasuicide.net/                    \_/
Junio C Hamano· Feb 17, 2009, 07:12 UTC · re: skillzero@gmail.com · lore

Re: git commit <path> scanning entire working tree?

skillzero@gmail.com writes:
> ... However, it would
> eliminate information (changed/untracked files outside that path), if
> people are relying on that.

People do rely on that information. Why else we would spend cycles to show them?

There is a precedence to allow a configuration variable to skip various computation to help slow systems, e.g. 6c2ce04 (Add argument 'no' commit/status option -u|--untracked-files, 2008-06-05).

skillzero@gmail.com· Feb 18, 2009, 02:25 UTC · re: Junio C Hamano · lore

Re: git commit <path> scanning entire working tree?

On Mon, Feb 16, 2009 at 11:12 PM, Junio C Hamano <gitster@pobox.com> wrote:
> skillzero@gmail.com writes:
> People do rely on that information.  Why else we would spend cycles to show
> them?

My guess was that most people didn't work with very large trees. For example, the Linux kernel tree stat's pretty quickly (.7 seconds when hot on my machine), but my tree contains the code for an entire OS distribution so even on a fast machine and OS, it takes many seconds.

My thinking was that in the case when a path was specified, people might be less interested in changes/untracked files outside that path (although I may be totally wrong). If a path wasn't specified, I can see why it would be useful to show everything. I tend to do a 'git status' then a bunch of 'git commit <path>' commands.

> There is a precedence to allow a configuration variable to skip various
> computation to help slow systems, e.g. 6c2ce04 (Add argument 'no'
> commit/status option -u|--untracked-files, 2008-06-05).

Thanks, I'll check it out. If that doesn't do what I need, maybe I can trying changing git to add support for automatically skipping files outside the specifies path and submit a patch for you guys to rip to shreds :)

← back to recent threads