aboutsummaryrefslogtreecommitdiffstats
path: root/ui-shared.c
diff options
context:
space:
mode:
authorLukas Fleischer2013-08-27 10:40:51 +0200
committerJason A. Donenfeld2013-09-14 19:31:50 +0200
commitd181d6593f827a524b9a7ebc860fa53410fddea2 (patch)
tree8f2f1f7627c9be8e19d3a5255763f052c07559bb /ui-shared.c
parent2da46fe5aa7f18839238c37d9bcb63657f89be26 (diff)
downloadcgit-d181d6593f827a524b9a7ebc860fa53410fddea2.tar.gz
cgit-d181d6593f827a524b9a7ebc860fa53410fddea2.tar.bz2
cgit-d181d6593f827a524b9a7ebc860fa53410fddea2.zip
ui-shared: Drop filepair_cb_raw() and helper
Remove filepair_cb_raw() and all related functions. These are no longer needed. We now use Git's internal functions for raw diff formatting everywhere. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
Diffstat (limited to 'ui-shared.c')
-rw-r--r--ui-shared.c72
1 files changed, 0 insertions, 72 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 1e19421..7ab2ab1 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -950,75 +950,3 @@ void cgit_print_snapshot_links(const char *repo, const char *head,
950 } 950 }
951 strbuf_release(&filename); 951 strbuf_release(&filename);
952} 952}
953
954static void print_line_raw(char *line, int len)
955{
956 char c = line[len-1];
957
958 line[len-1] = '\0';
959 htmlf("%s\n", line);
960 line[len-1] = c;
961}
962
963static void header_raw(unsigned char *sha1, char *path1, int mode1,
964 unsigned char *sha2, char *path2, int mode2)
965{
966 char *abbrev1, *abbrev2;
967 int subproject;
968
969 subproject = (S_ISGITLINK(mode1) || S_ISGITLINK(mode2));
970 htmlf("diff --git a/%s b/%s\n", path1, path2);
971
972 if (mode1 == 0)
973 htmlf("new file mode %.6o\n", mode2);
974
975 if (mode2 == 0)
976 htmlf("deleted file mode %.6o\n", mode1);
977
978 if (!subproject) {
979 abbrev1 = xstrdup(find_unique_abbrev(sha1, DEFAULT_ABBREV));
980 abbrev2 = xstrdup(find_unique_abbrev(sha2, DEFAULT_ABBREV));
981 htmlf("index %s..%s", abbrev1, abbrev2);
982 free(abbrev1);
983 free(abbrev2);
984 if (mode1 != 0 && mode2 != 0) {
985 htmlf(" %.6o", mode1);
986 if (mode2 != mode1)
987 htmlf("..%.6o", mode2);
988 }
989
990 if (is_null_sha1(sha1)) {
991 path1 = "dev/null";
992 htmlf("\n--- /%s\n", path1);
993 } else
994 htmlf("\n--- a/%s\n", path1);
995
996 if (is_null_sha1(sha2)) {
997 path2 = "dev/null";
998 htmlf("+++ /%s\n", path2);
999 } else
1000 htmlf("+++ b/%s\n", path2);
1001 }
1002}
1003
1004void filepair_cb_raw(struct diff_filepair *pair)
1005{
1006 unsigned long old_size = 0;
1007 unsigned long new_size = 0;
1008 int binary = 0;
1009
1010 header_raw(pair->one->sha1, pair->one->path, pair->one->mode,
1011 pair->two->sha1, pair->two->path, pair->two->mode);
1012 if (S_ISGITLINK(pair->one->mode) || S_ISGITLINK(pair->two->mode)) {
1013 if (S_ISGITLINK(pair->one->mode))
1014 print_line_raw(fmt("-Subproject %s", sha1_to_hex(pair->one->sha1)), 52);
1015 if (S_ISGITLINK(pair->two->mode))
1016 print_line_raw(fmt("+Subproject %s", sha1_to_hex(pair->two->sha1)), 52);
1017 return;
1018 }
1019 if (cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size,
1020 &new_size, &binary, 0, 0, print_line_raw))
1021 html("Error running diff");
1022 if (binary)
1023 html("Binary files differ\n");
1024}