@matheusbsbs / matheus-bagliano / commits / dc81c58cd6
Fork 0

git-branch: rename config vars branch.<branch>.*, too

When renaming a branch, the corresponding config section should be renamed, too. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>

Johannes Schindelin committed Dec 16, 2006 at 15:15 UTC dc81c58cd6b791a3db23f1d1acb5f7d38d1ff086
2 files changed +16
refs.c
+10
@@ -867,6 +867,16 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
867 goto rollback;
868 }
869
870 + if (!strncmp(oldref, "refs/heads/", 11) &&
871 + !strncmp(newref, "refs/heads/", 11)) {
872 + char oldsection[1024], newsection[1024];
873 +
874 + snprintf(oldsection, 1024, "branch.%s", oldref + 11);
875 + snprintf(newsection, 1024, "branch.%s", newref + 11);
876 + if (git_config_rename_section(oldsection, newsection) < 0)
877 + return 1;
878 + }
879 +
880 return 0;
881
882 rollback:
t/t3200-branch.sh
+6
@@ -94,6 +94,8 @@ test_expect_failure \
94 git-branch r &&
95 git-branch -m q r/q'
96
97 +git-repo-config branch.s/s.dummy Hello
98 +
99 test_expect_success \
100 'git branch -m s/s s should work when s/t is deleted' \
101 'git-branch -l s/s &&
@@ -104,6 +106,10 @@ test_expect_success \
106 git-branch -m s/s s &&
107 test -f .git/logs/refs/heads/s'
108
109 +test_expect_success 'config information was renamed, too' \
110 + "test $(git-repo-config branch.s.dummy) = Hello &&
111 + ! git-repo-config branch.s/s/dummy"
112 +
113 test_expect_failure \
114 'git-branch -m u v should fail when the reflog for u is a symlink' \
115 'git-branch -l u &&