From c1d1128bef97ae16a6740538abe5fb81c67ed239 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 28 Apr 2006 02:32:44 -0700 Subject: git-am --resolved: more usable error message. After doing the hard work of hand resolving the conflicts in the working tree, if the user forgets to run update-index to mark the paths that have been resolved, the command gave an unfriendly "fatal: git-write-tree: not able to write tree" error message. Catch the situation early and give more meaningful message and suggestion. Noticed and suggested by Len Brown. Signed-off-by: Junio C Hamano --- git-am.sh | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'git-am.sh') diff --git a/git-am.sh b/git-am.sh index eab4aa891e..872145b92d 100755 --- a/git-am.sh +++ b/git-am.sh @@ -376,6 +376,13 @@ do echo "No changes - did you forget update-index?" stop_here $this fi + unmerged=$(git-ls-files -u) + if test -n "$unmerged" + then + echo "You still have unmerged paths in your index" + echo "did you forget update-index?" + stop_here $this + fi apply_status=0 ;; esac -- cgit v1.2.3 From ced9456a27197fc038fbc5b5ebad87e55f1920d2 Mon Sep 17 00:00:00 2001 From: Robert Shearman Date: Tue, 2 May 2006 13:32:43 +0100 Subject: Give the user a hint for how to continue in the case that git-am fails because it requires user intervention Give the user a hint for how to continue in the case that git-am fails because it requires user intervention. Signed-off-by: Robert Shearman Signed-off-by: Junio C Hamano --- git-am.sh | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'git-am.sh') diff --git a/git-am.sh b/git-am.sh index 872145b92d..507ae4dcb9 100755 --- a/git-am.sh +++ b/git-am.sh @@ -14,6 +14,26 @@ stop_here () { exit 1 } +stop_here_user_resolve () { + cmdline=$(basename $0) + if test '' != "$interactive" + then + cmdline="$cmdline -i" + fi + if test '' != "$threeway" + then + cmdline="$cmdline -3" + fi + if test '.dotest' != "$dotest" + then + cmdline="$cmdline -d=$dotest" + fi + echo "When you have resolved this problem run \"$cmdline --resolved\"." + echo "If you would prefer to skip this patch, instead run \"$cmdline --skip\"." + + stop_here $1 +} + go_next () { rm -f "$dotest/$msgnum" "$dotest/msg" "$dotest/msg-clean" \ "$dotest/patch" "$dotest/info" @@ -374,14 +394,14 @@ do if test '' = "$changed" then echo "No changes - did you forget update-index?" - stop_here $this + stop_here_user_resolve $this fi unmerged=$(git-ls-files -u) if test -n "$unmerged" then echo "You still have unmerged paths in your index" echo "did you forget update-index?" - stop_here $this + stop_here_user_resolve $this fi apply_status=0 ;; @@ -407,7 +427,7 @@ do if test $apply_status != 0 then echo Patch failed at $msgnum. - stop_here $this + stop_here_user_resolve $this fi if test -x "$GIT_DIR"/hooks/pre-applypatch -- cgit v1.2.3 From cc120056a881101326488e3c5c2d3af2ce3a8de6 Mon Sep 17 00:00:00 2001 From: Sean Date: Sat, 13 May 2006 23:34:08 -0400 Subject: Make git rebase interactive help match documentation. Signed-off-by: Sean Estabrooks Signed-off-by: Junio C Hamano --- git-am.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'git-am.sh') diff --git a/git-am.sh b/git-am.sh index 507ae4dcb9..33f208cb0b 100755 --- a/git-am.sh +++ b/git-am.sh @@ -15,6 +15,10 @@ stop_here () { } stop_here_user_resolve () { + if [ -n "$resolvemsg" ]; then + echo "$resolvemsg" + stop_here $1 + fi cmdline=$(basename $0) if test '' != "$interactive" then @@ -121,7 +125,7 @@ fall_back_3way () { } prec=4 -dotest=.dotest sign= utf8= keep= skip= interactive= resolved= binary= ws= +dotest=.dotest sign= utf8= keep= skip= interactive= resolved= binary= ws= resolvemsg= while case "$#" in 0) break;; esac do @@ -157,6 +161,9 @@ do --whitespace=*) ws=$1; shift ;; + --resolvemsg=*) + resolvemsg=$(echo "$1" | sed -e "s/^--resolvemsg=//"); shift ;; + --) shift; break ;; -*) @@ -185,7 +192,7 @@ then else # Make sure we are not given --skip nor --resolved test ",$skip,$resolved," = ,,, || - die "we are not resuming." + die "Resolve operation not in progress, we are not resuming." # Start afresh. mkdir -p "$dotest" || exit -- cgit v1.2.3 From b7627278e200d8a80df6ee437b1a01d88f2b4883 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 15 May 2006 17:25:43 -0700 Subject: git-am: use apply --cached Now 'git apply' can apply patch without working tree, preparation of pristine preimage and postimage trees that are done when falling back on 3-way merge by "git am" can do so without temporary files. Signed-off-by: Junio C Hamano --- git-am.sh | 38 ++------------------------------------ 1 file changed, 2 insertions(+), 36 deletions(-) (limited to 'git-am.sh') diff --git a/git-am.sh b/git-am.sh index 507ae4dcb9..f50dff2222 100755 --- a/git-am.sh +++ b/git-am.sh @@ -55,46 +55,12 @@ fall_back_3way () { GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \ git-write-tree >"$dotest/patch-merge-base+" && # index has the base tree now. - ( - cd "$dotest/patch-merge-tmp-dir" && - GIT_INDEX_FILE="../patch-merge-tmp-index" \ - GIT_OBJECT_DIRECTORY="$O_OBJECT" \ - git-apply $binary --index <../patch - ) + GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \ + git-apply $binary --cached <"$dotest/patch" then echo Using index info to reconstruct a base tree... mv "$dotest/patch-merge-base+" "$dotest/patch-merge-base" mv "$dotest/patch-merge-tmp-index" "$dotest/patch-merge-index" - else - # Otherwise, try nearby trees that can be used to apply the - # patch. - ( - N=10 - - # Hoping the patch is against our recent commits... - git-rev-list --max-count=$N HEAD - - # or hoping the patch is against known tags... - git-ls-remote --tags . - ) | - while read base junk - do - # See if we have it as a tree... - git-cat-file tree "$base" >/dev/null 2>&1 || continue - - rm -fr "$dotest"/patch-merge-* && - mkdir "$dotest/patch-merge-tmp-dir" || break - ( - cd "$dotest/patch-merge-tmp-dir" && - GIT_INDEX_FILE=../patch-merge-tmp-index && - GIT_OBJECT_DIRECTORY="$O_OBJECT" && - export GIT_INDEX_FILE GIT_OBJECT_DIRECTORY && - git-read-tree "$base" && - git-apply $binary --index && - mv ../patch-merge-tmp-index ../patch-merge-index && - echo "$base" >../patch-merge-base - ) <"$dotest/patch" 2>/dev/null && break - done fi test -f "$dotest/patch-merge-index" && -- cgit v1.2.3