From 6e2dda35c2f012298f4f4759db2d651ef18e39a0 Mon Sep 17 00:00:00 2001 From: Robert Suetterlin Date: Thu, 22 Sep 2005 10:07:36 +1000 Subject: [PATCH 01/10] [PATCH] Add new keybindings This adds several new keybindings to allow history and selectline navigation. I basically added Opera-like history traversal, as well as left-right-cursor history traversal and vi-like motion commands. Signed-off-by: Robert Suetterlin Signed-off-by: Paul Mackerras --- gitk | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gitk b/gitk index df86dceba0..bd10f7dcf0 100755 --- a/gitk +++ b/gitk @@ -1,6 +1,6 @@ #!/bin/sh # Tcl ignores the next line -*- tcl -*- \ -exec wish "$0" -- "${1+$@}" +exec wish8.4 "$0" -- "${1+$@}" # Copyright (C) 2005 Paul Mackerras. All rights reserved. # This program is free software; it may be used, copied, modified @@ -486,6 +486,8 @@ proc makewindow {} { bindall "allcanvs scan dragto 0 %y" bind . "selnextline -1" bind . "selnextline 1" + bind . "goforw" + bind . "goback" bind . "allcanvs yview scroll -1 pages" bind . "allcanvs yview scroll 1 pages" bindkey "$ctext yview scroll -1 pages" @@ -493,6 +495,12 @@ proc makewindow {} { bindkey "$ctext yview scroll 1 pages" bindkey p "selnextline -1" bindkey n "selnextline 1" + bindkey z "goback" + bindkey x "goforw" + bindkey i "selnextline -1" + bindkey k "selnextline 1" + bindkey j "goback" + bindkey l "goforw" bindkey b "$ctext yview scroll -1 pages" bindkey d "$ctext yview scroll 18 units" bindkey u "$ctext yview scroll -18 units" From a69875318bf5f7a493ecb77c63073ee18f8ad557 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Mon, 26 Sep 2005 10:22:43 +1000 Subject: [PATCH 02/10] Change wish8.4 back to wish Checking in the change from wish to wish8.4 was a mistake; I had changed it for a test but forgot to change it back before checking in a patch. --- gitk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitk b/gitk index bd10f7dcf0..aa083dc47f 100755 --- a/gitk +++ b/gitk @@ -1,6 +1,6 @@ #!/bin/sh # Tcl ignores the next line -*- tcl -*- \ -exec wish8.4 "$0" -- "${1+$@}" +exec wish "$0" -- "${1+$@}" # Copyright (C) 2005 Paul Mackerras. All rights reserved. # This program is free software; it may be used, copied, modified From 9e026d3967776a1c1206890492ffc9d172bf1e9b Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Tue, 27 Sep 2005 10:29:41 +1000 Subject: [PATCH 03/10] Use "$@" rather than "${1+$@}" when invoking wish. --- gitk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitk b/gitk index aa083dc47f..f1ea4e1e43 100755 --- a/gitk +++ b/gitk @@ -1,6 +1,6 @@ #!/bin/sh # Tcl ignores the next line -*- tcl -*- \ -exec wish "$0" -- "${1+$@}" +exec wish "$0" -- "$@" # Copyright (C) 2005 Paul Mackerras. All rights reserved. # This program is free software; it may be used, copied, modified From 036a72d8fa25d9c56c19ae4c761401a58c43b8f6 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 26 Sep 2005 17:17:09 -0700 Subject: [PATCH 04/10] git-clone: check out "master" by default. And with -n flag you can tell it not to. Signed-off-by: Junio C Hamano --- git-clone.sh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/git-clone.sh b/git-clone.sh index a322a45995..71431319c0 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -9,7 +9,7 @@ unset CDPATH usage() { - echo >&2 "* git clone [-l [-s]] [-q] [-u ] " + echo >&2 "* git clone [-l [-s]] [-q] [-u ] [-n] " exit 1 } @@ -61,10 +61,12 @@ Perhaps git-update-server-info needs to be run there?" quiet= use_local=no local_shared=no +no_checkout= upload_pack= while case "$#,$1" in 0,*) break ;; + *,-n) no_checkout=yes ;; *,-l|*,--l|*,--lo|*,--loc|*,--loca|*,--local) use_local=yes ;; *,-s|*,--s|*,--sh|*,--sha|*,--shar|*,--share|*,--shared) local_shared=yes ;; @@ -186,9 +188,16 @@ yes,yes) ;; esac -# Update origin. -mkdir -p "$D/.git/remotes/" && -rm -f "$D/.git/remotes/origin" && -echo >"$D/.git/remotes/origin" \ -"URL: $repo +cd $D || exit + +if test -f ".git/HEAD" +then + mkdir -p .git/remotes || exit + echo >.git/remotes/origin \ + "URL: $repo Pull: master:origin" + case "$no_checkout" in + '') + git checkout + esac +fi From a935824036dc2c5a8ef1980a4b05a12228712754 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 23 Sep 2005 00:43:04 -0700 Subject: [PATCH 05/10] Fix overzealous cleanliness check in git-merge Being able to try multiple strategies and automatically picking one that seems to give less conflicting result may or may not much sense in practice. At least that should not force normal use case to additionally require the working tree to be fully clean. As Linus shouted, local changes do not matter unless they interfere with the merge. This commit changes git-merge not to require a clean working tree. Only when we will iterate through more than one merge strategies, local changes are stashed away before trying the first merge, and restored before second and later merges are attempted. The index file must be in sync with HEAD in any case -- otherwise the merge result would contain changes since HEAD that was done locally and registered in the index. This check is already enforced by three-way read-tree existing merge strategies use, but is done here as a safeguard as well. Signed-off-by: Junio C Hamano --- git-merge.sh | 68 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 18 deletions(-) diff --git a/git-merge.sh b/git-merge.sh index 41bc6d9561..413bfcae9f 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -18,8 +18,19 @@ all_strategies='recursive octopus resolve stupid' default_strategies='resolve octopus' use_strategies= -dropheads() { - rm -f -- "$GIT_DIR/MERGE_HEAD" || exit 1 +dropsave() { + rm -f -- "$GIT_DIR/MERGE_HEAD" \ + "$GIT_DIR/MERGE_SAVE" || exit 1 +} + +savestate() { + git diff -r -z --name-only $head | cpio -0 -o >"$GIR_DIR/MERGE_SAVE" +} + +restorestate() { + git reset --hard $head + cpio -iuv <"$GIT_DIR/MERGE_SAVE" + git-update-index --refresh >/dev/null } summary() { @@ -93,7 +104,7 @@ case "$#,$common" in # If head can reach all the merge then we are up to date. # but first the most common case of merging one remote echo "Already up-to-date. Yeeah!" - dropheads + dropsave exit 0 ;; 1,"$head") @@ -103,7 +114,7 @@ case "$#,$common" in git-read-tree -u -m $head "$1" || exit 1 git-rev-parse --verify "$1^0" > "$GIT_DIR/HEAD" summary "$1" - dropheads + dropsave exit 0 ;; 1,*) @@ -125,30 +136,51 @@ case "$#,$common" in if test "$up_to_date" = t then echo "Already up-to-date. Yeeah!" - dropheads + dropsave exit 0 fi ;; esac -# At this point we need a real merge. Require that the tree matches -# exactly our head. +# At this point, we need a real merge. No matter what strategy +# we use, it would operate on the index, possibly affecting the +# working tree, and when resolved cleanly, have the desired tree +# in the index -- this means that the index must be in sync with +# the $head commit. +files=$(git-diff-index --cached --name-only $head) || exit +if [ "$files" ]; then + echo >&2 "Dirty index: cannot merge (dirty: $files)" + exit 1 +fi -git-update-index --refresh && -test '' = "`git-diff-index --cached --name-only $head`" || { - die "Need real merge but the working tree has local changes." -} +case "$use_strategies" in +?*' '?*) + # Stash away the local changes so that we can try more than one. + savestate + single_strategy=no + ;; +*) + single_strategy=yes + ;; +esac result_tree= best_cnt=-1 best_strategy= wt_strategy= for strategy in $use_strategies do test "$wt_strategy" = '' || { echo "Rewinding the tree to pristine..." - git reset --hard $head + restorestate } - echo "Trying merge strategy $strategy..." + case "$single_strategy" in + no) + echo "Trying merge strategy $strategy..." + ;; + esac + + # Remember which strategy left the state in the working tree wt_strategy=$strategy - git-merge-$strategy $common -- $head_arg "$@" || { + + git-merge-$strategy $common -- "$head_arg" "$@" || { # The backend exits with 1 when conflicts are left to be resolved, # with 2 when it does not handle the given merge at all. @@ -186,14 +218,14 @@ then echo "Committed merge $result_commit, made by $wt_strategy." echo $result_commit >"$GIT_DIR/HEAD" summary $result_commit - dropheads + dropsave exit 0 fi # Pick the result from the best strategy and have the user fix it up. case "$best_strategy" in '') - git reset --hard $head + restorestate die "No merge strategy handled the merge." ;; "$wt_strategy") @@ -201,9 +233,9 @@ case "$best_strategy" in ;; *) echo "Rewinding the tree to pristine..." - git reset --hard $head + restorestate echo "Using the $best_strategy to prepare resolving by hand." - git-merge-$best_strategy $common -- $head_arg "$@" + git-merge-$best_strategy $common -- "$head_arg" "$@" ;; esac for remote From e2f5f6ef6795c880a2f13ea472b96704b4a4ca94 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 24 Sep 2005 22:52:32 -0700 Subject: [PATCH 06/10] Do not require clean tree when reverting and cherry-picking. My stupidity deserved to be yelled at by Linus ... there is no reason to require the working tree to be clean when merging -- the only requirements are index to match HEAD commit and the paths involved in merge are up to date in the working tree. Revert and cherry-pick are just specialized forms of merge, and the requirements should be the same. Remove the 'general purpose routine to make sure tree is clean' from git-sh-setup, to prevent me from getting tempted again. Signed-off-by: Junio C Hamano --- git-revert.sh | 5 ++++- git-sh-setup.sh | 11 ----------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/git-revert.sh b/git-revert.sh index 722c4f755a..dfd914cf56 100755 --- a/git-revert.sh +++ b/git-revert.sh @@ -56,9 +56,12 @@ t) die "Your index file is unmerged." ;; *) - check_clean_tree || die "Cannot run $me from a dirty tree." head=$(git-rev-parse --verify HEAD) || die "You do not have a valid HEAD" + files=$(git-diff-index --cached --name-only $head) || exit + if [ "$files" ]; then + die "Dirty index: cannot $me (dirty: $files)" + fi ;; esac diff --git a/git-sh-setup.sh b/git-sh-setup.sh index d5bfa62dee..55db795843 100755 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -17,17 +17,6 @@ die() { exit 1 } -check_clean_tree() { - dirty1_=`git-update-index -q --refresh` && { - dirty2_=`git-diff-index --name-only --cached HEAD` - case "$dirty2_" in '') : ;; *) (exit 1) ;; esac - } || { - echo >&2 "$dirty1_" - echo "$dirty2_" | sed >&2 -e 's/^/modified: /' - (exit 1) - } -} - [ -h "$GIT_DIR/HEAD" ] && [ -d "$GIT_DIR/refs" ] && [ -d "$GIT_OBJECT_DIRECTORY/00" ] From deca7e8c591608c9ffd0bf0aaf10b379da9f6d6e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 25 Sep 2005 00:12:06 -0700 Subject: [PATCH 07/10] Give default merge message after failed automerge. Signed-off-by: Junio C Hamano --- git-commit.sh | 3 +++ git-merge.sh | 14 ++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/git-commit.sh b/git-commit.sh index d8bfc3c254..9412840d8f 100755 --- a/git-commit.sh +++ b/git-commit.sh @@ -141,6 +141,9 @@ t) esac if [ -f "$GIT_DIR/MERGE_HEAD" ]; then + + test -f "$GIT_DIR/MERGE_MSG" && cat "$GIT_DIR/MERGE_MSG" + echo "#" echo "# It looks like your may be committing a MERGE." echo "# If this is not correct, please remove the file" diff --git a/git-merge.sh b/git-merge.sh index 413bfcae9f..7607e819c3 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -19,7 +19,7 @@ default_strategies='resolve octopus' use_strategies= dropsave() { - rm -f -- "$GIT_DIR/MERGE_HEAD" \ + rm -f -- "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/MERGE_MSG" \ "$GIT_DIR/MERGE_SAVE" || exit 1 } @@ -28,9 +28,12 @@ savestate() { } restorestate() { - git reset --hard $head - cpio -iuv <"$GIT_DIR/MERGE_SAVE" - git-update-index --refresh >/dev/null + if test -f "$GIT_DIR/MERGE_SAVE" + then + git reset --hard $head + cpio -iuv <"$GIT_DIR/MERGE_SAVE" + git-update-index --refresh >/dev/null + fi } summary() { @@ -160,6 +163,7 @@ case "$use_strategies" in single_strategy=no ;; *) + rm -f "$GIT_DIR/MERGE_SAVE" single_strategy=yes ;; esac @@ -242,4 +246,6 @@ for remote do echo $remote done >"$GIT_DIR/MERGE_HEAD" +echo $merge_msg >"$GIT_DIR/MERGE_MSG" + die "Automatic merge failed; fix up by hand" From 0b7a9fc971712308712fedbba404f7b448e37d45 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 25 Sep 2005 19:49:49 -0700 Subject: [PATCH 08/10] git-fetch: send informational output to >&2 consistently. Only the "Fetching ... using http" was leaking to stdout. Signed-off-by: Junio C Hamano --- git-fetch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-fetch.sh b/git-fetch.sh index 822b4cd982..e4a6a68057 100755 --- a/git-fetch.sh +++ b/git-fetch.sh @@ -178,7 +178,7 @@ do head=$(curl -nsf $curl_extra_args "$remote/$remote_name") && expr "$head" : "$_x40\$" >/dev/null || die "Failed to fetch $remote_name from $remote" - echo Fetching "$remote_name from $remote" using http + echo >&2 Fetching "$remote_name from $remote" using http git-http-fetch -v -a "$head" "$remote/" || exit ;; rsync://*) From 1e1cba6433a15d68eeca7eda7646d687714c18e3 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 26 Sep 2005 18:29:26 -0700 Subject: [PATCH 09/10] Require tk 8.4 (RPM) Signed-off-by: Junio C Hamano --- git-core.spec.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-core.spec.in b/git-core.spec.in index 61beebd61c..f643006782 100644 --- a/git-core.spec.in +++ b/git-core.spec.in @@ -9,7 +9,7 @@ URL: http://kernel.org/pub/software/scm/git/ Source: http://kernel.org/pub/software/scm/git/%{name}-%{version}.tar.gz BuildRequires: zlib-devel, openssl-devel, curl-devel %{!?_without_docs:, xmlto, asciidoc > 6.0.3} BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -Requires: rsync, rcs, curl, less, openssh-clients, python >= 2.3, tk +Requires: rsync, rcs, curl, less, openssh-clients, python >= 2.3, tk >= 2.4 %description This is a stupid (but extremely fast) directory content manager. It From 3cc35e29ec252d0dca1139106fbaa70cb9ad6ef1 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 27 Sep 2005 00:15:45 -0700 Subject: [PATCH 10/10] Really require tk 8.4 (RPM) **BLUSH** Signed-off-by: Junio C Hamano --- git-core.spec.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-core.spec.in b/git-core.spec.in index f643006782..6af5103ee6 100644 --- a/git-core.spec.in +++ b/git-core.spec.in @@ -9,7 +9,7 @@ URL: http://kernel.org/pub/software/scm/git/ Source: http://kernel.org/pub/software/scm/git/%{name}-%{version}.tar.gz BuildRequires: zlib-devel, openssl-devel, curl-devel %{!?_without_docs:, xmlto, asciidoc > 6.0.3} BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -Requires: rsync, rcs, curl, less, openssh-clients, python >= 2.3, tk >= 2.4 +Requires: rsync, rcs, curl, less, openssh-clients, python >= 2.3, tk >= 8.4 %description This is a stupid (but extremely fast) directory content manager. It