summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a8783ee)
raw | patch | inline | side by side (parent: a8783ee)
author | Linus Torvalds <torvalds@osdl.org> | |
Sun, 18 Sep 2005 18:27:45 +0000 (11:27 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sun, 18 Sep 2005 21:18:38 +0000 (14:18 -0700) |
This fixes everybodys favourite complaint about "git add", namely that it
doesn't take directories.
We use "git-ls-files --others" to generate an arbitrary list of filenames,
and thus also automatically honor ignore-files while we're at it.
Side note: there's a lot of room for improvement here. In particular, if
we have a long list of filenames (importing a big archive), this will just
do a big stupid for-loop and add them one at a time. Maybe it should use
generate-list | xargs -0 git-update-idex --add --
instead.
Also, I think we should have a default ignore list if we don't find a
.git/info/exclude file. Ignoring "*.o" and ".*" by default would probably
be the right thing to do.
But I think this is a good first step.
Use the "-n" flag to just show the list of files to be added without
adding them.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
doesn't take directories.
We use "git-ls-files --others" to generate an arbitrary list of filenames,
and thus also automatically honor ignore-files while we're at it.
Side note: there's a lot of room for improvement here. In particular, if
we have a long list of filenames (importing a big archive), this will just
do a big stupid for-loop and add them one at a time. Maybe it should use
generate-list | xargs -0 git-update-idex --add --
instead.
Also, I think we should have a default ignore list if we don't find a
.git/info/exclude file. Ignoring "*.o" and ".*" by default would probably
be the right thing to do.
But I think this is a good first step.
Use the "-n" flag to just show the list of files to be added without
adding them.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
git-add.sh | patch | blob | history |
diff --git a/git-add.sh b/git-add.sh
index 7d91eeb65705fba291b3baf0e006c9ec90f96276..3d364db2517b6a19de6b8e26f6d61a86589c1fcc 100755 (executable)
--- a/git-add.sh
+++ b/git-add.sh
#!/bin/sh
-git-update-index --add -- "$@"
+
+show_only=
+verbose=
+while : ; do
+ case "$1" in
+ -n)
+ show_only=true
+ verbose=true
+ ;;
+ -v)
+ verbose=true
+ ;;
+ *)
+ break
+ ;;
+ esac
+ shift
+done
+
+GIT_DIR=$(git-rev-parse --git-dir) || exit
+global_exclude=
+if [ -f "$GIT_DIR/info/exclude" ]; then
+ global_exclude="--exclude-from=$GIT_DIR/info/exclude"
+fi
+for i in $(git-ls-files --others \
+ $global_exclude --exclude-per-directory=.gitignore \
+ "$@")
+do
+ [ "$verbose" ] && echo " $i"
+ [ "$show_only" ] || git-update-index --add -- "$i" || exit
+done