git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] contrib/diffall: change comment to reflect actual reason for 'cdup'
@ 2012-03-13 17:45 Tim Henigan
  2012-03-13 17:45 ` [PATCH 2/4] contrib/diffall: teach diffall to create tmp dirs without using mktemp Tim Henigan
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Tim Henigan @ 2012-03-13 17:45 UTC (permalink / raw)
  To: git, gitster; +Cc: tim.henigan

The comment from an earlier commit did not reflect the actual reason this
operation is needed.

Signed-off-by: Tim Henigan <tim.henigan@gmail.com>
---
 contrib/diffall/git-diffall |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/contrib/diffall/git-diffall b/contrib/diffall/git-diffall
index 9bbd27f..d706a6d 100755
--- a/contrib/diffall/git-diffall
+++ b/contrib/diffall/git-diffall
@@ -36,7 +36,9 @@ fi
 
 start_dir=$(pwd)
 
-# needed to access tar utility
+# All the file paths returned by the diff command are relative to the root
+# of the working copy. So if the script is called from a subdirectory, it
+# must switch to the root of working copy before trying to use those paths.
 cdup=$(git rev-parse --show-cdup) &&
 cd "$cdup" || {
 	echo >&2 "Cannot chdir to $cdup, the toplevel of the working tree"
-- 
1.7.10.rc0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] contrib/diffall: teach diffall to create tmp dirs without using mktemp
  2012-03-13 17:45 [PATCH 1/4] contrib/diffall: change comment to reflect actual reason for 'cdup' Tim Henigan
@ 2012-03-13 17:45 ` Tim Henigan
  2012-03-13 17:45 ` [PATCH 3/4] contrib/diffall: teach diffall to handle working copy changes without tar Tim Henigan
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Tim Henigan @ 2012-03-13 17:45 UTC (permalink / raw)
  To: git, gitster; +Cc: tim.henigan

mktemp is not available on all platforms.  Instead of littering the code
with a work-around, this commit replaces mktemp with a one-line Perl
script.

Signed-off-by: Tim Henigan <tim.henigan@gmail.com>
---
 contrib/diffall/git-diffall |   11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/contrib/diffall/git-diffall b/contrib/diffall/git-diffall
index d706a6d..443f646 100755
--- a/contrib/diffall/git-diffall
+++ b/contrib/diffall/git-diffall
@@ -45,13 +45,10 @@ cd "$cdup" || {
 	exit 1
 }
 
-# mktemp is not available on all platforms (missing from msysgit)
-# Use a hard-coded tmp dir if it is not available
-tmp="$(mktemp -d -t tmp.XXXXXX 2>/dev/null)" || {
-	tmp=/tmp/git-diffall-tmp.$$
-	mkdir "$tmp" || exit 1
-}
-
+# set up temp dir
+tmp=$(perl -e 'use File::Temp qw(tempdir);
+	$t=tempdir("/tmp/git-diffall.XXXXX") or exit(1);
+	print $t') || exit 1
 trap 'rm -rf "$tmp" 2>/dev/null' EXIT
 
 left=
-- 
1.7.10.rc0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] contrib/diffall: teach diffall to handle working copy changes without tar
  2012-03-13 17:45 [PATCH 1/4] contrib/diffall: change comment to reflect actual reason for 'cdup' Tim Henigan
  2012-03-13 17:45 ` [PATCH 2/4] contrib/diffall: teach diffall to create tmp dirs without using mktemp Tim Henigan
