Interesting. Does it use it because it can (meaning, --work-tree is
supposed to work), or because --work-tree is the cleanest way to do what
it wants to do (if the feature worked properly, that is, which is not the
case)?
Also, here is a question:
$ git --git-dir git/.git --work-tree git diff --stat|tail -n 1
1443 files changed, 0 insertions(+), 299668 deletions(-)
So, it's like it thinks every file is removed.
But then:
$ cd git
$ git diff --stat|wc -l
0
is this a bug, or a user error?
I think it is among the many other things that falls into "the two
attempts still haven't resolved" category.
Interesting. Does it use it because it can (meaning, --work-tree is
supposed to work), or because --work-tree is the cleanest way to do what
it wants to do (if the feature worked properly, that is, which is not the
case)?
It's like:
The current working directory is like
/usr/lib/python2.5/site-packages/Pootle. The git repository is under
/some/other/path/outside/usr.
Then Pootle has two possibilities:
1) save the current directory, change to /some/other, execute git, and
change the directory back
2) use git --work-tree / --git-dir
I guess the second form is more elegant. Of course if it is decided that
this option will be removed then the old form can be still used, but I
think that would be a step back.
quoted
Also, here is a question:
$ git --git-dir git/.git --work-tree git diff --stat|tail -n 1
1443 files changed, 0 insertions(+), 299668 deletions(-)
So, it's like it thinks every file is removed.
But then:
$ cd git
$ git diff --stat|wc -l
0
is this a bug, or a user error?
I think it is among the many other things that falls into "the two
attempts still haven't resolved" category.
I'm unfamiliar with this part of the codebase, so in case somebody other
could look at it, that would be great, but I'm happy with write a
testcase for it. (Or in case nobody cares, I can try to fix it, but that
may take a bit more time.)
On Sun, Aug 24, 2008 at 08:05:03PM -0700, Junio C Hamano [off-list ref] wrote:
> > Does this include removing of --work-tree as well?
> >
> > The git backend of Pootle (http://translate.sourceforge.net/wiki/) uses
> > it.
>
> Interesting. Does it use it because it can (meaning, --work-tree is
> supposed to work), or because --work-tree is the cleanest way to do what
> it wants to do (if the feature worked properly, that is, which is not the
> case)?
It's like:
The current working directory is like
/usr/lib/python2.5/site-packages/Pootle. The git repository is under
/some/other/path/outside/usr.
Then Pootle has two possibilities:
1) save the current directory, change to /some/other, execute git, and
change the directory back
2) use git --work-tree / --git-dir
I guess the second form is more elegant. Of course if it is decided that
this option will be removed then the old form can be still used, but I
think that would be a step back.
> > Also, here is a question:
> >
> > $ git --git-dir git/.git --work-tree git diff --stat|tail -n 1
> > 1443 files changed, 0 insertions(+), 299668 deletions(-)
> >
> > So, it's like it thinks every file is removed.
> >
> > But then:
> >
> > $ cd git
> > $ git diff --stat|wc -l
> > 0
> >
> > is this a bug, or a user error?
>
> I think it is among the many other things that falls into "the two
> attempts still haven't resolved" category.
I'm unfamiliar with this part of the codebase, so in case somebody other
could look at it, that would be great, but I'm happy with write a
testcase for it. (Or in case nobody cares, I can try to fix it, but that
may take a bit more time.)
Because "git diff" did not call setup_work_tree(). The same happens
for "git diff-index" that someone reported recently. IIRC "git
diff-files" has the same problem.
--
Duy
This makes it possible to use git diff when we are outside the repo but
--work-tree and --git-dir is used.
Signed-off-by: Miklos Vajna <redacted>
---
On Mon, Aug 25, 2008 at 08:52:11PM +0700, Nguyen Thai Ngoc Duy [off-list ref] wrote:
Because "git diff" did not call setup_work_tree(). The same happens
for "git diff-index" that someone reported recently. IIRC "git
diff-files" has the same problem.
Thanks, that was the problem.
builtin-diff-files.c | 1 +
builtin-diff-index.c | 1 +
builtin-diff.c | 1 +
3 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/builtin-diff-index.c b/builtin-diff-index.c
index 17d851b..b8e0656 100644
--- a/builtin-diff-index.c
+++ b/builtin-diff-index.c
@@ -16,6 +16,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
int i;
int result;
+ setup_work_tree();
init_revisions(&rev, prefix);
git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
rev.abbrev = 0;
I think this is only needed when cached == 0
diff --git a/builtin-diff.c b/builtin-diff.c
index 7ffea97..86f9255 100644
--- a/builtin-diff.c
+++ b/builtin-diff.c
@@ -244,6 +244,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
int nongit;
int result = 0;
+ setup_work_tree();
/*
* We could get N tree-ish in the rev.pending_objects list.
* Also there could be M blobs there, and P pathspecs.
No. git-diff has too many modes, some does not need worktree. This
forces worktree on all modes.
--
Duy
On Mon, Aug 25, 2008 at 09:46:37PM +0700, Nguyen Thai Ngoc Duy [off-list ref] wrote:
On 8/25/08, Miklos Vajna [off-list ref] wrote:
quoted
diff --git a/builtin-diff-index.c b/builtin-diff-index.c
index 17d851b..b8e0656 100644
--- a/builtin-diff-index.c
+++ b/builtin-diff-index.c
@@ -16,6 +16,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
int i;
int result;
+ setup_work_tree();
init_revisions(&rev, prefix);
git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
rev.abbrev = 0;
I think this is only needed when cached == 0
quoted
diff --git a/builtin-diff.c b/builtin-diff.c
index 7ffea97..86f9255 100644
--- a/builtin-diff.c
+++ b/builtin-diff.c
@@ -244,6 +244,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
int nongit;
int result = 0;
+ setup_work_tree();
/*
* We could get N tree-ish in the rev.pending_objects list.
* Also there could be M blobs there, and P pathspecs.
No. git-diff has too many modes, some does not need worktree. This
forces worktree on all modes.
Ah, yes. I just wanted to say that I forgot do a 'make test' and
actually this breaks at least t0020-crlf.sh. I'll post a fixed patch in
a bit.
Sorry.
This makes it possible to use git diff when we are outside the repo but
--work-tree and --git-dir is used.
Signed-off-by: Miklos Vajna <redacted>
---
builtin-diff-files.c | 1 +
builtin-diff-index.c | 2 ++
builtin-diff.c | 1 +
3 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/builtin-diff.c b/builtin-diff.c
index 7ffea97..57da6ed 100644
--- a/builtin-diff.c
+++ b/builtin-diff.c
@@ -279,6 +279,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix) diff_no_index(&rev, argc, argv, nongit, prefix); /* Otherwise, we are doing the usual "git" diff */ + setup_work_tree(); rev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index; if (nongit)
At least builtin_diff_blobs() and builtin_diff_tree() won't need
worktree, so NACK again. Anyway I'm not familiar with diff*. Junio
should know these better.
--
Duy