Re: being nice to patch(1)

3 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: being nice to patch(1)

From: David Kastrup <hidden>
Date: 2016-06-15 22:43:19

Johannes Schindelin [off-list ref] writes:
Hi David,

[please Cc me, since I will be more likely to miss replies if you do not]

On Tue, 3 Jul 2007, David Kastrup wrote:
quoted
Johannes Schindelin [off-list ref] writes:
quoted
But maybe they would be willing to install git to get that wonderful 
git-apply program, and that wonderful rename-and-mode-aware git-diff, 
and the git-merge-file program, all of which can operate outside of a 
git repository. (Take that, hg!)
As long as git-diff lists all added files in a second non-git dirtree
as "/dev/null" when doing
git-diff --name-status -B -M -C dir1 dir2
its usefulness is limited.

git-diff --name-status -B -M -C dir1 dir2
D	dir1/auctex-11.84/CHANGES
D	dir1/auctex-11.84/COPYING
D	dir1/auctex-11.84/ChangeLog

[...]
Yes, directories are a problem. There our DWIMery does not really help. 
But there is a solution: say

	git diff --name-status --no-index -B -M -C dir1 dir2
It would help if you actually read what you are replying to.  The
problem is that added files are listed as "/dev/null", and --no-index
does not make a difference here.  It actually makes no apparent
difference at all when outside of a non-git dirtree.  Hardly
surprising, since no index file that could be consulted is present in
the first place.

The output still is (editing somewhat more so that it becomes even
more obvious):

git-diff -B -M -C --no-index --name-status dir1 dir2
D	dir1/auctex-11.84/CHANGES

[...]

A	/dev/null
A	/dev/null
R100	dir1/auctex-11.84/images/amstex.xpm	dir2/etc/auctex/images/amstex.xpm

[...]

_All_ lines starting in A end with /dev/null.

-- 
David Kastrup

[PATCH] diff --no-index: fix --name-status with added files

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:43:19

Without this patch, an added file would be reported as /dev/null.

Noticed by David Kastrup.

Signed-off-by: Johannes Schindelin <redacted>
---

	Would be nice, next time, to have a bug report which is not 
	embedded in a thread.

 diff.c                                   |    3 ++-
 t/t4013-diff-various.sh                  |    2 ++
 t/t4013/diff.diff_--name-status_dir2_dir |    3 +++
 3 files changed, 7 insertions(+), 1 deletions(-)
 create mode 100644 t/t4013/diff.diff_--name-status_dir2_dir
diff --git a/diff.c b/diff.c
index b6eb72b..1958970 100644
--- a/diff.c
+++ b/diff.c
@@ -2418,7 +2418,8 @@ static void diff_flush_raw(struct diff_filepair *p,
 		printf("%s ",
 		       diff_unique_abbrev(p->two->sha1, abbrev));
 	}
-	printf("%s%c%s", status, inter_name_termination, path_one);
+	printf("%s%c%s", status, inter_name_termination,
+			two_paths || p->one->mode ?  path_one : path_two);
 	if (two_paths)
 		printf("%c%s", inter_name_termination, path_two);
 	putchar(line_termination);
diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh
index b453b42..9eec754 100755
--- a/t/t4013-diff-various.sh
+++ b/t/t4013-diff-various.sh
@@ -17,6 +17,7 @@ test_expect_success setup '
 	export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
 
 	mkdir dir &&
+	mkdir dir2 &&
 	for i in 1 2 3; do echo $i; done >file0 &&
 	for i in A B; do echo $i; done >dir/sub &&
 	cat file0 >file2 &&
@@ -254,6 +255,7 @@ diff --patch-with-stat initial..side
 diff --patch-with-raw initial..side
 diff --patch-with-stat -r initial..side
 diff --patch-with-raw -r initial..side
+diff --name-status dir2 dir
 EOF
 
 test_done
diff --git a/t/t4013/diff.diff_--name-status_dir2_dir b/t/t4013/diff.diff_--name-status_dir2_dir
new file mode 100644
index 0000000..ef7fdb7
--- /dev/null
+++ b/t/t4013/diff.diff_--name-status_dir2_dir
@@ -0,0 +1,3 @@
+$ git diff --name-status dir2 dir
+A	dir/sub
+$
-- 
1.5.3.rc0.2637.g1dd84-dirty

Re: being nice to patch(1)

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:43:19

Hi,

On Tue, 3 Jul 2007, David Kastrup wrote:
It would help if you actually read what you are replying to.
Actually, your second explanation helped. Fix posted separately.

Ciao,
Dscho
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help