From 822f7c7349d61f6075961ce42c1bd1a85cf999e5 Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Sun, 23 Sep 2007 22:42:08 +0200 Subject: Supplant the "while case ... break ;; esac" idiom A lot of shell scripts contained stuff starting with while case "$#" in 0) break ;; esac and similar. I consider breaking out of the condition instead of the body od the loop ugly, and the implied "true" value of the non-matching case is not really obvious to humans at first glance. It happens not to be obvious to some BSD shells, either, but that's because they are not POSIX-compliant. In most cases, this has been replaced by a straight condition using "test". "case" has the advantage of being faster than "test" on vintage shells where "test" is not a builtin. Since none of them is likely to run the git scripts, anyway, the added readability should be worth the change. A few loops have had their termination condition expressed differently. Signed-off-by: David Kastrup Signed-off-by: Junio C Hamano --- git-mergetool.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-mergetool.sh') diff --git a/git-mergetool.sh b/git-mergetool.sh index 47a80553ad..a0e44f71c4 100755 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@ -268,7 +268,7 @@ merge_file () { cleanup_temp_files } -while case $# in 0) break ;; esac +while test $# != 0 do case "$1" in -t|--tool*) -- cgit v1.3 From 769f39861b73a374f116fcb913e5ff276fe92751 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 27 Sep 2007 14:41:23 -0700 Subject: Mergetool generating blank files (1.5.3) When mergetool is run from a subdirectory, "ls-files -u" nicely limits the output to conflicted files in that directory, but we need to give the full path to cat-file plumbing to grab the contents of stages. Signed-off-by: Junio C Hamano Signed-off-by: "Theodore Ts'o" --- git-mergetool.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'git-mergetool.sh') diff --git a/git-mergetool.sh b/git-mergetool.sh index a0e44f71c4..e00682a513 100755 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@ -12,6 +12,7 @@ USAGE='[--tool=tool] [file to merge] ...' SUBDIRECTORY_OK=Yes . git-sh-setup require_work_tree +prefix=$(git rev-parse --show-prefix) # Returns true if the mode reflects a symlink is_symlink () { @@ -162,9 +163,9 @@ merge_file () { local_mode=`git ls-files -u -- "$path" | awk '{if ($3==2) print $1;}'` remote_mode=`git ls-files -u -- "$path" | awk '{if ($3==3) print $1;}'` - base_present && git cat-file blob ":1:$path" > "$BASE" 2>/dev/null - local_present && git cat-file blob ":2:$path" > "$LOCAL" 2>/dev/null - remote_present && git cat-file blob ":3:$path" > "$REMOTE" 2>/dev/null + base_present && git cat-file blob ":1:$prefix$path" >"$BASE" 2>/dev/null + local_present && git cat-file blob ":2:$prefix$path" >"$LOCAL" 2>/dev/null + remote_present && git cat-file blob ":3:$prefix$path" >"$REMOTE" 2>/dev/null if test -z "$local_mode" -o -z "$remote_mode"; then echo "Deleted merge conflict for '$path':" -- cgit v1.3 From f6e0e559340af6e300b63da061fa05ff07e3d6f6 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 28 Sep 2007 21:23:22 -0400 Subject: mergetool: fix emerge when running in a subdirectory Only pass the basename of the output filename when to emerge, since emerge interprets non-absolute pathnames relative to the containing directory of the output buffer. Thanks to Kelvie Wong for pointing this out. Signed-off-by: "Theodore Ts'o" --- git-mergetool.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git-mergetool.sh') diff --git a/git-mergetool.sh b/git-mergetool.sh index e00682a513..a92019a1ed 100755 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@ -252,9 +252,9 @@ merge_file () { ;; emerge) if base_present ; then - emacs -f emerge-files-with-ancestor-command "$LOCAL" "$REMOTE" "$BASE" "$path" + emacs -f emerge-files-with-ancestor-command "$LOCAL" "$REMOTE" "$BASE" "$(basename "$path")" else - emacs -f emerge-files-command "$LOCAL" "$REMOTE" "$path" + emacs -f emerge-files-command "$LOCAL" "$REMOTE" "$(basename "$path")" fi status=$? save_backup -- cgit v1.3 From 208fe3ac7e1fd5be173cae1db4fa776390bc4e7d Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 28 Sep 2007 22:26:05 -0400 Subject: mergetool: Fix typo in options passed to kdiff3 Fix missing double hyphens in "-L1" and "-L2" Signed-off-by: "Theodore Ts'o" --- git-mergetool.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git-mergetool.sh') diff --git a/git-mergetool.sh b/git-mergetool.sh index a92019a1ed..9f4f3134b6 100755 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@ -192,10 +192,10 @@ merge_file () { case "$merge_tool" in kdiff3) if base_present ; then - (kdiff3 --auto --L1 "$path (Base)" -L2 "$path (Local)" --L3 "$path (Remote)" \ + (kdiff3 --auto --L1 "$path (Base)" --L2 "$path (Local)" --L3 "$path (Remote)" \ -o "$path" -- "$BASE" "$LOCAL" "$REMOTE" > /dev/null 2>&1) else - (kdiff3 --auto -L1 "$path (Local)" --L2 "$path (Remote)" \ + (kdiff3 --auto --L1 "$path (Local)" --L2 "$path (Remote)" \ -o "$path" -- "$LOCAL" "$REMOTE" > /dev/null 2>&1) fi status=$? -- cgit v1.3