@matheusbsbs / matheus-bagliano / commits / 3d1d81eba2
Fork 0

fast-import: Cleanup mode setting.

"S_IFREG | mode" makes only sense for 0644 and 0755. Even though doing (S_IFREG | mode) may not hurt when mode is any other supported value, that is only true because S_IFREG mode bit happens to be already on for S_IFLNK or S_IFGITLINK. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Acked-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Felipe Contreras committed Jan 14, 2009 at 03:37 UTC 3d1d81eba29d5cfc5b214dc049b743ffbe032ef4
1 file changed +4 -3
fast-import.c
+4 -3
@@ -1868,12 +1868,13 @@ static void file_change_m(struct branch *b)
1868 if (!p)
1869 die("Corrupt mode: %s", command_buf.buf);
1870 switch (mode) {
1871 + case 0644:
1872 + case 0755:
1873 + mode |= S_IFREG;
1874 case S_IFREG | 0644:
1875 case S_IFREG | 0755:
1876 case S_IFLNK:
1877 case S_IFGITLINK:
1875 - case 0644:
1876 - case 0755:
1878 /* ok */
1879 break;
1880 default:
@@ -1940,7 +1941,7 @@ static void file_change_m(struct branch *b)
1941 typename(type), command_buf.buf);
1942 }
1943
1943 - tree_content_set(&b->branch_tree, p, sha1, S_IFREG | mode, NULL);
1944 + tree_content_set(&b->branch_tree, p, sha1, mode, NULL);
1945 }
1946
1947 static void file_change_d(struct branch *b)