git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Use reflog in 'pull --rebase . foo'

From
Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
Date
Nov 13, 2010, 12:09 UTC
Message-ID
<AANLkTiniwpk7ao=M4=5vuahczk6FscQYJE1rZx=wuBk_@mail.gmail.com>
In-Reply-To
<m2pqu98urp.fsf@whitebox.home>

I see, maybe just dropping the middle part of the patch would be better. I think it looks like I have lost a '.*' in there as well (test cases pass though, so I'm not sure). Anyway, better be safe than sorry. The following seems better.

diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index 5f47b18..2e1661d 100644
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -63,11 +63,8 @@ get_default_remote () {
 get_remote_merge_branch () {
 	case "$#" in
 	0|1)
-	    origin="$1"
-	    default=$(get_default_remote)
-	    test -z "$origin" && origin=$default
 	    curr_branch=$(git symbolic-ref -q HEAD)
-	    [ "$origin" = "$default" ] &&
+	    test -z "$1" || test "$1" = $(get_default_remote) &&
 	    echo $(git for-each-ref --format='%(upstream)' $curr_branch)
 	    ;;
 	*)
@@ -89,7 +86,13 @@ get_remote_merge_branch () {
 	    refs/heads/*) remote=${remote#refs/heads/} ;;
 	    refs/* | tags/* | remotes/* ) remote=
 	    esac
-
-	    [ -n "$remote" ] && echo "refs/remotes/$repo/$remote"
+	    [ -n "$remote" ] && case "$repo" in
+		.)
+		    echo "refs/heads/$remote"
+		    ;;
+		*)
+		    echo "refs/remotes/$repo/$remote"
+		    ;;
+	    esac
 	esac
 }
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 0b489f5..0470a81 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -222,4 +222,11 @@ test_expect_success 'git pull --rebase does not
reapply old patches' '
 	)
 '

+test_expect_success 'git pull --rebase against local branch' '
+	git checkout -b copy2 to-rebase-orig &&
+	git pull --rebase . to-rebase &&
+	test "conflicting modification" = "$(cat file)" &&
+	test file = "$(cat file2)"
+'
+
 test_done
-- 
1.7.3.2.167.ga361b
Previous: Andreas SchwabNext: Santi Béjar
Message 3 of 6 in “Use reflog in 'pull --rebase . foo'”
  1. Use reflog in 'pull --rebase . foo'Martin von Zweigbergk, Nov 12, 2010
  2. Andreas SchwabNov 13, 2010
  3. Martin von ZweigbergkNov 13, 2010
  4. Santi BéjarNov 13, 2010
  5. Martin von ZweigbergkNov 13, 2010
  6. Santi BéjarNov 13, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.