@ 2012-03-13 17:45 ` Tim Henigan
  2012-03-13 17:45 ` [PATCH 4/4] contrib/diffall: eliminate duplicate while loops Tim Henigan
  2012-03-13 17:49 ` [PATCH 1/4] contrib/diffall: change comment to reflect actual reason for 'cdup' Tim Henigan
  3 siblings, 0 replies; 5+ messages in thread
From: Tim Henigan @ 2012-03-13 17:45 UTC (permalink / raw)
  To: git, gitster; +Cc: tim.henigan

The 'tar' utility is not available on all platforms (some only support
'gnutar').  An earlier commit created a work-around for this problem,
but a better solution is to eliminate the use of 'tar' completely.

Signed-off-by: Tim Henigan <tim.henigan@gmail.com>
---
 contrib/diffall/git-diffall |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/contrib/diffall/git-diffall b/contrib/diffall/git-diffall
index 443f646..8d243c7 100755
--- a/contrib/diffall/git-diffall
+++ b/contrib/diffall/git-diffall
@@ -202,10 +202,14 @@ then
 		fi
 	done < "$tmp/filelist"
 else
-	# Mac users have gnutar rather than tar
-	(tar --ignore-failed-read -c -T "$tmp/filelist" | (cd "$tmp/$right_dir" && tar -x)) || {
-		gnutar --ignore-failed-read -c -T "$tmp/filelist" | (cd "$tmp/$right_dir" && gnutar -x)
-	}
+	while read name
+	do
+		if test -e "$name"
+		then
+			mkdir -p "$tmp/$right_dir/$(dirname "$name")"
+			cp "$name" "$tmp/$right_dir"
+		fi
+	done < "$tmp/filelist"
 fi
 
 # Populate the tmp/left_dir directory with the files to be compared
-- 
1.7.10.rc0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] contrib/diffall: eliminate duplicate while loops
  2012-03-13 17:45 [PATCH 1/4] contrib/diffall: change comment to reflect actual reason for 'cdup' Tim Henigan
  2012-03-13 17:45 ` [PATCH 2/4] contrib/diffall: teach diffall to create tmp dirs without using mktemp Tim Henigan
  2012-03-13 17:45 ` [PATCH 3/4] contrib/diffall: teach diffall to handle working copy changes without tar Tim Henigan
@ 2012-03-13 17:45 ` Tim Henigan
  2012-03-13 17:49 ` [PATCH 1/4] contrib/diffall: change comment to reflect actual reason for 'cdup' Tim Henigan
  3 siblings, 0 replies; 5+ messages in thread
From: Tim Henigan @ 2012-03-13 17:45 UTC (permalink / raw)
  To: git, gitster; +Cc: tim.henigan

There were 3 instances of a 'while read; do' that used identical logic
to populate '/tmp/right_dir'. This commit groups them into a single loop.

Signed-off-by: Tim Henigan <tim.henigan@gmail.com>
---
 contrib/diffall/git-diffall |   24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/contrib/diffall/git-diffall b/contrib/diffall/git-diffall
index 8d243c7..b1afefe 100755
--- a/contrib/diffall/git-diffall
+++ b/contrib/diffall/git-diffall
@@ -179,38 +179,32 @@ fi
 mkdir -p "$tmp/$left_dir" "$tmp/$right_dir"
 
 # Populate the tmp/right_dir directory with the files to be compared
-if test -n "$right"
-then
-	while read name
-	do
+while read name
+do
+	if test -n "$right"
+	then
 		ls_list=$(git ls-tree $right "$name")
 		if test -n "$ls_list"
 		then
 			mkdir -p "$tmp/$right_dir/$(dirname "$name")"
 			git show "$right":"$name" >"$tmp/$right_dir/$name" || true
 		fi
-	done < "$tmp/filelist"
-elif test -n "$compare_staged"
-then
-	while read name
-	do
+	elif test -n "$compare_staged"
+	then
 		ls_list=$(git ls-files -- "$name")
 		if test -n "$ls_list"
 		then
 			mkdir -p "$tmp/$right_dir/$(dirname "$name")"
 			git show :"$name" >"$tmp/$right_dir/$name"
 		fi
-	done < "$tmp/filelist"
-else
-	while read name
-	do
+	else
 		if test -e "$name"
 		then
 			mkdir -p "$tmp/$right_dir/$(dirname "$name")"
 			cp "$name" "$tmp/$right_dir"
 		fi
-	done < "$tmp/filelist"
-fi
+	fi
+done < "$tmp/filelist"
 
 # Populate the tmp/left_dir directory with the files to be compared
 while read name
-- 
1.7.10.rc0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/4] contrib/diffall: change comment to reflect actual reason for 'cdup'
  2012-03-13 17:45 [PATCH 1/4] contrib/diffall: change comment to reflect actual reason for 'cdup' Tim Henigan
                   ` (2 preceding siblings ...)
  2012-03-13 17:45 ` [PATCH 4/4] contrib/diffall: eliminate duplicate while loops Tim Henigan
@ 2012-03-13 17:49 ` Tim Henigan
  3 siblings, 0 replies; 5+ messages in thread
From: Tim Henigan @ 2012-03-13 17:49 UTC (permalink / raw)
  To: git, gitster; +Cc: tim.henigan

On Tue, Mar 13, 2012 at 1:45 PM, Tim Henigan <tim.henigan@gmail.com> wrote:
> The comment from an earlier commit did not reflect the actual reason this
> operation is needed.
>
> Signed-off-by: Tim Henigan <tim.henigan@gmail.com>
> ---
>  contrib/diffall/git-diffall |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Junio - I had a typo in your email address when I sent this patch
series.  Sorry for the confusion.

Best regards,
Tim

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-03-13 17:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-13 17:45 [PATCH 1/4] contrib/diffall: change comment to reflect actual reason for 'cdup' Tim Henigan
2012-03-13 17:45 ` [PATCH 2/4] contrib/diffall: teach diffall to create tmp dirs without using mktemp Tim Henigan
2012-03-13 17:45 ` [PATCH 3/4] contrib/diffall: teach diffall to handle working copy changes without tar Tim Henigan
2012-03-13 17:45 ` [PATCH 4/4] contrib/diffall: eliminate duplicate while loops Tim Henigan
2012-03-13 17:49 ` [PATCH 1/4] contrib/diffall: change comment to reflect actual reason for 'cdup' Tim Henigan

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 NNTP newsgroup(s).