Commit Graph

21 Commits (master)

Author SHA1 Message Date
Christian Hesse 68de710c1c ui-ssdiff: ban strncat()
Git version v2.21.0 marks strncat() as banned (commit
ace5707a803eda0f1dde3d776dc3729d3bc7759a), so replace it.

Signed-off-by: Christian Hesse <mail@eworm.de>
5 years ago
Chris Mayo 5bd7e9bc1b ui-ssdiff: resolve HTML5 validation errors
- Remove ids from anchor elements. They were unusable because they were
  duplicated between files and versions of files.
- Always close span, with html().
- Fix missing / on closing tr element in cgit_ssdiff_header_end().

Signed-off-by: Chris Mayo <aklhfex@gmail.com>
5 years ago
Christian Hesse a96f2890f4 ui-ssdiff: ban strcat()
Git upstream bans strcat() with commit:

  banned.h: mark strcat() as banned
  1b11b64b815db62f93a04242e4aed5687a448748

Signed-off-by: Christian Hesse <mail@eworm.de>
6 years ago
Christian Hesse 0899eb644f ui-ssdiff: ban strncpy()
Git upstream bans strncpy() with commit:

  banned.h: mark strncpy() as banned
  e488b7aba743d23b830d239dcc33d9ca0745a9ad

Signed-off-by: Christian Hesse <mail@eworm.de>
6 years ago
Jason A. Donenfeld 08a2b1b8f8 Fix gcc 8.1.1 compiler warnings
CC ../shared.o
../shared.c: In function ‘expand_macro’:
../shared.c:487:3: warning: ‘strncpy’ specified bound depends on the length of the source argument [-Wstringop-overflow=]
   strncpy(name, value, len);
   ^~~~~~~~~~~~~~~~~~~~~~~~~
../shared.c:484:9: note: length computed here
   len = strlen(value);
         ^~~~~~~~~~~~~
../ui-shared.c: In function ‘cgit_repobasename’:
../ui-shared.c:136:2: warning: ‘strncpy’ specified bound 1024 equals destination size [-Wstringop-truncation]
  strncpy(rvbuf, reponame, sizeof(rvbuf));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    CC ../ui-ssdiff.o
../ui-ssdiff.c: In function ‘replace_tabs’:
../ui-ssdiff.c:142:4: warning: ‘strncat’ output truncated copying between 1 and 8 bytes from a string of length 8 [-Wstringop-truncation]
    strncat(result, spaces, 8 - (strlen(result) % 8));
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
6 years ago
John Keeping 7e67c64894 ui-ssdiff: fix decl-after-statement warnings
git.git's coding style avoids decl-after-statement and we generally try
to follow it but a few warnings have crept in recently.  Fix the one in
ui-ssdiff.c

Signed-off-by: John Keeping <john@keeping.me.uk>
8 years ago
Christian Hesse 11695a58fd git: update to v2.10.0
Upstream continues to replace unsigned char *sha1 with struct
object_id old_oid. This makes the required changes.

The git lib has its own main function now. Rename our main function
to cmd_main, it is called from main then.
8 years ago
Christian Hesse fa5810ed8e ui-ssdiff: fix resource leak: free allocation from cgit_fileurl
Coverity-id: 13929
Signed-off-by: Christian Hesse <mail@eworm.de>
9 years ago
John Keeping e3d3fffdd4 Avoid non-ANSI function declarations
Sparse says things like:

	warning: non-ANSI function declaration of function 'calc_ttl'

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years ago
Peter Wu 4468ec1b15 Reduce line number bloat, fix hover effect
Currently line numbers look like (for blob view and sdiff respectively):

    <a class='no' id='n68' name='n68' href='#n68'>68</a>
    <td class='lineno'><a class='no' href='...#n1' id='n1' name='n1'>1</a></td>

name=".." is unnecessary if the id attribute is set (this even applies
to IE6), so drop it. (aside, in HTML5, the name attribute is gone.)

The line number links can be selected through their parent classes, no
need for another class "no", so drop it too.

For a file with 2000 lines, this yields a saving of 40% (29% gzipped).

