# Re: [PATCH] Enter interactive mode if no parameters are given to git-add

4 messages from 2006-12-19 to 2006-12-19. Participants: Jakub Narebski, Junio C Hamano, Linus Torvalds, Andy Parkins.
Thread: https://gitlist.dev/t/43249

## Andy Parkins, 2006-12-19 15:16

Subject: [PATCH] Enter interactive mode if no parameters are given to git-add
Message-ID: <200612191516.09606.andyparkins@gmail.com>
URL: https://gitlist.dev/e/200612191516.09606.andyparkins%40gmail.com

```
git-add with no parameters previously adds every modified file.  This
patch instead makes git-add enter interactive mode.

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
---
This patch is against pu.

It seemed a bit nasty to add content without explicit instructions to do
so.  Instead, just drop into interactive mode, which they can easily get out
of if it was all a big accident, and additionally is quicker than typing
--interactive.

 builtin-add.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/builtin-add.c b/builtin-add.c
index aa2f0f3..52a63a0 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -96,10 +96,12 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 		if (!strcmp("--interactive", argv[i]))
 			add_interactive++;
 	}
+	if (argc == 1)
+		add_interactive++;
 	if (add_interactive) {
 		const char *args[] = { "add--interactive", NULL };
 
-		if (add_interactive != 1 || argc != 2)
+		if (add_interactive != 1 || argc > 2)
 			die("add --interactive does not take any parameters");
 		execv_git_cmd(args);
 		exit(1);
-- 
1.4.4.2.g95ee-dirty

```

## Jakub Narebski, 2006-12-19 16:42

Subject: Re: [PATCH] Enter interactive mode if no parameters are given to git-add
Message-ID: <em94l8$n8u$1@sea.gmane.org>
URL: https://gitlist.dev/e/em94l8%24n8u%241%40sea.gmane.org
In-Reply-To: <200612191516.09606.andyparkins@gmail.com>

```
<opublikowany i wysłany>

Andy Parkins wrote:

> gmane.comp.version-control.git
> git-add with no parameters previously adds every modified file.  This
> patch instead makes git-add enter interactive mode.
> 
> Signed-off-by: Andy Parkins <andyparkins@gmail.com>
> ---
> This patch is against pu.
> 
> It seemed a bit nasty to add content without explicit instructions to do
> so.  Instead, just drop into interactive mode, which they can easily get out
> of if it was all a big accident, and additionally is quicker than typing
> --interactive.

Hmmm... --interactive is not documented, and neither is --all (erm, I think
git add -all oatch was not yet added).
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git


```

## Junio C Hamano, 2006-12-19 18:00

Subject: Re: [PATCH] Enter interactive mode if no parameters are given to git-add
Message-ID: <7vy7p3pxyr.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vy7p3pxyr.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <200612191516.09606.andyparkins@gmail.com>

```
Andy Parkins <andyparkins@gmail.com> writes:

> git-add with no parameters previously adds every modified file.  This
> patch instead makes git-add enter interactive mode.
> ...
> It seemed a bit nasty to add content without explicit instructions to do
> so.

Does anybody rely on the current behaviour?

It is nasty and I consider it a bug.  It appears that it has
been like that since the days when it was still a shell script.

While I think nobody should drive 'git add' from script, the
behaviour to add everything when there is no explicit parameter
(or fall back to interactive for that matter) has a problem if
you say "some command | xargs git-add --" (you need "xargs -r"
to fix it, which is GNU).

Let's first have a patch to exit with a warning message (but
status 0) without doing anything when there is no explicit
paths.

Again, does anybody rely on the current behaviour?


```

## Linus Torvalds, 2006-12-19 19:04

Subject: Re: [PATCH] Enter interactive mode if no parameters are given to git-add
Message-ID: <Pine.LNX.4.64.0612191101490.3483@woody.osdl.org>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0612191101490.3483%40woody.osdl.org
In-Reply-To: <7vy7p3pxyr.fsf@assigned-by-dhcp.cox.net>

```


On Tue, 19 Dec 2006, Junio C Hamano wrote:

> Andy Parkins <andyparkins@gmail.com> writes:
> 
> > git-add with no parameters previously adds every modified file.  This
> > patch instead makes git-add enter interactive mode.
> > ...
> > It seemed a bit nasty to add content without explicit instructions to do
> > so.
> 
> Does anybody rely on the current behaviour?

I don't know about "rely", but yes, it's what I normally do. When I import 
a tar-ball, I'll just do

	..untar..
	cd result-x.y.z
	git init-db
	git add
	git commit

and I don't usually use the "." at all, since it's unnecessary.

But hey, if it enters some interactive mode, maybe I can teach myself to 
either just do "git add .", or if the interactive mode has a choice of "a" 
for "all", then why not?

> While I think nobody should drive 'git add' from script, the
> behaviour to add everything when there is no explicit parameter
> (or fall back to interactive for that matter) has a problem if
> you say "some command | xargs git-add --" (you need "xargs -r"
> to fix it, which is GNU).

That's a really good argument against the current behaviour of "git add", 
so while I actually use it without any parameters, I will concur that we 
should probably change it.


```
