From: Stefan Beller <hidden> Date: 2016-06-15 22:58:09
addr doesn't need to be checked at that line as it it already accessed
7 lines before in the if (addr->sa_family).
Signed-off-by: Stefan Beller <redacted>
---
daemon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Stefan Beller <hidden> Date: 2016-06-15 22:58:09
The date variable is assigned new memory via xmemdupz and 2 lines later
it is assigned new memory again via xmalloc, but the first assignment
is never freed nor used.
Signed-off-by: Stefan Beller <redacted>
---
builtin/commit.c | 1 -
1 file changed, 1 deletion(-)
@@ -181,19 +181,18 @@ static int queue_diff(struct diff_options *o,}}voiddiff_no_index(structrev_info*revs,intargc,constchar**argv,intnongit,constchar*prefix){inti,prefixlen;intno_index=0;-unsignedoptions=0;constchar*paths[2];/* Were we asked to do --no-index explicitly? */for(i=1;i<argc;i++){if(!strcmp(argv[i],"--")){i++;break;}if(!strcmp(argv[i],"--no-index"))
From: Jonathan Nieder <hidden> Date: 2016-06-15 22:58:09
Hi,
Stefan Beller wrote:
addr doesn't need to be checked at that line as it it already accessed
7 lines before in the if (addr->sa_family).
Good catch. This asymmetry has been present since the lines were first
introduced (all guarded by "if (addr)") in v1.4.1-rc1~3^2~4 (Log peer
address when git-daemon called from inetd, 2006-06-20).
From: Jonathan Nieder <hidden> Date: 2016-06-15 22:58:09
Stefan Beller wrote:
[Subject: diff-no-index: Remove unused variable.]
[...]
quoted hunk
--- a/diff-no-index.c+++ b/diff-no-index.c
[...]
- else if (!strcmp(argv[i], "-q")) {
+ else if (!strcmp(argv[i], "-q"))
- options |= DIFF_SILENT_ON_REMOVED;
i++;
- }
This feature was obviously never tested with --no-index, so I agree it
makes sense to remove it. Probably the commit message and a comment
should say so, though. E.g.:
diff --no-index: remove nonfunctional "-q" handling
Before v1.5.6-rc1~41^2~2, the option parsing for diff --no-index
and "git diff-files" shared code. In "git diff-files", "-q" means
to be silent about removed files. In "git diff --no-index", in
various versions it has been an error, an infinite loop, or a no-op.
Simplify the code to clarify that it is now a no-op, continuing to
accept and ignore the -q option in "git diff --no-index" to avoid
breaking scripts.
I wouldn't mind removing support for "-q" altogether, by the way (as a
separate change).
Hope that helps,
Jonathan
From: Stefan Beller <hidden> Date: 2016-06-15 22:58:11
On 07/15/2013 12:07 AM, Jonathan Nieder wrote:
This feature was obviously never tested with --no-index, so I agree it
makes sense to remove it. Probably the commit message and a comment
should say so, though. E.g.:
diff --no-index: remove nonfunctional "-q" handling
Before v1.5.6-rc1~41^2~2, the option parsing for diff --no-index
and "git diff-files" shared code. In "git diff-files", "-q" means
to be silent about removed files. In "git diff --no-index", in
various versions it has been an error, an infinite loop, or a no-op.
Simplify the code to clarify that it is now a no-op, continuing to
accept and ignore the -q option in "git diff --no-index" to avoid
breaking scripts.
I wouldn't mind removing support for "-q" altogether, by the way (as a
separate change).
Hope that helps,
Jonathan
I am resending the commit with a different wording, thanks to Jonathan.
However I tried to remove support for -q in a separate commit, and
I have some questions about the structure of the files.
(I am sure it's documented, but I cannot find it, so please hint me
where to read.)
The changes in the following patch are in diff_no_index.c, but the
diff_no_index(...) is called from cmd_diff, which is in builtin/diff.c
That cmd_diff is actually called from git.c having the
{ "diff", cmd_diff }, entry in handle_internal_command.
My question now is this: Why is the builtin/diff.c relying on stuff
outside of builtin/ ? Wouldn't it be better to move all these files
(such as diff_no_index.c) into the builtin folder as well?
Regarding the removal of the -q option, I tried it in the second patch.
Is it as easy as that, or am I missing the point?
The first patch doesn't change the behavior, so I'd assume it's safe to
apply it to origin/sb/misc-fixes, whereas the second patch will make
git diff complain about the -q option, so I'd assume it would wait for the
next major release?
Before:
touch actual_file
git diff -q actual_file no_file
error: Could not access 'no_file'
echo $?
1
After:
touch actual_file
git diff -q actual_file no_file
fatal: invalid diff option/value: -q
echo $?
128
Thanks,
Stefan
Stefan Beller (2):
diff --no-index: remove nonfunctional "-q" handling
git diff: Remove -q option to stay silent on missing files.
Documentation/git-diff-files.txt | 6 +-----
diff-no-index.c | 5 -----
2 files changed, 1 insertion(+), 10 deletions(-)
--
1.8.2.3.10.g2733812
From: Stefan Beller <hidden> Date: 2016-06-15 22:58:11
Before v1.5.6-rc1~41^2~2, the option parsing for diff --no-index
and "git diff-files" shared code. In "git diff-files", "-q" means
to be silent about removed files. In "git diff --no-index", in
various versions it has been an error, an infinite loop, or a no-op.
Simplify the code to clarify that it is now a no-op, continuing to
accept and ignore the -q option in "git diff --no-index" to avoid
breaking scripts.
Signed-off-by: Stefan Beller <redacted>
Helped-by: Jonathan Nieder [off-list ref]
---
diff-no-index.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
@@ -187,7 +187,6 @@ void diff_no_index(struct rev_info *revs,{inti,prefixlen;intno_index=0;-unsignedoptions=0;constchar*paths[2];/* Were we asked to do --no-index explicitly? */
From: Stefan Beller <hidden> Date: 2016-06-15 22:58:11
This feature was not tested in the test suite, hence we'd remove it for
now. It doesn't seem to be often used anyway.
A google search for "git diff -q" (match string exactly) only returned
http://stackoverflow.com/questions/11021287/git-detect-if-there-are-untracked-files-quickly
where "git diff -q" was quoted for its exit code behavior regarding files
being found or not.
Signed-off-by: Stefan Beller <redacted>
Proposed-by: <Jonathan Nieder> [off-list ref]
---
Documentation/git-diff-files.txt | 6 +-----
diff-no-index.c | 2 --
2 files changed, 1 insertion(+), 7 deletions(-)
@@ -9,7 +9,7 @@ git-diff-files - Compares files in the working tree and the index SYNOPSIS -------- [verse]-'git diff-files' [-q] [-0|-1|-2|-3|-c|--cc] [<common diff options>] [<path>...]+'git diff-files' [-0|-1|-2|-3|-c|--cc] [<common diff options>] [<path>...] DESCRIPTION -----------
@@ -41,10 +41,6 @@ omit diff output for unmerged entries and just show "Unmerged". diff, similar to the way 'diff-tree' shows a merge commit with these flags.--q::- Remain silent even on nonexistent files-- include::diff-format.txt[] GIT