While at it, fix the hover effect of line numbers: now the line number
get a black background as was intended.

Signed-off-by: Peter Wu <lekensteyn@gmail.com>
Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
10 years ago
John Keeping 8f20879431 Always #include corresponding .h in .c files
While doing this, remove declarations from header files where the
corresponding definition is declared "static" in order to avoid build
errors.

Also re-order existing headers in ui-*.c so that the file-specific
header always comes immediately after "cgit.h", helping with future
consistency.

Signed-off-by: John Keeping <john@keeping.me.uk>
11 years ago
Julius Plenz 225c8aba31 ssdiff: correctly manage tab expansion
Previously, replace_tabs("foo\tbar") would become "        foobar".

Signed-off-by: Julius Plenz <plenz@cis.fu-berlin.de>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
11 years ago
Julius Plenz c6fe94e02a ssdiff: point line links at exact blob by prepending "id="
Previously, the id_str (i.e. the current or diffed-against commit's
SHA1 ID) was simply concatenated to the URL. Now, prepend an "id="
string so that the links actually point to the right blobs and thus
the exact lines.

Signed-off-by: Julius Plenz <plenz@cis.fu-berlin.de>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
12 years ago
Jamie Couture 6a575b8900 use correct type for sizeof
**L would have worked well too.  Depending on the distribution sizeof *L
may return 8 instead of 4. **L is preferable, but since we don't expect
this datatype to change very often, sizeof int is less subtle and easier
to understand.

Signed-off-by: Jamie Couture <jamie.couture@gmail.com>
12 years ago
Eric Wong 19c31231fa ui-ssdiff.c: correct length check for LCS table
Each individual string may be too long for its respective
dimension of the LCS table.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
13 years ago
Jamie Couture e19f7d7180 ui-ssdiff: move LCS table away from the stack
Printing deferred line changes for files containing long lines would
cause a segfault.

- limit LCS table size: 128x128.
- move LCS table to global context: avoid allocating/freeing memory
  for every deferred line change.

Signed-off-by: Jamie Couture <jamie.couture@gmail.com>
13 years ago
Bernhard Reutner-Fischer e52040bf90 ssdiff: anchors for ssdiff
Emit anchors to the respective revisions in side-by-side diff view

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
13 years ago
Ragnar Ouchterlony 735e15e38a In side-by-side diff, add support for marking individual characters.
Refuses to do so if the left hand side of the diff has different amount of
differing lines to the right hand side to avoid confusion.

Note that I use the naive dynamic programming approach for calculating the
longest common subsequence. We could probably be more efficient by using a
better algorithm. The LCS calculating function is O(n*m) and uses up n*m
amount of memory too (so if we we compare two strings of length 100, I use
an array of 10000 for calculating the LCS). Might want to not calculate LCS
if the length of the line is too large.

Signed-off-by: Ragnar Ouchterlony <ragnar@lysator.liu.se>
15 years ago
Ragnar Ouchterlony 4a198e4b8e Fixed side-by-side diff bugs related to binary diff and more.
The fixed bugs:

 * "Binary files differ" did not show up either in unidiff or
   side-by-side-diff.
 * Subproject diffs did not work for side-by-side diffs.
 * The ssdiff link on diff pages did not conserve the path.

Signed-off-by: Ragnar Ouchterlony <ragnar@lysator.liu.se>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
15 years ago
Ragnar Ouchterlony 207cc34711 Polishing of how the side-by-side diff looks.
Aligned all different files, so that all side-by-side tables look
the same. Also made sure that the tables take up the whole browser
width.

Also various changes to the css to make things easier on the eye.

Signed-off-by: Ragnar Ouchterlony <ragnar@lysator.liu.se>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
15 years ago
Ragnar Ouchterlony 40e174d536 First version of side-by-side diff.
This constitutes the first prototype of a side-by-side diff. It is not
possible to switch between unidiff and side-by-side diff at all at this
stage.

Signed-off-by: Ragnar Ouchterlony <ragnar@lysator.liu.se>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
15 years ago