contrib/diffall: change comment to reflect actual reason for 'cdup'
PATCH 1/4 contrib/diffall: change comment to reflect actual reason for 'cdup'
The comment from an earlier commit did not reflect the actual reason this operation is needed.
--- contrib/diffall/git-diffall | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
contrib/diffall/git-diffall +3 -1
@@ -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"
Signature · 1 line
1.7.10.rc0
PATCH 2/4 contrib/diffall: teach diffall to create tmp dirs without using mktemp
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.
--- contrib/diffall/git-diffall | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
contrib/diffall/git-diffall +4 -7
@@ -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=
Signature · 1 line
1.7.10.rc0
PATCH 3/4 contrib/diffall: teach diffall to handle working copy changes without tar
In reply to Tim HeniganThe '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.
--- contrib/diffall/git-diffall | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
contrib/diffall/git-diffall +8 -4
@@ -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
Signature · 1 line
1.7.10.rc0
PATCH 4/4 contrib/diffall: eliminate duplicate while loops
In reply to Tim HeniganThere 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.
--- contrib/diffall/git-diffall | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-)
contrib/diffall/git-diffall +9 -15
@@ -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
Signature · 1 line
1.7.10.rc0
Quoted 7 lines · Tim Henigan
The comment from an earlier commit did not reflect the actual reason this operation is needed.
Signed-off-by Tim Henigan <[email protected]>---
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