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

[PATCH] Make git-clone respect branch.autosetuprebase

From
pknotz@sandia.gov <pknotz@sandia.gov>
Date
Mar 3, 2009, 18:35 UTC
Message-ID
<1236105352-21335-1-git-send-email-pknotz@sandia.gov>
From: Pat Notz <pknotz@sandia.gov>

When git-clone creates an initial branch it was not checking the branch.autosetuprebase configuration option (which may exist in ~/.gitconfig).

Signed-off-by: Pat Notz <pknotz@sandia.gov>
---
 builtin-clone.c  |    8 ++++++++
 t/t5601-clone.sh |   14 ++++++++++++++
 2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/builtin-clone.c b/builtin-clone.c
index c338910..f547267 100644
--- a/builtin-clone.c
+++ b/builtin-clone.c
@@ -360,6 +360,14 @@ static void install_branch_config(const char *local,
 	strbuf_reset(&key);
 	strbuf_addf(&key, "branch.%s.merge", local);
 	git_config_set(key.buf, remote);
+	switch (autorebase) {
+	case AUTOREBASE_REMOTE:
+	case AUTOREBASE_ALWAYS:
+		strbuf_reset(&key);
+		strbuf_addf(&key, "branch.%s.rebase", local);
+		git_config_set(key.buf, "true");
+		printf("Default branch '%s' will rebase on pull.\n", local);
+	}
 	strbuf_release(&key);
 }
 
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index 44793f2..0f8b43c 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -159,4 +159,18 @@ test_expect_success 'clone a void' '
 	test_cmp target-6/.git/config target-7/.git/config
 '
 
+test_expect_success 'clone respects global branch.autosetuprebase' '
+	HOME="`pwd`" &&
+	export HOME &&
+	test_config="$HOME"/.gitconfig &&
+	unset GIT_CONFIG_NOGLOBAL &&
+	git config -f "$test_config" branch.autosetuprebase remote &&
+	rm -fr dst &&
+	git clone src dst &&
+	cd dst &&
+	expected="ztrue" &&
+	actual="z$(git config branch.master.rebase)" &&
+	test $expected = $actual
+'
+
 test_done
-- 
1.6.1.2
Next: Junio C Hamano
Message 1 of 2 in “Make git-clone respect branch.autosetuprebase”
  1. Make git-clone respect branch.autosetuprebasepknotz@sandia.gov, Mar 3, 2009
  2. Junio C HamanoMar 3, 2009

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.