* git-commit: if run with <file> arguments, include files removed through git rm
@ 2007-09-04 14:43 Gerrit Pape
2007-09-04 16:00 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Gerrit Pape @ 2007-09-04 14:43 UTC (permalink / raw)
To: git
If git-commit is given a directory as argument to be included in the
commit, it uses git ls-files to find out which files to include; this
misses files previously removed from the working tree and the index
through git rm:
% git init-db
Initialized empty Git repository in .git/
% mkdir bar baz
% touch bar/file1 baz/file1 baz/file2
% git add . && git commit -mcommit1
Created initial commit 1d7dee4: commit1
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 bar/file1
create mode 100644 baz/file1
create mode 100644 baz/file2
% git rm baz/file1
rm 'baz/file1'
% git commit -- baz/
# On branch master
# Changed but not updated:
# (use "git add/rm <file>..." to update what will be committed)
#
# deleted: baz/file1
#
no changes added to commit (use "git add" and/or "git commit -a")
This patch lets it additionally use git ls-tree to look for the files in
the HEAD tree, but I guess there's a smarter way to fix this.
---
git-commit.sh | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/git-commit.sh b/git-commit.sh
index 1d04f1f..3ac7c4f 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -381,6 +381,7 @@ t,)
fi
TMP_INDEX="$GIT_DIR/tmp-index$$"
commit_only=`git ls-files --error-unmatch -- "$@"` || exit
+ commit_only="$commit_only "`git ls-tree -r --name-only HEAD -- "$@"` || exit
# Build a temporary index and update the real index
# the same way.
--
1.5.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: git-commit: if run with <file> arguments, include files removed through git rm
2007-09-04 14:43 git-commit: if run with <file> arguments, include files removed through git rm Gerrit Pape
@ 2007-09-04 16:00 ` Junio C Hamano
2007-09-05 10:20 ` Gerrit Pape
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2007-09-04 16:00 UTC (permalink / raw)
To: Gerrit Pape; +Cc: git
Gerrit Pape <pape@smarden.org> writes:
> This patch lets it additionally use git ls-tree to look for the files in
> the HEAD tree, but I guess there's a smarter way to fix this.
You raised a good issue, but this also needs other parts of the
system to be adjusted.
> commit_only=`git ls-files --error-unmatch -- "$@"` || exit
> + commit_only="$commit_only "`git ls-tree -r --name-only HEAD -- "$@"` || exit
The arguments to git-commit are *NOT* "<file> arguments". They
are file patterns and 'ls-files --error-unmatch -- "$@"' is
there to allow you to say something like:
$ git commit 'p*/*.c'
Alas, ls-tree does not grok globbing yet. Try this in git.git
repository (surrounding quotes are essential):
$ git ls-files 'p*/*.c'
$ git ls-tree -r HEAD 'p*/*.c'
Currently we have two semantics of "pathspec", and unifying
these semantics is one of the items with somewhat higher
priority on my TODO list for the 1.5.4 cycle (I started looking
at diff-tree and log last night):
* ls-files, diff-files, diff-index and grep understand both
"leading directory prefix" and "glob pattern"; you can say:
$ git ls-files -- arm/ 'p*/*.c'
$ git grep int -- arm/ 'p*/*.c'
and they do what you would expect them to do.
* diff-tree, log family and ls-tree understand only "leading
directory prefix" and not "glob pattern"; you cannot say:
$ git log -- 'p*/*.c'
So your patch is a definite improvement for normal ("non
pattern" but "exact pathname") case, but needs the updates to
pathspec semantics to be the correct fix.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: git-commit: if run with <file> arguments, include files removed through git rm
2007-09-04 16:00 ` Junio C Hamano
@ 2007-09-05 10:20 ` Gerrit Pape
0 siblings, 0 replies; 3+ messages in thread
From: Gerrit Pape @ 2007-09-05 10:20 UTC (permalink / raw)
To: git
On Tue, Sep 04, 2007 at 09:00:13AM -0700, Junio C Hamano wrote:
> Gerrit Pape <pape@smarden.org> writes:
> > This patch lets it additionally use git ls-tree to look for the files in
> > the HEAD tree, but I guess there's a smarter way to fix this.
>
> You raised a good issue, but this also needs other parts of the
Thanks for your detailed explanations.
Sebastian Harl actually noticed this unexpected behavior, and reported
through
http://bugs.debian.org/437817
Regards, Gerrit.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-09-05 10:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-04 14:43 git-commit: if run with <file> arguments, include files removed through git rm Gerrit Pape
2007-09-04 16:00 ` Junio C Hamano
2007-09-05 10:20 ` Gerrit Pape
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).