From 6d297f81373e19d86b8f02cb68120201d1b0ab1d Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sat, 8 Jul 2006 18:42:41 +0200 Subject: Status update on merge-recursive in C This is just an update for people being interested. Alex and me were busy with that project for a few days now. While it has progressed nicely, there are quite a couple TODOs in merge-recursive.c, just search for "TODO". For impatient people: yes, it passes all the tests, and yes, according to the evil test Alex did, it is faster than the Python script. But no, it is not yet finished. Biggest points are: - there are still three external calls - in the end, it should not be necessary to write the index more than once (just before exiting) - a lot of things can be refactored to make the code easier and shorter BTW we cannot just plug in git-merge-tree yet, because git-merge-tree does not handle renames at all. This patch is meant for testing, and as such, - it compile the program to git-merge-recur - it adjusts the scripts and tests to use git-merge-recur instead of git-merge-recursive - it provides "TEST", a script to execute the tests regarding -recursive - it inlines the changes to read-cache.c (read_cache_from(), discard_cache() and refresh_cache_entry()) Brought to you by Alex Riesen and Dscho Signed-off-by: Junio C Hamano --- git-merge.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index 24e3b507ef..b26ca147c0 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -9,15 +9,15 @@ USAGE='[-n] [--no-commit] [--squash] [-s ]... < LF=' ' -all_strategies='recursive octopus resolve stupid ours' -default_twohead_strategies='recursive' +all_strategies='recur recur octopus resolve stupid ours' +default_twohead_strategies='recur' default_octopus_strategies='octopus' no_trivial_merge_strategies='ours' use_strategies= index_merge=t if test "@@NO_PYTHON@@"; then - all_strategies='resolve octopus stupid ours' + all_strategies='recur resolve octopus stupid ours' default_twohead_strategies='resolve' fi -- cgit v1.2.3 From 06d30f4f3eea71bce4cf48db3ea384976b3983b7 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 9 Jul 2006 00:42:26 -0700 Subject: recur vs recursive: help testing without touching too many stuff. During git-merge-recur development, you could set an environment variable GIT_USE_RECUR_FOR_RECURSIVE to use WIP recur in place of the recursive strategy. Signed-off-by: Junio C Hamano --- git-merge.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index b26ca147c0..9b681159dc 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -9,8 +9,13 @@ USAGE='[-n] [--no-commit] [--squash] [-s ]... < LF=' ' -all_strategies='recur recur octopus resolve stupid ours' -default_twohead_strategies='recur' +all_strategies='recursive recur octopus resolve stupid ours' +case "${GIT_USE_RECUR_FOR_RECURSIVE}" in +'') + default_twohead_strategies=recursive ;; +?*) + default_twohead_strategies=recur ;; +esac default_octopus_strategies='octopus' no_trivial_merge_strategies='ours' use_strategies= @@ -110,6 +115,10 @@ do strategy="$2" shift ;; esac + case "$strategy,${GIT_USE_RECUR_FOR_RECURSIVE}" in + recursive,?*) + strategy=recur ;; + esac case " $all_strategies " in *" $strategy "*) use_strategies="$use_strategies$strategy " ;; -- cgit v1.2.3 From a06f678eb998862ea83b73e46ece32f99132935b Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 24 Sep 2006 19:49:47 -0700 Subject: Deprecate merge-recursive.py This renames merge-recursive written in Python to merge-recursive-old, and makes merge-recur as a synonym to merge-recursive. We do not remove merge-recur yet, but we will remove merge-recur and merge-recursive-old in a few releases down the road. Signed-off-by: Junio C Hamano --- git-merge.sh | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index d049e16431..5b34b4de99 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -9,21 +9,15 @@ USAGE='[-n] [--no-commit] [--squash] [-s ]... < LF=' ' -all_strategies='recursive recur octopus resolve stupid ours' -case "${GIT_USE_RECUR_FOR_RECURSIVE}" in -'') - default_twohead_strategies=recursive ;; -?*) - default_twohead_strategies=recur ;; -esac +all_strategies='recur recursive recursive-old octopus resolve stupid ours' +default_twohead_strategies='recursive' default_octopus_strategies='octopus' no_trivial_merge_strategies='ours' use_strategies= index_merge=t if test "@@NO_PYTHON@@"; then - all_strategies='recur resolve octopus stupid ours' - default_twohead_strategies='resolve' + all_strategies='recur recursive resolve octopus stupid ours' fi dropsave() { @@ -122,10 +116,6 @@ do strategy="$2" shift ;; esac - case "$strategy,${GIT_USE_RECUR_FOR_RECURSIVE}" in - recursive,?*) - strategy=recur ;; - esac case " $all_strategies " in *" $strategy "*) use_strategies="$use_strategies$strategy " ;; -- cgit v1.2.3 From ba0ac36ec5708820e670731001f7ab35351c6c48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santi=20B=C3=A9jar?= Date: Sun, 1 Oct 2006 05:34:17 +0200 Subject: merge and resolve: Output short hashes and .. in "Updating ..." MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Santi BĂ©jar Signed-off-by: Junio C Hamano --- git-merge.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index 5b34b4de99..49c46d55df 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -197,7 +197,7 @@ f,*) ;; ?,1,"$head",*) # Again the most common case of merging one remote. - echo "Updating from $head to $1" + echo "Updating $(git-rev-parse --short $head)..$(git-rev-parse --short $1)" git-update-index --refresh 2>/dev/null new_head=$(git-rev-parse --verify "$1^0") && git-read-tree -u -v -m $head "$new_head" && -- cgit v1.2.3 From fc61e313da0a124e9f6a213cd76944a8c4e6c918 Mon Sep 17 00:00:00 2001 From: Rene Scharfe Date: Sat, 21 Oct 2006 20:51:04 +0200 Subject: git-merge: show usage if run without arguments Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- git-merge.sh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index 5b34b4de99..789f4de595 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -93,6 +93,8 @@ finish () { esac } +case "$#" in 0) usage ;; esac + rloga= while case "$#" in 0) break ;; esac do -- cgit v1.2.3 From 7cdbff14d4823c3a3d64c2011ab0b23f794efef8 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 20 Nov 2006 00:49:31 -0800 Subject: remove merge-recursive-old This frees the Porcelain-ish that comes with the core Python-free. Signed-off-by: Junio C Hamano --- git-merge.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index cb094388bb..84c3acfe63 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -9,16 +9,13 @@ USAGE='[-n] [--no-commit] [--squash] [-s ]... < LF=' ' -all_strategies='recur recursive recursive-old octopus resolve stupid ours' +all_strategies='recur recursive octopus resolve stupid ours' default_twohead_strategies='recursive' default_octopus_strategies='octopus' no_trivial_merge_strategies='ours' use_strategies= index_merge=t -if test "@@NO_PYTHON@@"; then - all_strategies='recur recursive resolve octopus stupid ours' -fi dropsave() { rm -f -- "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/MERGE_MSG" \ -- cgit v1.2.3 From 17bcdad3b7baa3b12c662663372f1e3cd560dd8e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 20 Nov 2006 01:06:09 -0800 Subject: git-merge: make it usable as the first class UI This teaches the oft-requested syntax git merge $commit to implement merging the named commit to the current branch. This hopefully would make "git merge" usable as the first class UI instead of being a mere backend for "git pull". Most notably, $commit above can be any committish, so you can say for example: git merge js/shortlog~2 to merge early part of a topic branch without merging the rest of it. A custom merge message can be given with the new --message= parameter. The message is prepended in front of the usual "Merge ..." message autogenerated with fmt-merge-message. Signed-off-by: Junio C Hamano --- git-merge.sh | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 54 insertions(+), 7 deletions(-) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index 84c3acfe63..25deb1e867 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -3,7 +3,8 @@ # Copyright (c) 2005 Junio C Hamano # -USAGE='[-n] [--no-commit] [--squash] [-s ]... +' +USAGE='[-n] [--no-commit] [--squash] [-s ] [--reflog-action=] [-m=] +' + . git-sh-setup LF=' @@ -92,7 +93,7 @@ finish () { case "$#" in 0) usage ;; esac -rloga= +rloga= have_message= while case "$#" in 0) break ;; esac do case "$1" in @@ -125,17 +126,63 @@ do --reflog-action=*) rloga=`expr "z$1" : 'z-[^=]*=\(.*\)'` ;; + -m=*|--m=*|--me=*|--mes=*|--mess=*|--messa=*|--messag=*|--message=*) + merge_msg=`expr "z$1" : 'z-[^=]*=\(.*\)'` + have_message=t + ;; + -m|--m|--me|--mes|--mess|--messa|--messag|--message) + shift + case "$#" in + 1) usage ;; + esac + merge_msg="$1" + have_message=t + ;; -*) usage ;; *) break ;; esac shift done -merge_msg="$1" -shift -head_arg="$1" -head=$(git-rev-parse --verify "$1"^0) || usage -shift +# This could be traditional "merge HEAD ..." and the +# way we can tell it is to see if the second token is HEAD, but some +# people might have misused the interface and used a committish that +# is the same as HEAD there instead. Traditional format never would +# have "-m" so it is an additional safety measure to check for it. + +if test -z "$have_message" && + second_token=$(git-rev-parse --verify "$2^0" 2>/dev/null) && + head_commit=$(git-rev-parse --verify "HEAD" 2>/dev/null) && + test "$second_token" = "$head_commit" +then + merge_msg="$1" + shift + head_arg="$1" + shift +else + # We are invoked directly as the first-class UI. + head_arg=HEAD + + # All the rest are the commits being merged; prepare + # the standard merge summary message to be appended to + # the given message. If remote is invalid we will die + # later in the common codepath so we discard the error + # in this loop. + merge_name=$(for remote + do + rh=$(git-rev-parse --verify "$remote"^0 2>/dev/null) + if git show-ref -q --verify "refs/heads/$remote" + then + what=branch + else + what=commit + fi + echo "$rh $what '$remote'" + done | git-fmt-merge-msg + ) + merge_msg="${merge_msg:+$merge_msg$LF$LF}$merge_name" +fi +head=$(git-rev-parse --verify "$head_arg"^0) || usage # All the rest are remote heads test "$#" = 0 && usage ;# we need at least one remote head. -- cgit v1.2.3 From 8092c7f6af044836abf83ed26d542327a4b95c08 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 21 Nov 2006 21:13:28 -0800 Subject: merge: allow merging into a yet-to-be-born branch. Signed-off-by: Junio C Hamano --- git-merge.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index 25deb1e867..dd4e83dede 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -159,6 +159,24 @@ then shift head_arg="$1" shift +elif ! git-rev-parse --verify HEAD 2>/dev/null +then + # If the merged head is a valid one there is no reason to + # forbid "git merge" into a branch yet to be born. We do + # the same for "git pull". + if test 1 -ne $# + then + echo >&2 "Can merge only exactly one commit into empty head" + exit 1 + fi + + rh=$(git rev-parse --verify "$1^0") || + die "$1 - not something we can merge" + + git-update-ref -m "initial pull" HEAD "$rh" "" && + git-read-tree --reset -u HEAD + exit + else # We are invoked directly as the first-class UI. head_arg=HEAD -- cgit v1.2.3 From 51901e96bf592877f7b266d0d9c6cb83b363edce Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 26 Nov 2006 22:16:31 -0800 Subject: git-merge: tighten error checking. If a branch name to be merged is misspelled, the command leaked error messages from underlying plumbing commands, which were helpful only to people who know how the command are implemented to diagnose the breakage, but simply puzzling and unhelpful for the end users. Signed-off-by: Junio C Hamano --- git-merge.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index dd4e83dede..5fa8b0d577 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -188,13 +188,13 @@ else # in this loop. merge_name=$(for remote do - rh=$(git-rev-parse --verify "$remote"^0 2>/dev/null) + rh=$(git-rev-parse --verify "$remote"^0 2>/dev/null) && if git show-ref -q --verify "refs/heads/$remote" then what=branch else what=commit - fi + fi && echo "$rh $what '$remote'" done | git-fmt-merge-msg ) @@ -209,7 +209,7 @@ test "$rloga" = '' && rloga="merge: $@" remoteheads= for remote do - remotehead=$(git-rev-parse --verify "$remote"^0) || + remotehead=$(git-rev-parse --verify "$remote"^0 2>/dev/null) || die "$remote - not something we can merge" remoteheads="${remoteheads}$remotehead " done -- cgit v1.2.3 From c1751616381b6e8c8eae311107b5969a0233a6d8 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 26 Nov 2006 22:19:42 -0800 Subject: git-merge: do not leak rev-parse output used for checking internally. Signed-off-by: Junio C Hamano --- git-merge.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index 5fa8b0d577..75af10d3e4 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -159,7 +159,7 @@ then shift head_arg="$1" shift -elif ! git-rev-parse --verify HEAD 2>/dev/null +elif ! git-rev-parse --verify HEAD >/dev/null 2>&1 then # If the merged head is a valid one there is no reason to # forbid "git merge" into a branch yet to be born. We do -- cgit v1.2.3 From 3683dc5a9afaf88d00e55c9e6c67a2160ca7fc9c Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 2 Dec 2006 16:58:30 -0800 Subject: git-merge: fix confusion between tag and branch In a repository with core.warnambiguousrefs turned off, and with a branch and a tag that have the same name 'frotz', git merge frotz would merge the commit pointed at by the tag 'frotz' but incorrectly would identify what was merged as 'branch frotz' in the merge message. Signed-off-by: Junio C Hamano --- git-merge.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index 75af10d3e4..272f004622 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -189,13 +189,13 @@ else merge_name=$(for remote do rh=$(git-rev-parse --verify "$remote"^0 2>/dev/null) && - if git show-ref -q --verify "refs/heads/$remote" + bh=$(git show-ref -s --verify "refs/heads/$remote") && + if test "$rh" = "$bh" then - what=branch + echo "$rh branch '$remote' of ." else - what=commit - fi && - echo "$rh $what '$remote'" + echo "$rh commit '$remote'" + fi done | git-fmt-merge-msg ) merge_msg="${merge_msg:+$merge_msg$LF$LF}$merge_name" -- cgit v1.2.3 From 1127148089234a6f84754f2f0ec36cbbcae06fa9 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 4 Dec 2006 16:07:57 -0800 Subject: Loosen "working file will be lost" check in Porcelain-ish This uses the previous update to read-tree in Porcelain-ish commands "git checkout" and "git merge" to loosen the check when switching branches. Signed-off-by: Junio C Hamano --- git-merge.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index 272f004622..397b33f8d3 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -264,7 +264,7 @@ f,*) echo "Updating $(git-rev-parse --short $head)..$(git-rev-parse --short $1)" git-update-index --refresh 2>/dev/null new_head=$(git-rev-parse --verify "$1^0") && - git-read-tree -u -v -m $head "$new_head" && + git-read-tree -v -m -u --exclude-per-directory=.gitignore $head "$new_head" && finish "$new_head" "Fast forward" dropsave exit 0 -- cgit v1.2.3 From 211e6eb513f372ad79fecc3db19413b3573ae962 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 6 Dec 2006 10:52:04 -0800 Subject: git-merge: squelch needless error message. While deciding if the new style command line argument is a tag or a branch, we checked it with "git show-ref -s --verify" to see if results in an error, but when it is not a branch, the check leaked the error message out, which was not needed to be shown to the end user. Signed-off-by: Junio C Hamano --- git-merge.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index 272f004622..efdbabf775 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -189,7 +189,7 @@ else merge_name=$(for remote do rh=$(git-rev-parse --verify "$remote"^0 2>/dev/null) && - bh=$(git show-ref -s --verify "refs/heads/$remote") && + bh=$(git show-ref -s --verify "refs/heads/$remote" 2>/dev/null) && if test "$rh" = "$bh" then echo "$rh branch '$remote' of ." -- cgit v1.2.3 From de51faf3888505fa3d661d4c35f32ecaf9fa1087 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 6 Dec 2006 11:22:55 -0800 Subject: git-merge: fix "fix confusion between tag and branch" for real An earlier commit 3683dc5a broke the merge message generation with a careless use of && where it was not needed, breaking the merge message for cases where non branches are given. Signed-off-by: Junio C Hamano --- git-merge.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index efdbabf775..a948878b91 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -188,8 +188,9 @@ else # in this loop. merge_name=$(for remote do - rh=$(git-rev-parse --verify "$remote"^0 2>/dev/null) && - bh=$(git show-ref -s --verify "refs/heads/$remote" 2>/dev/null) && + rh=$(git-rev-parse --verify "$remote"^0 2>/dev/null) || + continue ;# not something we can merge + bh=$(git show-ref -s --verify "refs/heads/$remote" 2>/dev/null) if test "$rh" = "$bh" then echo "$rh branch '$remote' of ." -- cgit v1.2.3 From 0c4e95d083f77de03a64b65f5633ed0ba082a26e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 13 Dec 2006 09:32:40 -0800 Subject: git merge: reword failure message. 99.9999% of the time, the command is used with a single strategy; after a merge failure, saying "No strategy handled the merge" is technically correct, but there is no point stressing we tried and failed all the possibilities the user has given. Just say that it failed. Signed-off-by: Junio C Hamano --- git-merge.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index a948878b91..2f3d936b9c 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -400,7 +400,14 @@ fi case "$best_strategy" in '') restorestate - echo >&2 "No merge strategy handled the merge." + case "$use_strategies" in + ?*' '?*) + echo >&2 "No merge strategy handled the merge." + ;; + *) + echo >&2 "Merge with strategy $use_strategies failed." + ;; + esac exit 2 ;; "$wt_strategy") -- cgit v1.2.3 From b1bfcae438adb485bb66e2f59396373809e346e6 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 16 Dec 2006 12:31:45 -0800 Subject: merge: give a bit prettier merge message to "merge branch~$n" This hacks the input to fmt-merge-msg to make the message for merging early part of a branch a little easier to read. Signed-off-by: Junio C Hamano --- git-merge.sh | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index c895a04f6b..4ebfcf65d9 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -91,6 +91,22 @@ finish () { esac } +merge_name () { + remote="$1" + rh=$(git-rev-parse --verify "$remote^0" 2>/dev/null) || return + bh=$(git-show-ref -s --verify "refs/heads/$remote" 2>/dev/null) + if test "$rh" = "$bh" + then + echo "$rh branch '$remote' of ." + elif truname=$(expr "$remote" : '\(.*\)~[1-9][0-9]*$') && + git-show-ref -q --verify "refs/heads/$truname" 2>/dev/null + then + echo "$rh branch '$truname' (early part) of ." + else + echo "$rh commit '$remote'" + fi +} + case "$#" in 0) usage ;; esac rloga= have_message= @@ -188,15 +204,7 @@ else # in this loop. merge_name=$(for remote do - rh=$(git-rev-parse --verify "$remote"^0 2>/dev/null) || - continue ;# not something we can merge - bh=$(git show-ref -s --verify "refs/heads/$remote" 2>/dev/null) - if test "$rh" = "$bh" - then - echo "$rh branch '$remote' of ." - else - echo "$rh commit '$remote'" - fi + merge_name "$remote" done | git-fmt-merge-msg ) merge_msg="${merge_msg:+$merge_msg$LF$LF}$merge_name" -- cgit v1.2.3 From 228e2eb67e9f15983519f472cc1566a3dd857f9c Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 22 Dec 2006 15:21:55 -0800 Subject: merge and reset: adjust for "reset --hard" messages An earlier commit made "reset --hard" chattier but leaking its message from "git rebase" (which calls it when first rewinding the current branch to prepare replaying our own changes) without explanation was confusing, so add an extra message to mention it. Inside restorestate in merge (which is rarely exercised codepath, where more than one strategies are attempted), resetting to the original state uses "reset --hard" -- this can be squelched entirely. Signed-off-by: Junio C Hamano --- git-merge.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index 4ebfcf65d9..aec215e725 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -32,7 +32,7 @@ savestate() { restorestate() { if test -f "$GIT_DIR/MERGE_SAVE" then - git reset --hard $head + git reset --hard $head >/dev/null cpio -iuv <"$GIT_DIR/MERGE_SAVE" git-update-index --refresh >/dev/null fi -- cgit v1.2.3 From e0ec18192db8a5f80705a81dfaa1caa3e6c48c1a Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sat, 23 Dec 2006 03:44:47 -0500 Subject: Display 'theirs' branch name when possible in merge. Displaying the SHA1 of 'their' branch (the branch being merged into the current branch) is not nearly as friendly as just displaying the name of that branch, especially if that branch is already local to this repository. git-merge now sets the environment variable 'GITHEAD_%(sha1)=%(name)' for each argument it gets passed, making the actual input name that resolved to the commit '%(sha1)' easily available to the invoked merge strategy. git-merge-recursive makes use of these environment variables when they are available by using '%(name)' whenever it outputs the commit identification rather than '%(sha1)'. This is most obvious in the conflict hunks created by xdl_merge: $ git mege sideb~1 <<<<<<< HEAD:INSTALL Good! ======= Oops. >>>>>>> sideb~1:INSTALL [jc: adjusted a test script and a minor constness glitch.] Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- git-merge.sh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index aec215e725..7dd0a11236 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -221,6 +221,8 @@ do remotehead=$(git-rev-parse --verify "$remote"^0 2>/dev/null) || die "$remote - not something we can merge" remoteheads="${remoteheads}$remotehead " + eval GITHEAD_$remotehead='"$remote"' + export GITHEAD_$remotehead done set x $remoteheads ; shift -- cgit v1.2.3 From f94741324e26af42093a89e955ff9a923abff951 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 28 Dec 2006 02:34:48 -0500 Subject: Use GIT_REFLOG_ACTION environment variable instead. Junio rightly pointed out that the --reflog-action parameter was starting to get out of control, as most porcelain code needed to hand it to other porcelain and plumbing alike to ensure the reflog contained the top-level user action and not the lower-level actions it invoked. At Junio's suggestion we are introducing the new set_reflog_action function to all shell scripts, allowing them to declare early on what their default reflog name should be, but this setting only takes effect if the caller has not already set the GIT_REFLOG_ACTION environment variable. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- git-merge.sh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index 7dd0a11236..e8db52725c 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -3,9 +3,10 @@ # Copyright (c) 2005 Junio C Hamano # -USAGE='[-n] [--no-commit] [--squash] [-s ] [--reflog-action=] [-m=] +' +USAGE='[-n] [--no-commit] [--squash] [-s ] [-m=] +' . git-sh-setup +set_reflog_action "merge $*" LF=' ' @@ -57,10 +58,10 @@ squash_message () { finish () { if test '' = "$2" then - rlogm="$rloga" + rlogm="$GIT_REFLOG_ACTION" else echo "$2" - rlogm="$rloga: $2" + rlogm="$GIT_REFLOG_ACTION: $2" fi case "$squash" in t) @@ -109,7 +110,7 @@ merge_name () { case "$#" in 0) usage ;; esac -rloga= have_message= +have_message= while case "$#" in 0) break ;; esac do case "$1" in @@ -139,9 +140,6 @@ do die "available strategies are: $all_strategies" ;; esac ;; - --reflog-action=*) - rloga=`expr "z$1" : 'z-[^=]*=\(.*\)'` - ;; -m=*|--m=*|--me=*|--mes=*|--mess=*|--messa=*|--messag=*|--message=*) merge_msg=`expr "z$1" : 'z-[^=]*=\(.*\)'` have_message=t @@ -213,7 +211,6 @@ head=$(git-rev-parse --verify "$head_arg"^0) || usage # All the rest are remote heads test "$#" = 0 && usage ;# we need at least one remote head. -test "$rloga" = '' && rloga="merge: $@" remoteheads= for remote -- cgit v1.2.3 From de811948baa689382ad191c1c95e8be51a92c4fe Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 28 Dec 2006 02:35:05 -0500 Subject: Honor pull.{twohead,octopus} in git-merge. If git-merge is invoked without a strategy argument it is probably being run as a porcelain-ish command directly and is not being run from within git-pull. However we still should honor whatever merge strategy the user may have selected in their configuration, just as `git-pull .` would have. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- git-merge.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index e8db52725c..ba42260426 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -227,9 +227,21 @@ case "$use_strategies" in '') case "$#" in 1) - use_strategies="$default_twohead_strategies" ;; + var="`git-repo-config --get pull.twohead`" + if test -n "$var" + then + use_strategies="$var" + else + use_strategies="$default_twohead_strategies" + fi ;; *) - use_strategies="$default_octopus_strategies" ;; + var="`git-repo-config --get pull.octopus`" + if test -n "$var" + then + use_strategies="$var" + else + use_strategies="$default_octopus_strategies" + fi ;; esac ;; esac -- cgit v1.2.3 From d1014a1745a8aa90c8de2a5ac7624d8175f96724 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 31 Dec 2006 23:21:50 -0800 Subject: fail pull/merge early in the middle of conflicted merge After a pull that results in a conflicted merge, a new user often tries another "git pull" in desperation. When the index is unmerged, merge backends correctly bail out without touching either index nor the working tree, so this does not make the wound any worse. The user will however see several lines of messsages during this process, such as "filename: needs merge", "you need to resolve your current index first", "Merging...", and "Entry ... would be overwritten by merge. Cannot merge.". They are unnecessarily alarming, and cause useful conflict messages from the first pull scroll off the top of the terminal. This changes pull and merge to run "git-ls-files -u" upfront and stop them much earlier than we currently do. Old timers may know better and would not to try pulling again before cleaning things up; this change adds extra overhead that is unnecessary for them. But this would be worth paying for to save new people from needless confusion. Signed-off-by: Junio C Hamano --- git-merge.sh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index ba42260426..477002910e 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -8,6 +8,9 @@ USAGE='[-n] [--no-commit] [--squash] [-s ] [-m=] Date: Sat, 30 Dec 2006 23:32:38 -0500 Subject: Disallow working directory commands in a bare repository. If the user tries to run a porcelainish command which requires a working directory in a bare repository they may get unexpected results which are difficult to predict and may differ from command to command. Instead we should detect that the current repository is a bare repository and refuse to run the command there, as there is no working directory associated with it. [jc: updated Shawn's original somewhat -- bugs are mine.] Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- git-merge.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'git-merge.sh') diff --git a/git-merge.sh b/git-merge.sh index 477002910e..3eef048efc 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -7,6 +7,7 @@ USAGE='[-n] [--no-commit] [--squash] [-s ] [-m=]