Skip to content

Commit 3968e30

Browse files
fingolfingitster
authored andcommitted
remote-hg: fix handling of file perms when pushing
Previously, when changing and committing an executable file, the file would loose its executable bit on the hg side. Likewise, symlinks ended up as "normal" files". This was not immediately apparent on the git side unless one did a fresh clone. Signed-off-by: Max Horn <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent eacf011 commit 3968e30

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

contrib/remote-helpers/git-remote-hg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def gittz(tz):
5353
return '%+03d%02d' % (-tz / 3600, -tz % 3600 / 60)
5454

5555
def hgmode(mode):
56-
m = { '0100755': 'x', '0120000': 'l' }
56+
m = { '100755': 'x', '120000': 'l' }
5757
return m.get(mode, '')
5858

5959
def get_config(config):

contrib/remote-helpers/test-hg-hg-git.sh

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,74 @@ setup () {
109109

110110
setup
111111

112+
test_expect_success 'executable bit' '
113+
mkdir -p tmp && cd tmp &&
114+
test_when_finished "cd .. && rm -rf tmp" &&
115+
116+
(
117+
git init -q gitrepo &&
118+
cd gitrepo &&
119+
echo alpha > alpha &&
120+
chmod 0644 alpha &&
121+
git add alpha &&
122+
git commit -m "add alpha" &&
123+
chmod 0755 alpha &&
124+
git add alpha &&
125+
git commit -m "set executable bit" &&
126+
chmod 0644 alpha &&
127+
git add alpha &&
128+
git commit -m "clear executable bit"
129+
) &&
130+
131+
for x in hg git; do
132+
(
133+
hg_clone_$x gitrepo hgrepo-$x &&
134+
cd hgrepo-$x &&
135+
hg_log . &&
136+
hg manifest -r 1 -v &&
137+
hg manifest -v
138+
) > output-$x &&
139+
140+
git_clone_$x hgrepo-$x gitrepo2-$x &&
141+
git_log gitrepo2-$x > log-$x
142+
done &&
143+
cp -r log-* output-* /tmp/foo/ &&
144+
145+
test_cmp output-hg output-git &&
146+
test_cmp log-hg log-git
147+
'
148+
149+
test_expect_success 'symlink' '
150+
mkdir -p tmp && cd tmp &&
151+
test_when_finished "cd .. && rm -rf tmp" &&
152+
153+
(
154+
git init -q gitrepo &&
155+
cd gitrepo &&
156+
echo alpha > alpha &&
157+
git add alpha &&
158+
git commit -m "add alpha" &&
159+
ln -s alpha beta &&
160+
git add beta &&
161+
git commit -m "add beta"
162+
) &&
163+
164+
for x in hg git; do
165+
(
166+
hg_clone_$x gitrepo hgrepo-$x &&
167+
cd hgrepo-$x &&
168+
hg_log . &&
169+
hg manifest -v
170+
) > output-$x &&
171+
172+
git_clone_$x hgrepo-$x gitrepo2-$x &&
173+
git_log gitrepo2-$x > log-$x
174+
done &&
175+
176+
test_cmp output-hg output-git &&
177+
test_cmp log-hg log-git
178+
'
179+
112180
test_expect_success 'merge conflict 1' '
113181
mkdir -p tmp && cd tmp &&
114182
test_when_finished "cd .. && rm -rf tmp" &&

0 commit comments

Comments
 (0)